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
WCS: exception if MJD-OBS missing when some other headers present #11248
Comments
This allows it to compute MJD-OBS from DATE-OBS, which is needed to work around astropy/astropy#11248. Unfortunately that also means that FITS files with OBSGEO-X/Y/Z headers will spew out warnings due to astropy/astropy#10365, but that's better than crashing.
I don't see any traceback provided above, but this is what I see with
|
Whoops, I pasted the sample code twice instead of pasting the traceback. I get the same exception though. I'll just edit the report to remove the duplicated sample code. |
Are you getting the same error with
where Table 22 could be understood as requiring an ISO-8601 time to be put in |
No, because wcslib's fixers compute MJD-OBS from DATE-OBS. I actually ran into this issue because I was using an observation which has a DATE-OBS but I'd disabled the fixers due to #10365. For now I've just reenabled the fixers. Section 9.2.2 deals with DATEREF/MJDREF, so it doesn't seem relevant here. Just to be sure that we're talking about the same section numbers, I'm referring to https://fits.gsfc.nasa.gov/standard40/fits_standard40aa-le.pdf. I see 9.8 says:
If I add a DATE-AVG then my header is compliant with that, and the crash still occurs. |
Yes, I thought the "Time reference" referred to the time point for converting between the different coordinate systems, but that was a mistake. Primarily I was looking for some rule that would accept MJD, but not ISO-8601 formats, but that is not the case, and indeed, as you pointed out, wcslib is already converting all astropy/astropy/wcs/wcsapi/fitswcs.py Lines 421 to 424 in aef31be
requires a reasonably accurate observation date to compute the observer location relative to a celestial coordinate system, so it seems justified to not silently drop in a generic DATE – that is defined as "Date of HDU creation", so in principle might be delayed by an arbitrary time past the actual observation.However DATE-AVG/MJD-AVG, and with lower priority -BEG/-END, would certainly acceptable replacements, so _get_components_and_classes should perhaps be modified to search for those in order, if self.wcs.mjdobs has no valid value.
|
Beyond that, I see your use case has a DATE-OBS, so enabling its conversion to MJD is a WCSLIB internal issue, right? |
That is one solution I had in mind. An alternative might be to create the observer without an obstime, but I don't know if that's just going to cause an exception down the road when you try to change frames (possibly it makes sense for some values of SPECSYS?)
In fact the spec says "In order to compute the velocities it is necessary to have the date and time of the observation; the keywords DATE-AVG and MJD-AVG are reserved for this purpose." That sounds like they should be considered before DATE-OBS/MJD-OBS. |
Although |
|
Description
If a FITS header has a spectral axis and OBSGEO-* keywords but no MJD-DATE, then
_get_components_and_classes
crashes because it tries to construct a Time from a NaN MJD. I'm not aware of any requirement in the FITS specification to provide this header, but I didn't comb the entire spec.Expected behavior
I'm not familiar with the details of SpectralCoord at all so I don't know what the appropriate fix is, but I would expect the resulting WCS to be basically usable.
Actual behavior
When running the test code below, received an exception (see first comment - I forgot to paste it when filing the bug).
Steps to Reproduce
System Details
Linux-5.4.0-60-generic-x86_64-with-glibc2.29
Python 3.8.5 (default, Jul 28 2020, 12:59:40)
[GCC 9.3.0]
Numpy 1.19.1
astropy 4.3.dev450+gaa71c2f45
Scipy 1.5.2
Matplotlib 3.3.0
The text was updated successfully, but these errors were encountered: