Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reading from memory instead of disk? #307

Open
sbailey opened this issue Aug 17, 2020 · 7 comments
Open

reading from memory instead of disk? #307

sbailey opened this issue Aug 17, 2020 · 7 comments
Labels
feature request An issue requesting a new feature

Comments

@sbailey
Copy link
Contributor

sbailey commented Aug 17, 2020

Does fitsio support the ability to read from memory instead of disk?

This question is the inverse of #270, which documents how to write to memory instead of disk.

e.g. I'm looking for something like

fx = fitsio.FITS(io.BytesIO(data), 'r')  #- doesn't work

equivalent to

fx = astropy.io.fits.open(io.BytesIO(data))

Is this possible with fitsio?

@esheldon
Copy link
Owner

I don't think this particular things works (io.BytesIO(data)) , but I think cfitsio can read from memory. There may be a way to make it happen

@beckermr
Copy link
Collaborator

Do we need to pass down some emulated interface to a C file? That might be a tall order.

@esheldon
Copy link
Owner

Yeah, I'm not saying I know how to do it.

@beckermr
Copy link
Collaborator

https://heasarc.gsfc.nasa.gov/docs/software/fitsio/c/c_user/node91.html

This looks annoying and not fun.

@beckermr
Copy link
Collaborator

@sbailey
Copy link
Contributor Author

sbailey commented Aug 24, 2020

Thanks. My interest for this in-memory reading isn't urgent, but I just wanted to check if I was missing some pre-existing mem:// like trick to make it work analogous to the writing case. FWIW, use cases I was considering:

  • pulling FITS contents from a non-posix object store as a binary blob and then parsing it as a FITS file in memory without having to pass it via an actual file on disk
  • working on a filesystem with good bandwidth but poor/variable latency on individual I/O operations such that doing a single big read and then doing the parsing / seek / etc. in memory might be better performance. Maybe

@beckermr
Copy link
Collaborator

working on a filesystem with good bandwidth but poor/variable latency on individual I/O operations such that doing a single big read and then doing the parsing / seek / etc. in memory might be better performance. Maybe

So cfitsio does a lot of buffering internally. For this specific purpose, you may find that you don't need to buffer in memory yourself as well.

@esheldon esheldon added the feature request An issue requesting a new feature label Nov 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request An issue requesting a new feature
Projects
None yet
Development

No branches or pull requests

3 participants