-
-
Notifications
You must be signed in to change notification settings - Fork 414
Add vec_table
as an API Parameter for JPL Horizons
#3273
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
base: main
Are you sure you want to change the base?
Conversation
…upport more vector table options
Could you provide more specific examples? e.g., show a request that returns a table (in html, json, votable, or whatever form) that has conflicting column names? I don't think there is an intrinsic limitation here; if there are conflicting column names, they'll have |
cc @mkelley |
Try running with the following code: from astroquery.jplhorizons import Horizons
obj = Horizons(
id="Ceres",
location="500@399",
)
vectors = obj.vectors(
aberrations="apparent",
vec_table="2xarp",
)
print(vectors) Or look at a corresponding API request here and scroll to the table. The following error occurs with the code:
And so on with many readers until it ends with:
This only happens (I assume) because, for example, |
Yep, that's what's happening, but it is a pretty easy fix. e.g., after:
just add something like: duplicates = {hl for hl in headerline if headerline.count(hl) > 1}
dup_inds = {dup: [ii for ii, hl in enumerate(headerline) if hl == dup] for dup in duplicates}
for hl, inds in dup_inds.items():
for ii, ind in enumerate(inds):
headerline[ind] = f'{hl}_{ii}' ...which admittedly took some mental hoop jumping to come up with, but I think it'll work |
I just committed some code based on this (a bit more readable) that should work. I also had to change downstream code so it would work with the duplicate column names, namely the ones reading in unit data & renaming columns based on |
This looks like a good addition, thanks! Let me know if you have any questions about fixing the tests. It sounds like it would be useful to design a new test that specifically exercises this column renaming. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3273 +/- ##
==========================================
+ Coverage 69.09% 69.87% +0.78%
==========================================
Files 232 232
Lines 19677 19757 +80
==========================================
+ Hits 13595 13805 +210
+ Misses 6082 5952 -130 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Added a new test (
Also, should the docs be changed for installing in "editable" mode with the following pip install instead?
The Apart from those separate issues/things to look into, the test now works! |
Could you elaborate on this in a separate issue? I never had any problems with the editable installs even without this extra option. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @megargayu! There are a couple of things remaining before this can be merged (but none of them are blockers and I'm OK with fixing the last two myself before merging the PR):
- consider adding something about this in the narrative docs, maybe an example, too.
- fix the docs build (it complains about duplicated
horizons user manual
references) - fix the style warnings, they are mostly whitespace.
# read in vectors header line | ||
# reading like this helps fix issues with commas after JDTDB | ||
if self.query_type == 'vectors': | ||
headerline_raw = str(src[idx - 2]).replace("JDTDB,", "JDTDB") | ||
headerline = [" JDTDB", *str(headerline_raw).split("JDTDB")[1].split(',')] | ||
headerline[-1] = '_dump' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the record, I haven't checked the correctness for all these changes, but trust the tests and the other review that these and the rest below are correct.
I actually figured out what the issue was - if you install in editable mode, and you try to
However, this is fixed if you put |
The JPL Horizons module is missing some API parameters that are allowed by NASA, including the
vec_table
parameter. This is especially important for uncertainties of certain objects (like small asteroids), and this pull request aims to add this functionality into astroquery. See here for the reference.However, because of the way that JPL Horizons names columns, there can be naming conflicts between columns with the correct input (for example,
vec_table="2xarp"
would cause many conflicts, likeR_s
,A_s
, etc; see changes inastroquery/jplhorizons/__init__.py
for more information). Whenever this happens, the program fails with an error. (Supporting this is not strictly required, I assume, as all of these values are usually not needed in the same request).Is this an intrinsic limitation of astropy's implementation of tables, or is there a way to fix this error?