Enh/embedded figures - adds a module in gempy/adlibrary to embed non-FITS files (PDFs etc) in astrodata instances and FITS files#516
Open
phirstgemini wants to merge 2 commits intomasterfrom
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #516 +/- ##
==========================================
+ Coverage 66.79% 66.81% +0.02%
==========================================
Files 316 318 +2
Lines 40195 40295 +100
==========================================
+ Hits 26848 26923 +75
- Misses 13347 13372 +25
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There's been various discussions in the FITS community about storing non-FITS files (typically but not exclusively PDF / JPG / PNG graphics) inside FITS files. There are various ways to do this with various degrees of support. Consensus usually settles on storing the data in a binary table.
This PR adds:
embedded_files.pymodule ingempy/adlibrary(with tests) to implement this. This allows capturing such files into an attribute of an astrodata instance and storing them as above in the corresponding FITS file.extract_files[.py]script ingempy/scriptsto easily extract such files from their FITS containers.geminidr/core/primitives_spect.pyto use the module to capture the arc PDF plot into the processed arc.The way this is implemented the name of the ad attribute (that becomes the binary table FITS extension) defaults to
FIGURESbut the name can be specified in the call, and can contain multiple embedded files. There's nothing to stop adding multiple such attributes with different names. It uses variable length byte records to store the file contents, so does not waste space in the binary table if multiple files of different lengths are stored in the same attribute. The table also has columns for filename, size and md5sum to facilitate data integrity checking.The implementation is simple, and due to the way FITS (and astropy) tables work, it not especially memory efficient for example when adding additional files to an existing table. This could be improved but the figures in question are usually small (~10s of K) compared to available memory so this is not an issue unless a use case arises to manipulate large data files using this mechanism