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

Update MPC query to parse 3 digit precision motion columns #3026

Merged
merged 10 commits into from
Jun 27, 2024

Conversation

jurezakrajsek
Copy link
Contributor

#3019 update of the MPC parse_results to correctly parse 3 digit precision motion columns
#3022 update of the MPC parse_results to raise EmptyResponseError if no table lines are parsed

@bsipocz
Copy link
Member

bsipocz commented Jun 11, 2024

cc @mkelley

@mkelley
Copy link
Contributor

mkelley commented Jun 14, 2024

Thank you for identifying and addressing these issues, @jurezakrajsek . Let me know if you want help debugging the failures. I'm investigating the first two and see that the columns are not yet fully aligned. See the last two columns from the test_get_ephemeris_Moon_phase_and_Uncertainty() test:

          Date                  RA               Dec          Delta     r    Elongation  Phase     V    Proper motion Direction Azimuth Altitude Sun altitude Moon phase Moon distance Moon altitude Uncertainty 3sig Unc. P.A.
                               deg               deg            AU      AU      deg       deg     mag     arcsec / h     deg      deg     deg        deg                      deg           deg           arcsec         deg   
          Time               float64           float64       float64 float64  float64   float64 float64    float64     float64   int64   int64      int64      float64       int64         int64           str3          str6  
----------------------- ----------------- ------------------ ------- ------- ---------- ------- ------- ------------- --------- ------- -------- ------------ ---------- ------------- ------------- ---------------- ---------
2018-07-30 17:46:14.000 72.47041666666665  23.53527777777778   2.091   1.693       53.3    28.7    22.6         67.51      90.1     256       61           62       0.93            95           -33              2 3    09.2 /
2018-07-31 17:46:14.000 72.96499999999999 23.534166666666668   2.088   1.699       53.8    28.8    22.6         66.97      90.4     257       61           62       0.87            84           -22              2 3    10.6 /
2018-08-01 17:46:14.000 73.45541666666665  23.53111111111111   2.085   1.705       54.3    28.9    22.6         66.43      90.7     257       60           61       0.79            72           -11              2 3    12.2 /
2018-08-02 17:46:14.000 73.94208333333333  23.52611111111111   2.082   1.712       54.8    29.0    22.6         65.89      91.0     257       60           61       0.71            60             1              2 3    13.8 /
2018-08-03 17:46:14.000 74.42458333333333 23.519166666666667   2.078   1.718       55.3    29.1    22.6         65.34      91.2     258       59           61       0.61            47            12              2 3    15.5 /
2018-08-04 17:46:14.000 74.90291666666666              23.51   2.075   1.724       55.9    29.2    22.6          64.8      91.5     258       59           61        0.5            35            24              2 3    17.2 /
2018-08-05 17:46:14.000 75.37749999999998  23.49888888888889   2.071    1.73       56.4    29.2    22.6         64.25      91.8     259       58           61        0.4            22            36              2 3    19.0 /
2018-08-06 17:46:14.000 75.84791666666665 23.485833333333336   2.067   1.736       56.9    29.3    22.7         63.69      92.1     259       58           61       0.29             9            49              2 3    20.9 /

It is the same problem in the test_get_ephemeris_Uncertainty() test.

@jurezakrajsek
Copy link
Contributor Author

@mkelley
I see, looks like other columns in the ephemeris output need to be shifted to. I did not test this with the uncertenty columns as I do not use them. I'll try to look at it and debug this.

@jurezakrajsek
Copy link
Contributor Author

Found a better example for the test:

2024 AA

Number of variant orbits available: 11

Perturbed ephemeris below is based on 1-day-arc unperturbed elements from MPO 793554. Last observed on 2024 Jan. 2.

