Demetra spectra FITS header

Post Reply
Jacques Michelet
Posts: 16
Joined: Mon Apr 01, 2019 8:13 pm

Demetra spectra FITS header

Post by Jacques Michelet »

Here is a minor issue that may be fixed quite easily:

Demetra issues spectra as FITS files, with flux data contained in the first HDU. The wavelength data are derived from the FITS header, using the WCS convention.
The WCS is able to convert pixels to wavelengths, or wavelength to pixel, and assumes the FITS header specifies one - and only one - axis.
But the Demetra spectrum header is not FITS-compliant as it contains 2 keywords (CTYPE2 and CUNIT2) that fools the WCS when opening the file. For instance, using some Python code, here are some warnings:

Code: Select all

>>> import specutils as sp
>>> sp.Spectrum1D.read('/home/jaq/astro/dev/argia/05-spectroscopie/alcyone.fit')
WARNING: FITSFixedWarning: The WCS transformation has more axes (2) than the image it is associated with (1) [astropy.wcs.wcs]
WARNING: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 59560.788125 from DATE-OBS'. [astropy.wcs.wcs]
WARNING: UnitsWarning: 'Intensit?relative' did not parse as fits unit: At col 0, Unit 'Intensit' not supported by the FITS standard.  If this is meant to be a custom unit, define it with 'u.def_unit'. To have it recognized inside a file reader or other code, enable it with 'u.add_enabled_units'. For details, see https://docs.astropy.org/en/latest/units/combining_and_defining.html [astropy.units.core]
<Spectrum1D(flux=<Quantity [1.537479 , 1.5703377, 1.603197 , ..., 0.8247515, 0.8243076,
           0.8238455]>, spectral_axis=<SpectralAxis [3802.08096824, 3802.26786349, 3802.45475874, ..., 5869.14242252,
   5869.32931777, 5869.51621302] Angstrom>)>
The 1st warning is about this WCS trouble, the 3rd one is about a non-standard unit and maybe a non-ascii character that is included into the CUNIT2 keyword.

Code: Select all

CTYPE2  = 'Intensity' / Axis 2 description                                      
CUNIT2  = 'Intensit? relative' / Axis 2 unit                                 
In a nutshell, removing these 2 keywords would make the Demeta spectra more compliant with the FITS 'standard'.
For sure this is not the most important issue we have to face in the current days.

Jacques
Nicolas Durand
Posts: 9
Joined: Mon Aug 05, 2013 10:42 am

Re: Demetra spectra FITS header

Post by Nicolas Durand »

Hi Jacques

You are right, "but"...
I find a bit weird that the data described in the FITS header contains wavelength information to describe a single axis which is a set of flux data type.
This is the extracted spectrum from the FITS than contains a wavelength X axis data type. In this case, there is a second axis with flux Y axis data type. The flux can be relative, raw...
Following the convention will bring me to use or invent another FITS keys that describe the data type contained in the axis.... ??

I wonder myself what i better (or more wrong ;) ) : keeping the actual convention rule break by describing 2 axes for a 1D FITS HDU or use/invent others FITS key to describe the data contained in the 1D data array ?
Or maybe my spectrum representation in a fits file is incorrect ? Should Demetra use another well known keys to describe 1D array data type ?

Nicolas
Jacques Michelet
Posts: 16
Joined: Mon Apr 01, 2019 8:13 pm

Re: Demetra spectra FITS header

Post by Jacques Michelet »

Bonjour Nicolas,

Yes, it looks rather odd no keyword describes the flux data in the header, whether it is a relative or an absolute flux, and which unit is used for it. The BSS specification has no recommendation for that. Maybe is it time to add a new one (BSS_FLUX, or BSSFUNIT, or BSS_FLUN, or ...) ? Or do the BAA or the AAVSO guys have gone through this issue, and have issued some recommendations ?

Jacques
Nicolas Durand
Posts: 9
Joined: Mon Aug 05, 2013 10:42 am

Re: Demetra spectra FITS header

Post by Nicolas Durand »

Jacques,

-> I will remove the 2 keywords from the spectra generated by Demetra. (CTYPE2/CUNIT2)
I will may add others fits keyword only if I will receive request to add again the removed information. It look like this information is useless.

Thanks to have enlightened me this point.

Nicolas
Jacques Michelet
Posts: 16
Joined: Mon Apr 01, 2019 8:13 pm

Re: Demetra spectra FITS header

Post by Jacques Michelet »

Bonjour Nicolas,

Thanks for your fix.
Looking at some sites publishing spectra, and the FITS recommendations, BUNIT seems to be the recommended keyword in that purpose. In https://fits.gsfc.nasa.gov/users_guide/ ... ode22.html , one can find :
BUNIT (character) represents the physical units of the quantity stored in the array, e.g., Janskys, magnitudes/pixel. The name comes from ``brightness units.'' Section 3.1.1.4 discusses recommendations for choice of units.
For Demetra spectra fluxes, a possible internal logic may be :
Relative intensity fluxes <-> no specific keyword
Calibrated fluxes <-> BUNIT with the unit described in the value field

Jacques
Robin Leadbeater
Posts: 1926
Joined: Mon Sep 26, 2011 4:41 pm
Contact:

Re: Demetra spectra FITS header

Post by Robin Leadbeater »

There are indeed no keywords in the BeSS standard for the flux axis units which is a problem. ISIS includes BUNIT and BTYPE in the header though. The normal assumption is if BUNIT and BSS_NORM are blank then the spectrum is calibrated in relative flux. There is no way of indicating "raw" spectra ie direct from the instrument, the assumption being these would as a minimum be rectified(normalised). For spectra calibrated in absolute flux, BUNIT and BTYPE can be entered if using ISIS. In the BAA database, absolute flux calibrated spectra are indicated at entry using a tick box (actually labelled, incorrectly as just "Flux Calibrated"). This is then carried over into the database entry as a flag but the fits header is not changed and the units are not noted. (The assumption is FLAM). I have no idea how AAVSO deal with this. My suspicion is that they may not even be aware of the issue.

Cheers
Robin
LHIRES III #29 ATIK314 ALPY 600/200 ATIK428 Star Analyser 100/200 C11 EQ6
http://www.threehillsobservatory.co.uk
Post Reply