LM-SAL / aiapy

Python library for AIA data analysis
https://aiapy.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
7 stars 3 forks source link

ErfaWarning and time-related AiapyUserWarning when running aiapy.calibration.degradation() #89

Closed nabobalis closed 9 months ago

nabobalis commented 3 years ago

In GitLab by @ebuchlin on May 10, 2021, 01:07

Steps to reproduce

I run aiapy 0.5.0 with python 3.8.6 under Ubuntu 20.10 with astropy==4.2.1, sunpy==2.1.4, and pyerfa==1.7.3.

When running the following code:

import astropy.units as u
from astropy.time import Time
from aiapy.calibrate import degradation

t = Time(58817.5, format="mjd", scale="utc")   # 2019-11-30T12:00:00
d = degradation(94 * u.AA, t)
print(d)

the output is

/usr/local/lib/python3.8/dist-packages/erfa/core.py:154: ErfaWarning: ERFA function "taiutc" yielded 1 of "dubious year (Note 4)"
  warnings.warn('ERFA function "{}" yielded {}'.format(func_name, wmsg),
WARNING: SunpyDeprecationWarning: specify desired keywords as arguments to JSOCResponse.show() [aiapy.calibrate.util]
WARNING: SunpyDeprecationWarning: use JSOCClient.search() instead [aiapy.calibrate.util]
/usr/local/lib/python3.8/dist-packages/erfa/core.py:154: ErfaWarning: ERFA function "utctai" yielded 1 of "dubious year (Note 3)"
  warnings.warn('ERFA function "{}" yielded {}'.format(func_name, wmsg),
/usr/local/lib/python3.8/dist-packages/erfa/core.py:154: ErfaWarning: ERFA function "dtf2d" yielded 100 of "dubious year (Note 6)"
  warnings.warn('ERFA function "{}" yielded {}'.format(func_name, wmsg),
WARNING: AiapyUserWarning: Multiple valid epochs for 58817.5. Using the most recent one [aiapy.calibrate.util]
[0.90317732]

Behavior vs expected behavior

This issue is about the ErfaWarning's and the AiapyUserWarning, which is also related to time. They also appear when using scale="tai" instead of scale="utc". They also appear with an input time in datetime64 format:

import numpy as np
t = Time(np.datetime64("2019-11-30T12:00:00"), format="datetime64", scale="utc")

It is well known (see astropy issue 9603 and related issues) than ErfaWarnings are too cryptic for the user. But the point here is not about this, it is about why these warnings appear when calling degradation(). 2019 is not a year for which UTC is not well defined, and, with my limited knowledge of astropy.time, it seems to me that all time conversions required to call degradation() should not produce warnings.