[Further observations?](https://www.minorplanetcenter.net/iau/info/FurtherObs.html) Useful for orbit improvement.

     K24A00A       [H=27.41]
Date       UT      R.A. (J2000) Decl.    Delta     r     El.    Ph.   V      Sky Motion        Object    Sun   Moon                Uncertainty info
            h m s                                                            "/min    "/min   Azi. Alt.  Alt.  Phase Dist. Alt.    3-sig/" P.A.
2024 06 15 000000 23 28 41.4 -05 17 10   1.451   1.819   93.3  33.9  30.9   +0.19    +0.006   323  -55   +30   0.57   168  +45       169 063.5 / [Map](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460476.50000&Ext=VAR2) / [Offsets](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460476.50000&Ext=VAR2&Form=Y&OC=500)
2024 06 16 000000 23 28 56.6 -05 17 08   1.447   1.829   94.2  33.6  30.9   +0.17    -0.003   325  -56   +30   0.67   156  +35       172 063.5 / [Map](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460477.50000&Ext=VAR2) / [Offsets](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460477.50000&Ext=VAR2&Form=Y&OC=500)
2024 06 17 000000 23 29 09.7 -05 17 19   1.444   1.838   95.1  33.4  30.9   +0.15    -0.012   326  -56   +30   0.75   144  +25       175 063.6 / [Map](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460478.50000&Ext=VAR2) / [Offsets](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460478.50000&Ext=VAR2&Form=Y&OC=500)
2024 06 18 000000 23 29 20.7 -05 17 44   1.440   1.848   96.1  33.1  30.9   +0.13    -0.021   328  -57   +30   0.83   132  +14       178 063.6 / [Map](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460479.50000&Ext=VAR2) / [Offsets](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460479.50000&Ext=VAR2&Form=Y&OC=500)
2024 06 19 000000 23 29 29.8 -05 18 22   1.437   1.858   97.0  32.9  30.9   +0.10    -0.031   329  -57   +30   0.90   120  +03       181 063.6 / [Map](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460480.50000&Ext=VAR2) / [Offsets](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460480.50000&Ext=VAR2&Form=Y&OC=500)
2024 06 20 000000 23 29 36.8 -05 19 14   1.433   1.867   97.9  32.6  30.9   +0.083   -0.040   331  -58   +30   0.95   107  -08       184 063.7 / [Map](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460481.50000&Ext=VAR2) / [Offsets](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460481.50000&Ext=VAR2&Form=Y&OC=500)
2024 06 21 000000 23 29 41.7 -05 20 19   1.429   1.877   98.8  32.3  30.9   +0.062   -0.049   333  -58   +30   0.99   094  -20       187 063.7 / [Map](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460482.50000&Ext=VAR2) / [Offsets](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460482.50000&Ext=VAR2&Form=Y&OC=500)
2024 06 22 000000 23 29 44.6 -05 21 38   1.425   1.886   99.8  32.1  30.9   +0.040   -0.059   334  -58   +30   1.00   081  -31       190 063.7 / [Map](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460483.50000&Ext=VAR2) / [Offsets](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460483.50000&Ext=VAR2&Form=Y&OC=500)
2024 06 23 000000 23 29 45.3 -05 23 10   1.422   1.896  100.8  31.8  30.9   +0.018   -0.069   336  -59   +30   0.99   067  -43       193 063.8 / [Map](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460484.50000&Ext=VAR2) / [Offsets](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460484.50000&Ext=VAR2&Form=Y&OC=500)
2024 06 24 000000 23 29 43.9 -05 24 57   1.418   1.905  101.7  31.5  30.9   -0.003   -0.078   338  -59   +30   0.95   053  -54       196 063.8 / [Map](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460485.50000&Ext=VAR2) / [Offsets](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460485.50000&Ext=VAR2&Form=Y&OC=500)
2024 06 25 000000 23 29 40.4 -05 26 57   1.414   1.914  102.7  31.2  30.9   -0.026   -0.088   340  -59   +30   0.89   039  -63       199 063.8 / [Map](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460486.50000&Ext=VAR2) / [Offsets](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460486.50000&Ext=VAR2&Form=Y&OC=500)
2024 06 26 000000 23 29 34.8 -05 29 12   1.410   1.924  103.7  30.9  30.9   -0.048   -0.098   342  -60   +30   0.81   025  -68       202 063.9 / [Map](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460487.50000&Ext=VAR2) / [Offsets](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460487.50000&Ext=VAR2&Form=Y&OC=500)
2024 06 27 000000 23 29 26.9 -05 31 40   1.406   1.933  104.7  30.6  30.9   -0.070   -0.11    344  -60   +30   0.72   011  -65       205 063.9 / [Map](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460488.50000&Ext=VAR2) / [Offsets](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460488.50000&Ext=VAR2&Form=Y&OC=500)
2024 06 28 000000 23 29 16.9 -05 34 23   1.403   1.942  105.7  30.3  30.9   -0.093   -0.12    346  -60   +30   0.61   004  -58       208 064.0 / [Map](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460489.50000&Ext=VAR2) / [Offsets](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460489.50000&Ext=VAR2&Form=Y&OC=500)
2024 06 29 000000 23 29 04.6 -05 37 20   1.399   1.952  106.7  29.9  30.9   -0.12    -0.13    348  -61   +30   0.49   018  -47       211 064.0 / [Map](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460490.50000&Ext=VAR2) / [Offsets](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460490.50000&Ext=VAR2&Form=Y&OC=500)
2024 06 30 000000 23 28 50.2 -05 40 31   1.395   1.961  107.8  29.6  30.9   -0.14    -0.14    350  -61   +30   0.38   032  -36       214 064.0 / [Map](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460491.50000&Ext=VAR2) / [Offsets](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460491.50000&Ext=VAR2&Form=Y&OC=500)
2024 07 01 000000 23 28 33.4 -05 43 57   1.391   1.970  108.8  29.2  30.9   -0.16    -0.15    352  -61   +30   0.27   046  -24       217 064.1 / [Map](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460492.50000&Ext=VAR2) / [Offsets](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460492.50000&Ext=VAR2&Form=Y&OC=500)
2024 07 02 000000 23 28 14.5 -05 47 37   1.388   1.979  109.8  28.9  30.9   -0.19    -0.16    354  -61   +30   0.18   060  -12       220 064.1 / [Map](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460493.50000&Ext=VAR2) / [Offsets](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460493.50000&Ext=VAR2&Form=Y&OC=500)
2024 07 03 000000 23 27 53.2 -05 51 32   1.384   1.988  110.9  28.5  30.9   -0.21    -0.17    356  -61   +30   0.10   074  +00       223 064.2 / [Map](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460494.50000&Ext=VAR2) / [Offsets](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460494.50000&Ext=VAR2&Form=Y&OC=500)
2024 07 04 000000 23 27 29.7 -05 55 41   1.380   1.997  112.0  28.2  30.9   -0.23    -0.18    358  -61   +30   0.04   088  +11       226 064.2 / [Map](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460495.50000&Ext=VAR2) / [Offsets](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460495.50000&Ext=VAR2&Form=Y&OC=500)
2024 07 05 000000 23 27 03.9 -06 00 05   1.377   2.006  113.0  27.8  30.9   -0.26    -0.19    001  -61   +30   0.01   101  +22       229 064.2 / [Map](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460496.50000&Ext=VAR2) / [Offsets](https://cgi.minorplanetcenter.net/cgi-bin/uncertaintymap.cgi?Obj=K24A00A&JD=2460496.50000&Ext=VAR2&Form=Y&OC=500)

…recision

Modified test and data set for 3 digit sky motion precision
@jurezakrajsek
Copy link
Contributor Author

jurezakrajsek commented Jun 15, 2024

@mkelley
I have now modified the start of the uncertainty columns to complensate for 3 digit precision of the sky motion. Runing the mpc_test.py now goes without an error.

I have added a new data set of the object 2024 AA which covers this case of 3 digit sky motion and also has the uncertainty.

I also added a test for an empty ephemeris table that I encountered last week for comet 340P, but I can no longer repeate this issue (looks like something strange was on the MPC side), so I manually created the test data file by removing the ephemeris lines from the result table.

Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

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

Please add a sentence in the CHANGES changelog file about these fixes. Also, please add remote-data tests that access the server.

As for the content of the fix, I'll also wait for @mkelley to sign off on it.

Copy link
Member

Choose a reason for hiding this comment

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

I would prefer to see remote-data tests added, too, not just mocked ones with a canned HTML response.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For empty ephemeris result I was not able to repeate the error for comet 340P.
There was a time period that MPC services had some issues, so Im not sure if it was related to that but it happened, so it does make sence to capture this
Therefor it is difficult to create a remote test for this case as I cannot find a target and date where such a response would be returned.

Anyway the remote tests for ephemeris are just testing if we get the response back.

@pytest.mark.parametrize('target', ['(3202)', 'C/2003 A2'])
def test_get_ephemeris_by_target(self, target):
    # test that query succeeded
    response = mpc.MPC.get_ephemeris(target)
    assert len(response) > 0

Should we include the tests for Moon_phase and Moon_phase_and_Uncertainty like in these in test_mpc.py also?

def test_get_ephemeris_Moon_phase(patch_post):
    result = mpc.core.MPC.get_ephemeris('2P', location='G37')
    assert result['Moon phase'][0] >= 0


def test_get_ephemeris_Uncertainty(patch_post):
    # this test requires an object with uncertainties != N/A
    result = mpc.core.MPC.get_ephemeris('2024 AA')
    assert result['Uncertainty 3sig'].quantity[0] > 0 * u.arcsec

Copy link
Member

Choose a reason for hiding this comment

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

yes, that would be great, at the minimum I suppose you can just add these objects to the previous target list above and just test if results are returned and parsed out.

But it also good to add the other two extra tests that do some check for the content.

(In general we try to minimize the testing load on the remote services, but these are quite fast queries without downloading hundred of Mb of data, so we should indeed test against the server more).

Copy link
Contributor Author

@jurezakrajsek jurezakrajsek Jun 18, 2024

Choose a reason for hiding this comment

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

Tests for ephemeris parsing are now added to the test_mpc_remote.py
Running
pytest -P mpc -m remote_data --remote-data=any --cov astroquery/mpc --cov-config=setup.cfg
runs with 21 passed tests.

astroquery\mpc\tests\test_mpc_remote.py .....................                                                                                                                                                                                                                                                                                                                    [100%]

---------- coverage: platform win32, python 3.10.10-final-0 ----------
Name                              Stmts   Miss  Cover
-----------------------------------------------------
astroquery\mpc\__init__.py           11      0   100%
astroquery\mpc\core.py              382    111    71%
astroquery\mpc\setup_package.py       4      2    50%
-----------------------------------------------------
TOTAL                               397    113    72%


=== 21 passed, 60 deselected in 32.70s ===

Also running a local test
pytest -P mpc --cov astroquery/mpc --cov-config=setup.cfg
runs with 60 passed tests.

astroquery\mpc\tests\test_mpc.py ...........................................................                                                                                                                                                                                                                                                                                     [ 72%]
astroquery\mpc\tests\test_mpc_remote.py sssssssssssssssssssss                                                                                                                                                                                                                                                                                                                    [ 98%]
docs\mpc\mpc.rst .                                                                                                                                                                                                                                                                                                                                                               [100%]

---------- coverage: platform win32, python 3.10.10-final-0 ----------
Name                              Stmts   Miss  Cover
-----------------------------------------------------
astroquery\mpc\__init__.py           11      0   100%
astroquery\mpc\core.py              382     44    88%
astroquery\mpc\setup_package.py       4      2    50%
-----------------------------------------------------
TOTAL                               397     46    88%


=== 60 passed, 21 skipped in 4.32s ===

astroquery/mpc/core.py Outdated Show resolved Hide resolved
astroquery/mpc/core.py Show resolved Hide resolved
@bsipocz
Copy link
Member

bsipocz commented Jun 17, 2024

Unrelated, but as I was thinking about the empty responses and when it would make sense to get an Error vs a Warning, I checked the known impactors and was surprised to see emphemeris returned for them. Isn't that something to be fixed at server side?

>>> from astroquery.mpc import MPC
>>> MPC.get_ephemeris('2024 BX1')
<Table length=21>
          Date                  RA                Dec          Delta     r    ...  Phase   V   Proper motion Direction
                               deg                deg            AU      AU   ...   deg   mag    arcsec / h     deg   
          Time               float64            float64       float64 float64 ... float64 str1    float64     float64 
----------------------- ------------------ ------------------ ------- ------- ... ------- ---- ------------- ---------
2024-06-17 22:29:42.000  27.33083333333333 23.690555555555555   1.273   1.063 ...    50.6             111.87      51.6
2024-06-18 22:29:42.000 27.969583333333333  24.15222222222222   1.275   1.068 ...    50.5             111.35      51.8
2024-06-19 22:29:42.000  28.60916666666666 24.609444444444446   1.277   1.074 ...    50.3             110.85      52.0
2024-06-20 22:29:42.000 29.250416666666663  25.06222222222222   1.278   1.079 ...    50.2             110.35      52.2
2024-06-21 22:29:42.000 29.892916666666665 25.511111111111113    1.28   1.085 ...    50.1             109.85      52.4
2024-06-22 22:29:42.000  30.53666666666666 25.955555555555556   1.281    1.09 ...    50.0             109.36      52.6
2024-06-23 22:29:42.000 31.181666666666665  26.39611111111111   1.283   1.095 ...    49.8             108.88      52.8
2024-06-24 22:29:42.000  31.82833333333333            26.8325   1.284   1.101 ...    49.7              108.4      53.1
2024-06-25 22:29:42.000  32.47624999999999 27.264444444444443   1.285   1.106 ...    49.6             107.92      53.3
2024-06-26 22:29:42.000  33.12583333333333 27.692777777777778   1.286   1.111 ...    49.5             107.45      53.5
2024-06-27 22:29:42.000  33.77708333333333 28.116666666666667   1.287   1.116 ...    49.4             106.98      53.7
2024-06-28 22:29:42.000 34.429583333333326 28.536944444444448   1.287   1.121 ...    49.3             106.51      53.9
2024-06-29 22:29:42.000  35.08333333333333 28.952777777777776   1.288   1.126 ...    49.3             106.04      54.1
2024-06-30 22:29:42.000  35.73916666666666 29.365000000000002   1.288   1.131 ...    49.2             105.57      54.4
2024-07-01 22:29:42.000 36.396249999999995 29.773055555555555   1.289   1.136 ...    49.1             105.11      54.6
2024-07-02 22:29:42.000             37.055 30.177222222222223   1.289   1.141 ...    49.0             104.65      54.8
2024-07-03 22:29:42.000 37.714999999999996 30.577222222222222   1.289   1.146 ...    48.9             104.18      55.0
2024-07-04 22:29:42.000 38.377083333333324 30.973333333333333   1.289   1.151 ...    48.8             103.72      55.2
2024-07-05 22:29:42.000  39.04041666666666 31.365833333333335   1.289   1.156 ...    48.8             103.26      55.5
2024-07-06 22:29:42.000  39.70499999999999 31.754166666666666   1.289    1.16 ...    48.7             102.81      55.7
2024-07-07 22:29:42.000  40.37166666666666  32.13861111111111   1.289   1.165 ...    48.6             102.35      55.9

@bsipocz bsipocz added this to the v0.4.8 milestone Jun 17, 2024
… table is retrieved

- Added remote test for ephemeris with moon phase and uncertainty
- Changes listed in CHANGES.rst
@jurezakrajsek
Copy link
Contributor Author

jurezakrajsek commented Jun 18, 2024

@bsipocz
There are many strange issues that the MPC should have resolved on the server side.

Example, if you check periodic comets:
P/2014 U2 - gives no ephemeris response
384P - gives a normal response
In this case, this is expected as P/2014 U2 was assigned the number 384P, but it would be nice if P/2014 U2 would automatically be linked to 384P and response of 384P would be returned also for P/2014 U2?

On the other hand,
P/2011 WG113 still gives an ephemeris response, although it received the number 365P.

Difference between P/2014 U2 and P/2011 WG113
For P/2011 WG113, there are still orbital elements provided in the Soft00Cmt.txt.

And to make it even more confusing, the orbital elements are not the same to its official 365P

    PK11WB3G  2023 10  9.3927  1.321242  0.581442   67.7726   86.3043    9.8451  20240617   9.0  4.0  P/2011 WG113                                             MPEC 2018-D88
0365P         2023 10  9.4002  1.321170  0.581437   67.4263   86.6565    9.8497  20240617  17.0  4.0  365P/PANSTARRS                                           MPC111775	

There are many of these first-apparition designations that have an official number; some return an ephemeris response, others don't.
It seems that there is no conversion/alias table at the MPC that would check the first-apparition designation and return the response of the current official designation.

@mkelley
Copy link
Contributor

mkelley commented Jun 18, 2024

The MPC is working to replace all of their previous services with modern and documented API end points, including this ephemeris service, which should improve its behavior and the relationships between temporary and permanent designations.

astroquery/mpc/core.py Outdated Show resolved Hide resolved
astroquery/mpc/core.py Outdated Show resolved Hide resolved
# raise EmptyResponseError if no ephemeris lines are found in the query response
try:
i = text_table.index('\n', text_table.index('JD_TT')) + 1
except ValueError as e:
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a test that covers this exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mkelley
It is difficult to create a remote test for this case as I can no longer repeate this issue by querying the MPC for the same object and date that i described in the issu (looks like something was not working on the MPC side at that time). I'm not able to find a different target or date where such a response would be returned. But if it happens I can add a remote test for this case also.

So I have manually created the test data file by removing the ephemeris lines from the result table and included a test for this in local data test_mpc.py

def test_get_ephemeris_by_name_empty(patch_post):
    with pytest.raises(NoResultsWarning):
        mpc.core.MPC.get_ephemeris('340P', location='G37')

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the manual test is OK. I can't think of a successful remote test case that should return empty lines. Brigitta's impactor example is an interesting idea, but the service clearly doesn't behave that way.

Copy link
Member

Choose a reason for hiding this comment

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

I can't think of a successful remote test case that should return empty line

well, that case I would revert my previous opinion about the warning and say that it should loudly error as an indication of something is broken.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mkelley, @bsipocz
So we change back to EmptyResponseError?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, EmptyResponseError

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mkelley
I have corrected it back to EmptyResponseerror

Copy link
Contributor

@mkelley mkelley left a comment

Choose a reason for hiding this comment

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

I've commented on the few remaining issues from the failing tests. Otherwise, I think it is ready.

# raise EmptyResponseError if no ephemeris lines are found in the query response
try:
i = text_table.index('\n', text_table.index('h m s')) + 1
except ValueError as e:
Copy link
Contributor

Choose a reason for hiding this comment

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

e is not used, so probably shouldn't be defined.

# raise EmptyResponseError if no ephemeris lines are found in the query response
try:
i = text_table.index('\n', text_table.index('JD_TT')) + 1
except ValueError as e:
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks. Finally, e is not used, so probably shouldn't be defined.

@@ -64,7 +64,7 @@
from astropy.coordinates import EarthLocation, Angle
from astropy.time import Time

from ...exceptions import InvalidQueryError
from ...exceptions import EmptyResponseError, InvalidQueryError, NoResultsWarning
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the unused NoResultsWarning

CHANGES.rst Outdated
@@ -12,6 +12,8 @@ mpc
^^^

- Parse star catalog information when querying observations database [#2957]
- Parse ephemeris with sky motion with three digit precision [#3019]
- Raise NoResultWarining when empty ephemeris reponse is returned [#3019]
Copy link
Contributor

Choose a reason for hiding this comment

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

NoResultWarning -> EmptyResponseError

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, instead of referencing the issues, reference the PR #3026.

@jurezakrajsek
Copy link
Contributor Author

@mkelley
All mentioned corrections are done.

Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

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

Thank you!

@bsipocz bsipocz merged commit 5d42c1f into astropy:main Jun 27, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants