Skip to content
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

Bug: heasarc queries fail with astroquery > 0.4.7 #61

Open
nkphysics opened this issue Feb 10, 2025 · 1 comment
Open

Bug: heasarc queries fail with astroquery > 0.4.7 #61

nkphysics opened this issue Feb 10, 2025 · 1 comment
Assignees
Labels
bug Something isn't working dependencies Pull requests that update a dependency file

Comments

@nkphysics
Copy link
Owner

Recently tests with versions 0.4.8 and 0.4.9 of astroquery fail, with the output logs shown below.

This is likely due to the major rewrite of astoquery.heasarc module: astropy/astroquery#2997

In short it would appear that the response table from the heasarc now has the column names in lowercase vs uppercase based on logs shown below.

self = Index(['name', 'ra', 'dec', 'time', 'obsid', 'exposure', 'processing_status',
       'processing_date', 'public_date', 'obs_type', '__row'],
      dtype='object')
key = 'OBSID'

    def get_loc(self, key):
        """
        Get integer location, slice or boolean mask for requested label.
    
        Parameters
        ----------
        key : label
    
        Returns
        -------
        int if unique index, slice if monotonic index, else mask
    
        Examples
        --------
        >>> unique_index = pd.Index(list('abc'))
        >>> unique_index.get_loc('b')
        1
    
        >>> monotonic_index = pd.Index(list('abbc'))
        >>> monotonic_index.get_loc('b')
        slice(1, 3, None)
    
        >>> non_monotonic_index = pd.Index(list('abcb'))
        >>> non_monotonic_index.get_loc('b')
        array([False,  True, False,  True])
        """
        casted_key = self._maybe_cast_indexer(key)
        try:
            return self._engine.get_loc(casted_key)
        except KeyError as err:
>           raise KeyError(key) from err
E           KeyError: 'OBSID'


FAILED tests/test_autonicer.py::test_call_nicer - KeyError: 'OBSID'
FAILED tests/test_autonicer.py::test_make_cycle - TypeError: 'int' object is not subscriptable
FAILED tests/test_autonicer.py::test_single_sel - AttributeError: 'int' object has no attribute 'loc'
FAILED tests/test_autonicer.py::test_short_entry - assert 0 == 1
FAILED tests/test_autonicer.py::test_wrong_obsid - AttributeError: 'int' object has no attribute 'loc'
FAILED tests/test_autonicer.py::test_cycle_sel - TypeError: 'int' object is not subscriptable
FAILED tests/test_autonicer.py::test_rm_single_sel - assert 0 == 58
FAILED tests/test_autonicer.py::test_back - IndexError: list index out of range
FAILED tests/test_autonicer.py::test_duplicate - TypeError: 'int' object is not subscriptable
FAILED tests/test_autonicer.py::test_pullreduce - AttributeError: 'int' object has no attribute 'loc'
FAILED tests/test_autonicer.py::test_nometa - FileNotFoundError: [Errno 2] No such file or directory: '/home/nick/Research/Pulsar_Timing/autoHeasoft/autoNICER/data/3013010102/xti/even...
FAILED tests/test_autonicer.py::test_no_primary_obsid - FileNotFoundError: [Errno 2] No such file or directory: '/home/nick/Research/Pulsar_Timing/autoHeasoft/autoNICER/data/3013010102/xti/even...
FAILED tests/test_autonicer.py::test_checkcal_reprocess - AssertionError: assert '----------  Passing Reprocess of 3013010102  ----------' in 'DATASETS NOT FOUND\nDATASETS NOT FOUND\nDATASETS NOT...
FAILED tests/test_autonicer.py::test_inlist_singledir - FileNotFoundError: [Errno 2] No such file or directory: 'test.csv'
ERROR tests/test_autonicer.py::test_get_clevts - FileNotFoundError: [Errno 2] No such file or directory: '/home/nick/Research/Pulsar_Timing/autoHeasoft/autoNICER/data/3013010102/'
ERROR tests/test_autonicer.py::test_getmeta - FileNotFoundError: [Errno 2] No such file or directory: '/home/nick/Research/Pulsar_Timing/autoHeasoft/autoNICER/data/3013010102/'
ERROR tests/test_autonicer.py::test_decompress - FileNotFoundError: [Errno 2] No such file or directory: '/home/nick/Research/Pulsar_Timing/autoHeasoft/autoNICER/data/3013010102/'
ERROR tests/test_autonicer.py::test_checkcal - FileNotFoundError: [Errno 2] No such file or directory: '/home/nick/Research/Pulsar_Timing/autoHeasoft/autoNICER/data/3013010102/'
ERROR tests/test_autonicer.py::test_no_caldb - FileNotFoundError: [Errno 2] No such file or directory: '/home/nick/Research/Pulsar_Timing/autoHeasoft/autoNICER/data/3013010102/'
ERROR tests/test_autonicer.py::test_reprocess - FileNotFoundError: [Errno 2] No such file or directory: '/home/nick/Research/Pulsar_Timing/autoHeasoft/autoNICER/data/3013010102/'
@nkphysics nkphysics added bug Something isn't working dependencies Pull requests that update a dependency file labels Feb 10, 2025
@nkphysics nkphysics self-assigned this Feb 10, 2025
@nkphysics
Copy link
Owner Author

It would appear that the issue is larger than I previously thought. The following code sample just from some of my testing with astroquery >= 0.4.8 shows that the query_object() in the heasarc package is deprecated breaking most of this.

>>> from astroquery.heasarc import Heasarc
>>> heasarc = Heasarc()
>>> Heasarc.clear_cache()
>>> query = heasarc.query_object("crab", mission="nicermastr")
WARNING: AstropyDeprecationWarning: The query_object function is deprecated and may be removed in a future version.
        Use query_region instead. [warnings]

I either need to decide if I want to try to un-deprecate (if that's a word) this on astroquery's end or figure out if its worth making a 3rd party querying package for the heasarc. For now the best temporary fix will be to require astroquery <= 0.4.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies Pull requests that update a dependency file
Projects
None yet
Development

No branches or pull requests

1 participant