MAINT: heasarc deprecation warning and changed API behaviour
Hi, in the tests running here: https://github.com/NuSTAR/nustar-clock-utils/actions/runs/13671731675/job/38223241105?pr=121
I'm getting this deprecation warning:
WARNING astroquery:logger.py:235 AstropyDeprecationWarning: The query_object function is deprecated and may be removed in a future version.
Use query_region instead.
and I was looking for alternatives. However, I can't find a place in the code where the query_object function is deprecated (I see a deprecation of single keywords, not the entire function), and from the PRs I see that there actually is ongoing development on this function (e.g. #3217 ). What am I missing? Thanks
UPDATE:
I found that this is only deprecated in the heasarc submodule, and I understand now why one of my tests based on that method fails, the functionality has changed.
I was doing
all_nustar_obs = heasarc.query_object(
'*', 'numaster', resultmax=100000,
fields='OBSID,TIME,END_TIME,NAME,OBSERVATION_MODE,OBS_TYPE')
to query the whole numaster catalog. The code above could not work, because the internals of query_object have changed (now, it really asks for a single object).
What is the best way to download the whole numaster with those columns now?
I would think you can do an "all sky" spatial query. But downloading the whole catalogue is a special case that may need to be spelt out in the docs, or have its own method (many archives don't support such bulk download or have special workarounds or require coordination, so we need to ask heasarc here about their preference)
Cc @zoghbi-a
The new heasarc modules moved to using TAP queries, which are more powerful for the end user and the preferred way on the archive side.
@matteobachetti, to get the same result, you can do:
all_nustar_obs = heasarc.query_tap('select OBSID,TIME,END_TIME,NAME,OBSERVATION_MODE,OBS_TYPE from numaster').to_table()
which will give you the full numaster catalog as a table.
@zoghbi-a, @bsipocz, thanks! After opening the Issue I managed to come out with a TAP query similar to that, the new interface is indeed very convenient! I think a pythonic procedure would be more intuitive for users (downloading a catalogue is something that happens), but certainly not high-priority.
If getting the full catalogue is a frequent enough use case then the above TAP query could indeed be wrapped up into a method. numaster may be small enough that it's not an issue, but there are certainly catalogues where we don't want to serve the full dataset via TAP :)
As to back to the original issue: we may want to override the deprecation message with something more informative, e.g. pointing out that the module has been fully rewritten so the behaviour is expected to be slightly ydifferent.
There is an alternative to getting the full catalog that has always been there, though I personally don't like it. The catalogs can be downloaded as ascii files in tdat format from here: https://heasarc.gsfc.nasa.gov/FTP/heasarc/dbase/dump/.
Those can be parsed and read as as table. @d-giles has a nearly done PR to add a tdat reader toastropy.io.ascii.
If getting the full catalogue is a frequent enough use case then the above TAP query could indeed be wrapped up into a method.
numastermay be small enough that it's not an issue, but there are certainly catalogues where we don't want to serve the full dataset via TAP :)
I can definitely see that :) In my case, I didn't actually want the full catalog, but just a few columns for all rows. The software I'm using it for is the NuSTAR clock file creation code, which needs a list of all obsids to annotate a full-mission diagnostic plot. I guess it's very specific and not so usual. Most large-scale actions on catalogs are probably cross-matches, that can be done through specific TAP calls rather than in the user's laptop