Commit b6e173f9 authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

add support for fits: support s3a://

parent 04092ce1
Pipeline #10827 passed with stage
...@@ -14,9 +14,11 @@ from csst_fs.s3_config import load_s3_options ...@@ -14,9 +14,11 @@ from csst_fs.s3_config import load_s3_options
s3_options = load_s3_options() s3_options = load_s3_options()
s3_prefix = ("s3://", "s3a://")
def open(filename, **kwargs) -> fits.HDUList: def open(filename, **kwargs) -> fits.HDUList:
if filename.startswith("s3://"): if filename.startswith(s3_prefix):
# read FITS file from s3 # read FITS file from s3
return fits.open(filename, use_fsspec=True, fsspec_kwargs=s3_options, **kwargs) return fits.open(filename, use_fsspec=True, fsspec_kwargs=s3_options, **kwargs)
else: else:
...@@ -25,7 +27,7 @@ def open(filename, **kwargs) -> fits.HDUList: ...@@ -25,7 +27,7 @@ def open(filename, **kwargs) -> fits.HDUList:
def getheader(filename, **kwargs) -> fits.HDUList: def getheader(filename, **kwargs) -> fits.HDUList:
if filename.startswith("s3://"): if filename.startswith(s3_prefix):
# read FITS file from s3 # read FITS file from s3
return fits.getheader( return fits.getheader(
filename, use_fsspec=True, fsspec_kwargs=s3_options, **kwargs filename, use_fsspec=True, fsspec_kwargs=s3_options, **kwargs
...@@ -36,7 +38,7 @@ def getheader(filename, **kwargs) -> fits.HDUList: ...@@ -36,7 +38,7 @@ def getheader(filename, **kwargs) -> fits.HDUList:
def getval(filename, **kwargs) -> fits.HDUList: def getval(filename, **kwargs) -> fits.HDUList:
if filename.startswith("s3://"): if filename.startswith(s3_prefix):
# read FITS file from s3 # read FITS file from s3
return fits.getval( return fits.getval(
filename, use_fsspec=True, fsspec_kwargs=s3_options, **kwargs filename, use_fsspec=True, fsspec_kwargs=s3_options, **kwargs
...@@ -47,7 +49,7 @@ def getval(filename, **kwargs) -> fits.HDUList: ...@@ -47,7 +49,7 @@ def getval(filename, **kwargs) -> fits.HDUList:
def getdata(filename, **kwargs) -> fits.HDUList: def getdata(filename, **kwargs) -> fits.HDUList:
if filename.startswith("s3://"): if filename.startswith(s3_prefix):
# read FITS file from s3 # read FITS file from s3
return fits.getdata( return fits.getdata(
filename, use_fsspec=True, fsspec_kwargs=s3_options, **kwargs filename, use_fsspec=True, fsspec_kwargs=s3_options, **kwargs
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment