Skip to content

ENH: adding SSA method for IRSA#3076

Merged
bsipocz merged 9 commits into
astropy:mainfrom
bsipocz:ENH_irsa_ssa
Feb 28, 2025
Merged

ENH: adding SSA method for IRSA#3076
bsipocz merged 9 commits into
astropy:mainfrom
bsipocz:ENH_irsa_ssa

Conversation

@bsipocz

@bsipocz bsipocz commented Aug 1, 2024

Copy link
Copy Markdown
Member

Addig SSA access to spectral holdings. The query_ssa method is a very thin wrapper of pyvo, so while any issues recovered with it is appreciated, we may ultimately need to propagate those upstream rather than adding workaround for the PR.

closes #3061

@keflavich

Copy link
Copy Markdown
Contributor

I'm testing this out now. See #3092 for related work.

First, the format is not the same as sia, which ideally we'd fix:

In [6]: crd = SkyCoord.from_name('Sgr B2')
   ...: sgrb2_q = Irsa.query_ssa(pos=(crd.ra, crd.dec, 0.01,) )

Traceback (most recent call last):
  File ~/mambaforge/envs/py310forge/lib/python3.10/site-packages/pyvo/dal/ssa.py:383 in pos
    ra, dec = pos
ValueError: too many values to unpack (expected 2)

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  Cell In[6], line 2
    sgrb2_q = Irsa.query_ssa(pos=(crd.ra, crd.dec, 0.01,) )
  File ~/repos/astroquery/astroquery/ipac/irsa/core.py:160 in query_ssa
    return self.ssa.search(pos=pos, diameter=diameter, band=band, time=time,
  File ~/mambaforge/envs/py310forge/lib/python3.10/site-packages/pyvo/dal/ssa.py:214 in search
    return self.create_query(
  File ~/mambaforge/envs/py310forge/lib/python3.10/site-packages/pyvo/dal/ssa.py:260 in create_query
    return SSAQuery(
  File ~/mambaforge/envs/py310forge/lib/python3.10/site-packages/pyvo/dal/ssa.py:351 in __init__
    self.pos = pos
  File ~/mambaforge/envs/py310forge/lib/python3.10/site-packages/pyvo/dal/ssa.py:385 in pos
    raise ValueError(
ValueError: Pos must be a sequence with exactly two values, expressing ra and dec in icrs degrees

ssa only wants a 2-tuple, not a 3-tuple

But it looks like right now, this is not yet functional (it is labeled draft, after all)

In [7]: crd = SkyCoord.from_name('Sgr B2')
   ...: sgrb2_q = Irsa.query_ssa(pos=(crd.ra, crd.dec) )
Traceback (most recent call last):
  Cell In[7], line 2
    sgrb2_q = Irsa.query_ssa(pos=(crd.ra, crd.dec) )
  File ~/repos/astroquery/astroquery/ipac/irsa/core.py:160 in query_ssa
    return self.ssa.search(pos=pos, diameter=diameter, band=band, time=time,
  File ~/mambaforge/envs/py310forge/lib/python3.10/site-packages/pyvo/dal/ssa.py:215 in search
    pos=pos, diameter=diameter, band=band, time=time, format=format, **keywords).execute()
  File ~/mambaforge/envs/py310forge/lib/python3.10/site-packages/pyvo/dal/ssa.py:578 in execute
    return SSAResults(self.execute_votable(), url=self.queryurl, session=self._session)
  File ~/mambaforge/envs/py310forge/lib/python3.10/site-packages/pyvo/dal/adhoc.py:111 in __init__
    super().__init__(votable, url=url, session=session)
  File ~/mambaforge/envs/py310forge/lib/python3.10/site-packages/pyvo/dal/query.py:322 in __init__
    raise DALQueryError(self._status[1], self._status[0], url)
DALQueryError: UsageFault: BAD_REQUEST: Unknown parameter: request

In [8]: crd = SkyCoord.from_name('Sgr B2')
   ...: sgrb2_q = Irsa.query_ssa(pos=crd)
Traceback (most recent call last):
  Cell In[8], line 2
    sgrb2_q = Irsa.query_ssa(pos=crd)
  File ~/repos/astroquery/astroquery/ipac/irsa/core.py:160 in query_ssa
    return self.ssa.search(pos=pos, diameter=diameter, band=band, time=time,
  File ~/mambaforge/envs/py310forge/lib/python3.10/site-packages/pyvo/dal/ssa.py:215 in search
    pos=pos, diameter=diameter, band=band, time=time, format=format, **keywords).execute()
  File ~/mambaforge/envs/py310forge/lib/python3.10/site-packages/pyvo/dal/ssa.py:578 in execute
    return SSAResults(self.execute_votable(), url=self.queryurl, session=self._session)
  File ~/mambaforge/envs/py310forge/lib/python3.10/site-packages/pyvo/dal/adhoc.py:111 in __init__
    super().__init__(votable, url=url, session=session)
  File ~/mambaforge/envs/py310forge/lib/python3.10/site-packages/pyvo/dal/query.py:322 in __init__
    raise DALQueryError(self._status[1], self._status[0], url)
DALQueryError: UsageFault: BAD_REQUEST: Unknown parameter: request

@bsipocz

bsipocz commented Sep 7, 2024

Copy link
Copy Markdown
Member Author

Yeap, whatever I have here is just a dump of the first draft that I came up with during some meeting or such by mostly just copying over sia, without cleaning up and making it ssa specific. Realistically this won't get done before the next quarter (and will need some server-side stuff, too, e.g. caching some queries)

@bsipocz bsipocz added this to the v0.4.8 milestone Dec 5, 2024
@bsipocz bsipocz modified the milestones: v0.4.8, v0.4.9 Jan 16, 2025
@bsipocz bsipocz removed this from the v0.4.9 milestone Jan 24, 2025
@bsipocz bsipocz added this to the v0.4.10 milestone Feb 14, 2025
@codecov

codecov Bot commented Feb 14, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 53.33333% with 7 lines in your changes missing coverage. Please review.

Project coverage is 69.07%. Comparing base (29ba772) to head (eecd8e1).
Report is 326 commits behind head on main.

Files with missing lines Patch % Lines
astroquery/ipac/irsa/core.py 50.00% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3076      +/-   ##
==========================================
+ Coverage   68.31%   69.07%   +0.75%     
==========================================
  Files         231      232       +1     
  Lines       19199    19605     +406     
==========================================
+ Hits        13116    13542     +426     
+ Misses       6083     6063      -20     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bsipocz bsipocz marked this pull request as ready for review February 14, 2025 18:57
@bsipocz

bsipocz commented Feb 14, 2025

Copy link
Copy Markdown
Member Author

@keflavich - this is ready for review. There may be corners of uncovered API, and some missing parsing on the pyvo side, I've opened issues for a couple of those, but the basic examples should work here.

I'm also planning to make this more user friendly, e.g. adding the to_table() in the methods, but that will have to be systematic and do in e.g. the alma module, too.

@bsipocz bsipocz requested a review from keflavich February 14, 2025 19:01

@keflavich keflavich left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor suggestions & questions. Fine to merge, but it might be nice to make some small doc improvements.

Comment thread docs/ipac/irsa/irsa.rst Outdated
>>> arp220_spectra = Irsa.query_ssa(pos=coord).to_table()

Without specifying the collection, the query returns results from multiple
collections. For example this target has spectra from Sofia as well as from

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SOFIA is an acronym, right?

Suggested change
collections. For example this target has spectra from Sofia as well as from
collections. For example this target has spectra from SOFIA as well as from

Comment thread astroquery/ipac/irsa/core.py Outdated
pos : `~astropy.coordinates.SkyCoord` class or sequence of two floats
the position of the center of the circular search region.
assuming icrs decimal degrees if unit is not specified.
diameter : `~astropy.units.Quantity` class or scalar float

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why diameter instead of radius? radius is more common across the rest of our API

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inherited from SSA API, but I agree that I need to change this to be radius instead.

Comment thread astroquery/ipac/irsa/core.py Outdated
Comment on lines +152 to +157
format : str
the image format(s) of interest. "all" indicates
all available formats; "graphic" indicates
graphical images (e.g. jpeg, png, gif; not FITS);
"metadata" indicates that no images should be
returned--only an empty table with complete metadata.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is ('all', 'graphic', 'metadata') a complete set of valid options? If so, it would be helpful to indicate that. If not, can we document what is allowed here or in the main docs?

@bsipocz bsipocz Feb 20, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied this from the pyvo docs, looking at the IRSA SSA metadata, these are the actual options:

        <OPTION value="ALL"/>
        <OPTION value="COMPLIANT"/>
        <OPTION value="NATIVE"/>
        <OPTION value="VOTABLE"/>
        <OPTION value="FITS"/>
        <OPTION value="XML"/>
        <OPTION value="GRAPHIC"/>
        <OPTION value="METADATA"/>

However, some of these are known not to be working (e.g. metadata), and now as I test them some of them are not working as expected. (e.g. FITS).

So this may need an upstream fix (either at the server on in pyvo), and here, I may just remove this kwarg for now and hard-wire to return all results in this first iteration.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, now I hardwired 'all', and opened a follow-up to address this properly. xref: #3234

coord = SkyCoord.from_name("Eta Carina")
result = Irsa.query_ssa(pos=coord)
assert len(result) > 260
collections = set(unique(result.to_table(), keys='dataid_collection')['dataid_collection'])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is set(unique( redundant? I'd imagine so

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure 🤦‍♀️

@bsipocz

bsipocz commented Feb 27, 2025

Copy link
Copy Markdown
Member Author

I've addressed all the review issues here and opened follow-up for the format issues. So I'll go ahead with the merge so we can try and sort out if there is anything needed for the next release (in ~2 weeks time).

@bsipocz bsipocz merged commit 71b00bb into astropy:main Feb 28, 2025
@bsipocz bsipocz deleted the ENH_irsa_ssa branch February 28, 2025 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IRSA: adding SSA method

2 participants