Skip to content

Add example of how to get non-public (proprietary) data#3294

Merged
bsipocz merged 4 commits into
astropy:mainfrom
keflavich:alma_proprietary_doc
Apr 22, 2025
Merged

Add example of how to get non-public (proprietary) data#3294
bsipocz merged 4 commits into
astropy:mainfrom
keflavich:alma_proprietary_doc

Conversation

@keflavich

Copy link
Copy Markdown
Contributor

cc @andamian

@low-sky noted that there was no documentation explaining how to get proprietary data.

This example shows technically how to do it, but it won't actually do anything useful.

In [20]: len(Alma.query_region('W51', radius=25*u.arcmin, public_data=True))
Out[20]: 376

In [26]: len(Alma.query_region('W51', radius=25*u.arcmin, public_data=False))
Out[26]: 376

by contrast, in other regions, it does work

In [24]: len(Alma.query_region(SkyCoord(0.253*u.deg, 0.016*u.deg, frame='galactic'), radius=1*u.arcmin, public=True))
Out[24]: 244

In [25]: len(Alma.query_region(SkyCoord(0.253*u.deg, 0.016*u.deg, frame='galactic'), radius=1*u.arcmin, public=False))
Out[25]: 78

so @andamian any idea what's going on here? Why is it region-dependent?

@codecov

codecov Bot commented Apr 17, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 69.47%. Comparing base (4ed16e4) to head (4b0c754).
Report is 169 commits behind head on main.

Files with missing lines Patch % Lines
astroquery/alma/core.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3294      +/-   ##
==========================================
+ Coverage   69.36%   69.47%   +0.11%     
==========================================
  Files         232      232              
  Lines       19692    19708      +16     
==========================================
+ Hits        13659    13692      +33     
+ Misses       6033     6016      -17     

☔ 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.

Comment thread docs/alma/alma.rst Outdated
>>> # Now query including proprietary data
>>> proprietary_data = alma.query(payload=dict(project_code='2017.1.01355.L', public_data=False))
>>> # Or restrict to only proprietary data
>>> only_proprietary = alma.query_region('W51', radius=25*u.arcmin, public_data=False)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

noting that the query_region function takes public not public_data as the keyword. The issue is correct but the doc change isn't.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks for catching that, it was indeed the problem. It comes from Alma.help() showing public_data, not public.

@keflavich

Copy link
Copy Markdown
Contributor Author

Right, it was user error:

In [27]: len(Alma.query_region('W51', radius=25*u.arcmin, public=False))
Out[27]: 66

In [28]: len(Alma.query_region('W51', radius=25*u.arcmin, public=True))
Out[28]: 376

In [29]: len(Alma.query_region('W51', radius=25*u.arcmin, public=None, public_data=False))
Out[29]: 66

In [30]: len(Alma.query_region('W51', radius=25*u.arcmin, public=None, public_data=True))
Out[30]: 376

but Alma.help() isn't very helpful, since it implies public_data will be respected

@bsipocz bsipocz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @keflavich

Comment thread astroquery/alma/core.py
if science is not None:
payload['science_observation'] = science
if public is not None:
if 'public_data' in kwargs:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is why I really dislike **kwargs, it swallows stuff and creates inconsistencies like this almost duplicate of kwargs with the same functionality.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I hear you, but I greatly prefer this over query(payload={'public_data' : True}). I find it really clunky & annoying to specify keywords as dicts.

The redundancy here is almost certainly my fault: I told @andamian that he should preserve as much of the old API as possible, so this is (probably, I'm going from memory here) an API backward-compatibility-driven choice.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Redundancy was an agreed tradeoff to make the transition from the Web form to astroquery easier. Do you think it's time to remove public_data from the help to avoid further confusion?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

no, I think the redundancy is important here, we just needed the documentation to be clear

Comment thread docs/alma/alma.rst Outdated
>>> # First login to access proprietary data
>>> alma.login("username") # Will prompt for password
>>> # Now query including proprietary data
>>> proprietary_data = alma.query(payload=dict(project_code='2017.1.01355.L', public=False))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Isn't it public=None to include both public and proprietary?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, this is definitely a mistake

Comment thread docs/alma/alma.rst
>>> proprietary_data = alma.query(payload=dict(project_code='2017.1.01355.L', public=False))
>>> # Or restrict to only proprietary data
>>> # include both public and proprietary data using public=None
>>> proprietary_data = alma.query(payload=dict(project_code='2017.1.01355.L', public=None))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I forgot what happens for public=None and unauthenticated user. Returns only public data or fails?

@bsipocz bsipocz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @keflavich and @andamian for the review!

@bsipocz bsipocz merged commit 7785a12 into astropy:main Apr 22, 2025
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.

4 participants