Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
csst-pipeline
csst_fs
Commits
898f5408
Commit
898f5408
authored
Jul 30, 2024
by
Matthias Weidenthaler
Browse files
Added fromfile feature for hdulists
parent
3f4284d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
898f5408
...
@@ -158,6 +158,23 @@ fsspec_HDUList.writeto(hdul_img, out_combined_img, overwrite=True)
...
@@ -158,6 +158,23 @@ fsspec_HDUList.writeto(hdul_img, out_combined_img, overwrite=True)
fsspec_HDUList.writeto(hdul_img, out_combined_img, s3_options=s3_options, overwrite=True)
fsspec_HDUList.writeto(hdul_img, out_combined_img, s3_options=s3_options, overwrite=True)
```
```
### HDUList.fromfile
#### 老写法
```
python
hdul_img = fits.HDUList.fromfile("hdulist.fits")
```
usage reference:
[https://docs.astropy.org/en/stable/io/fits/api/hdulists.html#astropy.io.fits.HDUList.fromfile](https://docs.astropy.org/en/stable/io/fits/api/hdulists.html#astropy.io.fits.HDUList.fromfile)
#### 新写法
```python
from csst_fs import fsspec_HDUList
hdul_img = fsspec_HDUList.fromfile("hdulist.fits")
hdul_img = fsspec_HDUList.fromfile("hdulist.fits", cache=False, s3_options=s3_options)
```
### table.Table.read
### table.Table.read
#### 老写法
#### 老写法
```
python
```
python
...
...
csst_fs/fits/fsspec_HDUList.py
View file @
898f5408
import
fsspec
import
fsspec
from
astropy.io
import
fits
from
..fsspec_fileobj
import
open_fileobj
from
..fsspec_fileobj
import
open_fileobj
from
..s3_config
import
load_s3_options
from
..s3_config
import
load_s3_options
def
writeto
(
fits_HDUList
,
out_path
,
s3_options
=
load_s3_options
(),
*
args
,
**
kwargs
):
def
writeto
(
fits_HDUList
,
out_path
,
*
args
,
s3_options
=
load_s3_options
(),
**
kwargs
):
fileobj
=
open_fileobj
(
out_path
,
s3_options
,
mode
=
'wb'
)
fileobj
=
open_fileobj
(
out_path
,
s3_options
,
mode
=
'wb'
)
fits_HDUList
.
writeto
(
fileobj
,
*
args
,
**
kwargs
)
fits_HDUList
.
writeto
(
fileobj
,
*
args
,
**
kwargs
)
if
hasattr
(
fileobj
,
'close'
):
if
hasattr
(
fileobj
,
'close'
):
fileobj
.
close
()
fileobj
.
close
()
def
fromfile
(
filename
,
*
args
,
s3_options
=
load_s3_options
(),
**
kwargs
):
fileobj
=
open_fileobj
(
filename
,
s3_options
,
mode
=
'rb'
)
return
fits
.
HDUList
.
fromfile
(
fileobj
,
*
args
,
**
kwargs
)
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment