Coder Social home page Coder Social logo

Comments (2)

jurezakrajsek avatar jurezakrajsek commented on July 23, 2024

I think I found an issue with the parsing of the MPC ephemeris results.
The

This is the result for comet 113P produced today and where my error happens today.

Date       UT      R.A. (J2000) Decl.    Delta     r     El.    Ph.   m1     Sky Motion        Object    Sun   Moon
            h m s                                                            "/hr     "/hr    Azi. Alt.  Alt.  Phase Dist. Alt.
2024 06 06 195900 12 34 22.7 -10 03 31   3.997   4.527  115.5  11.7  23.1   -0.13    +2.96    204  +31   -10   0.00   112  -04
2024 06 06 202900 12 34 22.7 -10 03 29   3.998   4.527  115.4  11.7  23.1   -0.099   +2.97    212  +29   -13   0.00   112  -07
2024 06 06 205900 12 34 22.7 -10 03 28   3.998   4.527  115.4  11.7  23.1   -0.060   +2.97    220  +26   -16   0.00   111  -10
2024 06 06 212900 12 34 22.7 -10 03 26   3.998   4.527  115.4  11.7  23.1   -0.016   +2.97    227  +22   -18   0.00   111  -12
2024 06 06 215900 12 34 22.7 -10 03 25   3.999   4.527  115.4  11.7  23.1   +0.033   +2.98    234  +18   -20   0.00   111  -14
2024 06 06 222900 12 34 22.7 -10 03 23   3.999   4.528  115.4  11.7  23.1   +0.087   +2.98    240  +13   -21   0.00   111  -15
2024 06 06 225900 12 34 22.7 -10 03 22   3.999   4.528  115.3  11.7  23.1   +0.14    +2.98    246  +09   -22   0.00   110  -16

As can be seen the SkyMotion columns sometimes have the precision of 3 decimals arcsec/h.
So I looked at the _parse_result(self, result, **kwargs) function in the MPCClass and tried to print out the table of parsed results just after

tab = ascii.read(text_table, format='fixed_width_no_header',
                 names=names, col_starts=col_starts,
                 col_ends=col_ends, data_start=data_start,
                 fill_values=(('N/A', np.nan),), fast_reader=False)
for col, unit in zip(names, units):
    tab[col].unit = unit
print(tab)                             

And here is what I get:

113P/Spitaler
       Date           RA        Dec    Delta   r   Elongation Phase  V   dRA cos(Dec)    dDec    Azimuth Altitude Sun altitude Moon phase Moon distance Moon altitude
                                         AU    AU     deg      deg  mag   arcsec / h  arcsec / h   deg     deg        deg                      deg           deg
----------------- ---------- --------- ----- ----- ---------- ----- ---- ------------ ---------- ------- -------- ------------ ---------- ------------- -------------
2024 06 06 200000 12 34 22.7 -10 03 31 3.997 4.527      115.5  11.7 23.1        -0.13      +2.96     205       31          -10        0.0           112            -4
2024 06 06 203000 12 34 22.7 -10 03 29 3.998 4.527      115.4  11.7 23.1        -0.09  8   +2.97     213       29          -13        0.0           112            -7
2024 06 06 210000 12 34 22.7 -10 03 28 3.998 4.527      115.4  11.7 23.1        -0.05  9   +2.97     220       25          -16        0.0           111           -10
2024 06 06 213000 12 34 22.7 -10 03 26 3.998 4.527      115.4  11.7 23.1        -0.01  4   +2.97     227       22          -18        0.0           111           -12
2024 06 06 220000 12 34 22.7 -10 03 25 3.999 4.527      115.4  11.7 23.1         0.03  5   +2.98     234       18          -20        0.0           111           -14
2024 06 06 223000 12 34 22.7 -10 03 23 3.999 4.528      115.4  11.7 23.1         0.08  9   +2.98     240       13          -21        0.0           111           -15

