User defined units fail to parse when reading into QTable
See original GitHub issueI construct a QTable that takes in data as a user defined unit and output it to the current directory.
bandpass_sol_lum = u.def_unit('bandpass_sol_lum')
lum_array = np.ones((5,5)) * bandpass_sol_lum
qt = QTable()
qt['Luminosity'] = QTable.Column(lum_array)
qt.write('output_lum.fits',overwrite=True,format='fits')
When I read it back in:
qt_readIn = QTable()
qt_readIn['Luminosity'] = QTable.read('output_lum.fits',format='fits') # <--Exception thrown
I get:
YamlParseError: 'bandpass_sol_lum' did not parse as unit: At col 0, bandpass_sol_lum is not a valid unit.
Is it possible at all to parse user defined units when reading them back in from a FITS file? @zpace
My environment: macOS 10.14.3 python 3.6.8 astropy 3.2 numpy 1.16.4
[Edit]: To address this issue, read the comments below and add the example to the documentation as discussed.
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (7 by maintainers)
Top Results From Across the Web
Unified File Read/Write Interface — Astropy v5.2
Reading and writing image data in the unified I/O interface is supported though ... To use this interface, first import the Table class,...
Read more >Using quantities to parse data with units and errors - r-spatial
The problem of reading and parsing quantities with errors and units depends on the reporting scheme used. Let us consider errors first.
Read more >Advanced Queuing & PL/SQL Notification - Ask TOM
Every example I read take a record type as payload parameter, when I replicate them but use a varray type as payload it...
Read more >Model/View Tutorial | Qt Widgets 6.4.1
A table widget is a 2D array of the data elements that the user can change. The table widget can be integrated into...
Read more >Let's Write a Simple JPEG Library, Part-II: The Decoder
The JPEG compression algorithm: After reading the encoded data from the JFIF file, it has to replay the steps of encoding in the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I could make the documentation changes if that’s alright.
Fortunately, it is easier than that! The trick is to tell the whole system about the existence of this new unit using
u.add_enabled_units(bandpass_sol_lum)
:One thing that is odd - likely a bug - is that if I add the unit before writing the fits file, I get an error; e.g., if after the above I try rewriting:
This is weird. And separate from your issue, so let’s make it a new one: #8887