As can be seen the dRA cos(Dec) and dDec are parsed inccorectlly where the precision fo dRA cos(Dec) is 3 decimals. The last digit is already parsed to the dDec column making it a string instead of a float column and the conversion to arcsec/min later fails.

The issue comes from setting the col_start and col_ends for Sky Motion in the _parse_result()
Current code:

elif 's=s' in result.request.body:  # sky Motion
    names += ('dRA cos(Dec)', 'dDec')
    units += ('arcsec/h', 'arcsec/h')
col_starts += (73, 81)
col_ends += (80, 89)

if 'Moon' in columns:
    # table includes Alt, Az, Sun and Moon geometry
    names += ('Azimuth', 'Altitude', 'Sun altitude', 'Moon phase',
              'Moon distance', 'Moon altitude')
    col_starts += tuple((col_ends[-1] + offset for offset in
                         (2, 9, 14, 20, 27, 33)))
    col_ends += tuple((col_ends[-1] + offset for offset in
                       (8, 13, 19, 26, 32, 37)))
    units += ('deg', 'deg', 'deg', None, 'deg', 'deg')

To fix this we need to parse one character more so the end of dRA cos(Dec) column is shifted one character to the right. But also the dDec column can have 3 decimals precision so the end of the column must also be shifted to the right now for 2 characters to column 91.

But changing the col_ends has the effect on all remaining columns, so we need to adjust the next part and all the starts and ands must be moved now one character to the left.

Corrected code

elif 's=s' in result.request.body:  # sky Motion
    names += ('dRA cos(Dec)', 'dDec')
    units += ('arcsec/h', 'arcsec/h')
col_starts += (73, 82)
col_ends += (81, 91)

if 'Moon' in columns:
    # table includes Alt, Az, Sun and Moon geometry
    names += ('Azimuth', 'Altitude', 'Sun altitude', 'Moon phase',
              'Moon distance', 'Moon altitude')
    col_starts += tuple((col_ends[-1] + offset for offset in
                         (1, 8, 13, 19, 26, 32)))
    col_ends += tuple((col_ends[-1] + offset for offset in
                       (7, 12, 18, 25, 31, 36)))
    units += ('deg', 'deg', 'deg', None, 'deg', 'deg')

This way I get the results parsed as expected and conversion to arcsec/min works:

113P/Spitaler
       Date           RA        Dec    Delta   r   Elongation Phase  V   dRA cos(Dec)    dDec    Azimuth Altitude Sun altitude Moon phase Moon distance Moon altitude
                                         AU    AU     deg      deg  mag   arcsec / h  arcsec / h   deg     deg        deg                      deg           deg
----------------- ---------- --------- ----- ----- ---------- ----- ---- ------------ ---------- ------- -------- ------------ ---------- ------------- -------------
2024 06 06 200000 12 34 22.7 -10 03 31 3.997 4.527      115.5  11.7 23.1        -0.13       2.96     205       31          -10        0.0           112            -4
2024 06 06 203000 12 34 22.7 -10 03 29 3.998 4.527      115.4  11.7 23.1       -0.098       2.97     213       29          -13        0.0           112            -7
2024 06 06 210000 12 34 22.7 -10 03 28 3.998 4.527      115.4  11.7 23.1       -0.059       2.97     220       25          -16        0.0           111           -10
2024 06 06 213000 12 34 22.7 -10 03 26 3.998 4.527      115.4  11.7 23.1       -0.014       2.97     227       22          -18        0.0           111           -12
2024 06 06 220000 12 34 22.7 -10 03 25 3.999 4.527      115.4  11.7 23.1        0.035       2.98     234       18          -20        0.0           111           -14
2024 06 06 223000 12 34 22.7 -10 03 23 3.999 4.528      115.4  11.7 23.1        0.089       2.98     240       13          -21        0.0           111           -15

from astroquery.

bsipocz avatar bsipocz commented on July 23, 2024

cc @mkelley

from astroquery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.