Stanford-NavLab / gnss_lib_py

Modular Python tool for parsing, analyzing, and visualizing Global Navigation Satellite Systems (GNSS) data and state estimates
MIT License
116 stars 28 forks source link

support multiple signal_type/observation_code in add_sv_states_rinex #161

Open mikehb opened 2 months ago

mikehb commented 2 months ago

Describe the proposed feature My observation data has multiple signal and observation code, but add_sv_states_rinex prints 'Some ephemeris data is missing'. I have to add the sv states one by one

obs_signal=obs_data.where('gnss_id','gps').where('signal_type','l2').where('observation_code','2X') sv_states=glp.add_sv_states_rinex(obs_signal)

Motivate the proposed feature This features make it easier to use in case that multiple GNSS signals need to be considered.

betaBison commented 2 months ago

Hi @mikehb, I wonder if gnss_lib_py wasn't correctly installed based on your other issue.

It's also definitely possible we have a bug in the code or don't have observation files like yours in our testing scheme. If you're able to attach your full/cropped observation file to this issue, I'd be happy to take a look at what happens when I try to run the file myself.

mikehb commented 2 months ago

Looks like the QZSS is not supported by function add_sv_states_rinex. This the observation file which could reproduce RuntimeError: Some ephemeris data is missing.

>>> a=glp.RinexObs("/home/mikehuang/data/simple.23o")
>>> glp.add_sv_states_rinex(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mikehuang/.local/lib/python3.11/site-packages/gnss_lib_py/utils/sv_models.py", line 168, in add_sv_states_rinex
    raise RuntimeError('Some ephemeris data is missing')
RuntimeError: Some ephemeris data is missing
>>>
     3.02           OBSERVATION DATA    M: Mixed            RINEX VERSION / TYPE
CONVBIN 2.4.2                           20240428 043130 UTC PGM / RUN BY / DATE 
log: /mnt/hgfs/ChromeCoreDownloads/BJCN/OBS_BJCN_2023111900_COMMENT             
format: RTCM 3, station ID: 0                               COMMENT             
                                                            MARKER NAME         
                                                            MARKER NUMBER       
                                                            MARKER TYPE         
                                                            OBSERVER / AGENCY   
                                                            REC # / TYPE / VERS 
                                                            ANT # / TYPE        
        0.0000        0.0000        0.0000                  APPROX POSITION XYZ 
        0.0000        0.0000        0.0000                  ANTENNA: DELTA H/E/N
G    8 C1C L1C C1W L1W C2W L2W C2X L2X                      SYS / # / OBS TYPES 
R    8 C1C L1C C1P L1P C2C L2C C2P L2P                      SYS / # / OBS TYPES 
E    2 C1X L1X                                              SYS / # / OBS TYPES 
J    4 C1C L1C C2X L2X                                      SYS / # / OBS TYPES 
S    2 C1C L1C                                              SYS / # / OBS TYPES 
C    4 C1C L1C C2C L2C                                      SYS / # / OBS TYPES 
  2023    11    18    16     0   18.0000000     GPS         TIME OF FIRST OBS   
  2023    11    18    16    15   17.0000000     GPS         TIME OF LAST OBS    
G                                                           SYS / PHASE SHIFT   
R                                                           SYS / PHASE SHIFT   
E                                                           SYS / PHASE SHIFT   
J                                                           SYS / PHASE SHIFT   
S                                                           SYS / PHASE SHIFT   
C                                                           SYS / PHASE SHIFT   
  0                                                         GLONASS SLOT / FRQ #
 C1C    0.000 C1P    0.000 C2C    0.000 C2P    0.000        GLONASS COD/PHS/BIS 
                                                            END OF HEADER       
> 2023 11 18 16  0 18.0000000  0 42                     
G 1  22826214.473   119952757.861                                    22826212.633    93469576.064    22826212.168    93469730.081  
G 2  24872316.025   130705043.597                                                                                                  
G 3  21450978.406   112725667.707                                    21450976.137    87838183.340    21450976.155    87838190.348  
G 6  22310811.829   117244127.770                                    22310810.381    91359051.827    22310810.757    91359062.832  
G14  20586826.309   108184519.011                                    20586821.841    84299618.968    20586821.680    84299622.976  
G17  20666297.573   108602201.852                                    20666292.087    84625061.538    20666292.123    84625072.546  
G19  21216925.780   111495719.278                                    21216918.686    86879775.203                                  
G22  20637785.456   108452297.902                                    20637779.649    84508285.314                                  
G24  24760654.002   130118137.477                                                                    24760651.715   101390757.683  
G30  25197101.671   132411648.119                                    25197100.188   103177909.192    25197099.938   103177927.203  
R 2  23202681.997                                                                                    23202680.943                  
R 3  22499580.777                                                                                    22499577.882                  
R 9  20115125.558                                                                                    20115121.627                  
R10  22791047.271                                                                                                                  
R16  20795190.606                                                                                    20795189.266                  
R18  20809812.917                                                                                    20809809.111                  
R19  19911510.115                                                                                    19911508.524                  
R20  23210716.303                                                                                    23210717.375                  
E 2                                
E13                                
E15                                
E21                                
E27                                
E30                                
J 2  37475424.856   196934794.097    37475421.907   153455712.667  
J 3  39204664.709   206022025.597    39204661.135   160536672.730  
J 4  37819672.119   198743765.004    37819668.242   154865253.802  
C 1                                                                
C 2                                                                
C 3                                                                
C 4                                                                
C 5                                                                
C 7                                                                
C 8                                                                
C 9                                                                
C10                                                                
C13                                                                
C14                                                                
C27                                                                
C28                                                                
C30                                                                
C33                                                                
> 2023 11 18 16  0 19.0000000  0 42                     
G 1  22826849.628   119956095.597                                    22826847.787    93472176.894    22826847.323    93472330.903  
G 2  24872878.596   130708000.253                                                                                                  
G 3  21451000.671   112725784.686                                    21450998.402    87838274.497    21450998.419    87838281.498  
G 6  22310314.266   117241513.159                                    22310312.836    91357014.470    22310313.212    91357025.473  
G14  20587159.941   108186272.344                                    20587155.492    84300985.206    20587155.331    84300989.212  
G17  20666214.214   108601763.889                                    20666208.746    84624720.270    20666208.782    84624731.271  
G19  21216554.319   111493767.247                                    21216547.225    86878254.138                                  
G22  20637808.043   108452416.533                                    20637802.235    84508377.752                                  
G24  24760665.420   130118197.301                                                                    24760663.079   101390804.322  
G30  25197690.313   132414741.521                                    25197688.830   103180319.657    25197688.544   103180337.692  
R 2  23202814.693                                                                                    23202813.639                  
R 3  22499139.091                                                                                    22499136.196                  
R 9  20115000.797                                                                                    20114996.884                  
R10  22790396.892                                                                                                                  
R16  20795842.897                                                                                    20795841.539                  
R18  20810228.747                                                                                    20810224.941                  
R19  19911498.375                                                                                    19911496.784                  
R20  23210197.601                                                                                    23210198.691                  
E 2                                
E13                                
E15                                
E21                                
E27                                
E30                                
J 2  37475355.024   196934427.132    37475352.075   153455426.720  
J 3  39204713.473   206022281.836    39204709.899   160536872.401  
J 4  37819651.534   198743656.790    37819647.656   154865169.477  
C 1                                                                
C 2                                                                
C 3                                                                
C 4                                                                
C 5                                                                
C 7                                                                
C 8                                                                
C 9                                                                
C10                                                                
C13                                                                
C14                                                                
C27                                                                
C28                                                                
C30                                                                
C33                                                                
> 2023 11 18 16  0 20.0000000  0 42                     
G 1  22827484.728   119959432.895                                    22827482.906    93474777.332    22827482.423    93474931.379  
G 2  24873440.952   130710956.334                                                                                                  
G 3  21451022.989   112725901.820                                    21451020.720    87838365.738    21451020.702    87838372.770  
G 6  22309816.721   117238898.313                                    22309815.273    91354976.895    22309815.631    91354987.930  
G14  20587493.627   108188025.688                                    20587489.178    84302351.412    20587488.981    84302355.447  
G17  20666130.837   108601325.582                                    20666125.369    84624378.698    20666125.369    84624389.740  
G19  21216182.822   111491814.859                                    21216175.745    86876732.764                                  
G22  20637830.629   108452535.155                                    20637824.840    84508470.148                                  
G24  24760676.821   130118257.234                                                                    24760674.498   101390851.000  
G30  25198278.847   132417834.286                                    25198277.364   103182729.602    25198277.060   103182747.647  
R 2  23202947.442                                                                                    23202946.388                  
R 3  22498697.422                                                                                    22498694.509                  
R 9  20114876.107                                                                                    20114872.194                  
R10  22789746.460                                                                                                                  
R16  20796495.206                                                                                    20796493.848                  
R18  20810644.506                                                                                    20810640.699                  
R19  19911486.599                                                                                    19911485.009                  
R20  23209678.792                                                                                    23209679.864                  
E 2                                
E13                                
E15                                
E21                                
E27                                
E30                                
J 2  37475285.102   196934059.704    37475282.172   153455140.397  
J 3  39204762.095   206022537.462    39204758.557   160537071.581  
J 4  37819630.860   198743548.034    37819626.964   154865084.727  
C 1                                                                
C 2                                                                
C 3                                                                
C 4                                                                
C 5                                                                
C 7                                                                
C 8                                                                
C 9                                                                
C10                                                                
C13                                                                
C14                                                                
C27                                                                
C28                                                                
C30                                                                
C33                                                                
> 2023 11 18 16  0 21.0000000  0 43                     
G 1  22828119.829   119962770.636                                    22828117.989    93477378.238    22828117.560    93477532.226  
G 2  24874003.504   130713912.700                                                                                                  
G 3  21451045.433   112726019.990                                    21451043.163    87838457.860    21451043.199    87838464.848  
G 6  22309319.212   117236284.122                                    22309317.764    91352939.913    22309318.157    91352950.903  
G14  20587827.403   108189779.934                                    20587822.953    84303718.407    20587822.810    84303722.397  
G17  20666047.496   108600887.830                                    20666042.028    84624037.643    20666042.064    84624048.632  
G19  21215811.360   111489863.005                                    21215804.248    86875211.892                                  
G22  20637853.323   108452654.649                                    20637847.515    84508563.319                                  
G24  24760688.400   130118318.027                                                                    24760686.059   101390898.378  
G30  25198867.381   132420927.235                                    25198865.898   103185139.727    25198865.648   103185157.722  
R 2  23203080.405                                                                                    23203079.351                  
R 3  22498255.914                                                                                    22498253.019                  
R 9  20114751.667                                                                                    20114747.736                  
R10  22789096.188                                                                                                                  
R16  20797147.675                                                                                    20797146.317                  
R18  20811060.371                                                                                    20811056.565                  
R19  19911474.948                                                                                    19911473.358                  
R20  23209160.126                                                                                    23209161.198                  
E 2                                
E13                                
E15                                
E21                                
E27                                
E30                                
J 2  37475215.288   196933692.666    37475212.304   153454854.405  
J 3  39204810.806   206022793.354    39204807.250   160537270.983  
J 4  37819610.221   198743439.662    37819606.343   154865000.277  
C 1                                                                
C 2                                                                
C 3                                                                
C 4                                                                
C 5                                                                
C 7                                                                
C 8                                                                
C 9                                                                
C10                                                                
C13                                                                
C14                                                                
C27                                                                
C28                                                                
C30                                                                
C32                                                                
C33                                                                
> 2023 11 18 16  0 22.0000000  0 43                     
G 1  22828754.984   119966108.234                                    22828753.143    93479978.931    22828752.679    93480132.951  
G 2  24874565.896   130716868.758                                                                                                  
G 3  21451068.019   112726138.586                                    21451065.768    87838550.247    21451065.768    87838557.265  
G 6  22308821.756   117233669.951                                    22308820.308    91350902.881    22308820.684    91350913.900  
G14  20588161.303   108191534.455                                    20588156.854    84305085.541    20588156.675    84305089.558  
G17  20665964.209   108600450.001                                    20665958.723    84623696.455    20665958.741    84623707.474  
G19  21215439.935   111487911.057                                    21215432.841    86873690.868                                  
G22  20637876.142   108452774.404                                    20637870.334    84508656.603                                  
G24  24760700.015   130118379.140                                                                    24760697.692   101390946.001  
G30  25199455.897   132424019.815                                    25199454.414   103187549.513    25199454.182   103187567.502  
R 2  23203213.476                                                                                    23203212.422                  
R 3  22497814.460                                                                                    22497811.565                  
R 9  20114627.316                                                                                    20114623.385                  
R10  22788445.988                                                                                                                  
R16  20797800.180                                                                                    20797798.822                  
R18  20811476.183                                                                                    20811472.377                  
R19  19911463.333                                                                                    19911461.725                  
R20  23208641.442                                                                                    23208642.532                  
E 2                                
E13                                
E15                                
E21                                
E27                                
E30                                
J 2  37475145.420   196933325.426    37475142.436   153454568.241  
J 3  39204859.409   206023048.889    39204855.871   160537470.103  
J 4  37819589.546   198743331.014    37819585.651   154864915.625  
C 1                                                                
C 2                                                                
C 3                                                                
C 4                                                                
C 5                                                                
C 7                                                                
C 8                                                                
C 9                                                                
C10                                                                
C13                                                                
C14                                                                
C27                                                                
C28                                                                
C30                                                                
C32                                                                
C33                                                                
> 2023 11 18 16  0 23.0000000  0 43                     
G 1  22829390.138   119969446.075                                    22829388.298    93482579.858    22829387.851    93482733.871  
G 2  24875128.377   130719824.901                                                                                                  
G 3  21451090.731   112726258.036                                    21451088.479    87838643.346    21451088.479    87838650.345  
G 6  22308324.389   117231056.261                                    22308322.942    91348866.237    22308323.317    91348877.249  
G14  20588495.311   108193289.684                                    20588490.844    84306453.258    20588490.683    84306457.267  
G17  20665880.939   108600012.519                                    20665875.471    84623355.567    20665875.507    84623366.574  
G19  21215068.545   111485959.440                                    21215061.451    86872170.135                                  
G22  20637899.050   108452894.831                                    20637893.242    84508750.451                                  
G24  24760711.808   130118440.984                                                                    24760709.467   101390994.177  
G30  25200044.414   132427112.363                                    25200042.930   103189959.270    25200042.662   103189977.282  
R 2  23203346.725                                                                                    23203345.671                  
R 3  22497373.149                                                                                    22497370.236                  
R 9  20114503.162                                                                                    20114499.231                  
R10  22787795.895                                                                                                                  
R16  20798452.829                                                                                    20798451.471                  
R18  20811892.067                                                                                    20811888.243                  
R19  19911451.790                                                                                    19911450.200                  
R20  23208122.793                                                                                    23208123.865                  
E 2                                
E13                                
E15                                
E21                                
E27                                
E30                                
J 2  37475075.623   196932958.385    37475072.586   153454282.242  
J 3  39204908.067   206023304.497    39204904.511   160537669.278  
J 4  37819568.890   198743222.542    37819565.012   154864831.102  
C 1                                                                
C 2                                                                
C 3                                                                
C 4                                                                
C 5                                                                
C 7                                                                
C 8                                                                
C 9                                                                
C10                                                                
C13                                                                
C14                                                                
C27                                                                
C28                                                                
C30                                                                
C32                                                                
C33                                                                
> 2023 11 18 16  0 24.0000000  0 43                     
G 1  22830025.328   119972784.013                                    22830023.488    93485180.855    22830023.041    93485334.854  
G 2  24875690.805   130722780.952                                                                                                  
G 3  21451113.585   112726378.152                                    21451111.334    87838736.947    21451111.334    87838743.948  
G 6  22307827.077   117228442.850                                    22307825.629    91346829.813    22307826.004    91346840.818  
G14  20588829.408   108195045.438                                    20588824.959    84307821.380    20588824.798    84307825.382  
G17  20665797.723   108599575.216                                    20665792.255    84623014.811    20665792.273    84623025.821  
G19  21214697.191   111484007.988                                    21214690.097    86870649.525                                  
G22  20637922.065   108453015.762                                    20637916.258    84508844.683                                  
G24  24760723.655   130118503.382                                                                    24760721.350   101391042.797  
G30  25200632.840   132430204.723                                    25200631.357   103192368.920    25200631.125   103192386.913  
R 2  23203480.117                                                                                    23203479.063                  
R 3  22496931.963                                                                                    22496929.050                  
R 9  20114379.169                                                                                    20114375.238                  
R10  22787145.856                                                                                                                  
R16  20799105.566                                                                                    20799104.208                  
R18  20812307.969                                                                                    20812304.163                  
R19  19911440.318                                                                                    19911438.728                  
R20  23207604.216                                                                                    23207605.306                  
E 2                                
E13                                
E15                                
E21                                
E27                                
E30                                
J 2  37475005.791   196932591.382    37475002.736   153453996.266  
J 3  39204956.671   206023560.006    39204953.132   160537868.371  
J 4  37819548.233   198743114.070    37819544.374   154864746.583  
C 1                                                                
C 2                                                                
C 3                                                                
C 4                                                                
C 5                                                                
C 7                                                                
C 8                                                                
C 9                                                                
C10                                                                
C13                                                                
C14                                                                
C27                                                                
C28                                                                
C30                                                                
C32                                                                
C33                                                                
> 2023 11 18 16  0 25.0000000  0 43                     
G 1  22830660.536   119976122.133                                    22830658.696    93487781.995    22830658.267    93487935.991  
G 2  24876253.089   130725737.122                                                                                                  
G 3  21451136.601   112726499.036                                    21451134.331    87838831.145    21451134.349    87838838.142  
G 6  22307329.835   117225829.818                                    22307328.388    91344793.691    22307328.763    91344804.687  
G14  20589163.630   108196801.814                                    20589159.181    84309189.992    20589159.038    84309193.984  
G17  20665714.561   108599138.179                                    20665709.075    84622674.272    20665709.128    84622685.268  
G19  21214325.891   111482056.776                                    21214318.779    86869129.109                                  
G22  20637945.188   108453137.281                                    20637939.380    84508939.387                                  
G24  24760735.717   130118566.393                                                                    24760733.340   101391091.892  
G30  25201221.303   132433297.024                                    25201219.820   103194778.498    25201219.588   103194796.482  
R 2  23203613.670                                                                                    23203612.616                  
R 3  22496490.866                                                                                    22496487.953                  
R 9  20114255.355                                                                                    20114251.442                  
R10  22786495.942                                                                                                                  
R16  20799758.411                                                                                    20799757.053                  
R18  20812723.906                                                                                    20812720.100                  
R19  19911428.936                                                                                    19911427.327                  
R20  23207085.639                                                                                    23207086.712                  
E 2                                
E13                                
E15                                
E21                                
E27                                
E30                                
J 2  37474935.977   196932224.506    37474932.921   153453710.391  
J 3  39205005.292   206023815.499    39205001.754   160538067.459  
J 4  37819527.612   198743005.674    37819523.753   154864662.119  
C 1                                                                
C 2                                                                
C 3                                                                
C 4                                                                
C 5                                                                
C 7                                                                
C 8                                                                
C 9                                                                
C10                                                                
C13                                                                
C14                                                                
C27                                                                
C28                                                                
C30                                                                
C32                                                                
C33                                                                
> 2023 11 18 16  0 26.0000000  0 43                     
G 1  22831295.780   119979460.268                                    22831293.940    93490383.132    22831293.475    93490537.145  
G 2  24876815.267   130728693.018                                                                                                  
G 3  21451159.723   112726620.531                                    21451157.472    87838925.796    21451157.454    87838932.820  
G 6  22306832.630   117223217.002                                    22306831.200    91342757.719    22306831.558    91342768.729  
G14  20589497.960   108198558.656                                    20589493.510    84310558.942    20589493.350    84310562.953  
G17  20665631.434   108598701.255                                    20665625.948    84622333.795    20665625.966    84622344.808  
G19  21213954.608   111480105.671                                    21213947.514    86867608.756                                  
G22  20637968.399   108453259.251                                    20637962.592    84509034.410                                  
G24  24760747.814   130118629.924                                                                    24760745.438   101391141.383  
G30  25201809.730   132436389.129                                    25201808.247   103197187.907    25201807.997   103197205.898  
R 2  23203747.366                                                                                    23203746.312                  
R 3  22496049.840                                                                                    22496046.946                  
R 9  20114131.701                                                                                    20114127.770                  
R10  22785845.992                                                                                                                  
R16  20800411.345                                                                                    20800410.005                  
R18  20813139.861                                                                                    20813136.055                  
R19  19911417.589                                                                                    19911415.998                  
R20  23206567.134                                                                                    23206568.224                  
E 2                                
E13                                
E15                                
E21                                
E27                                
E30                                
J 2  37474866.199   196931857.609    37474863.107   153453424.497  
J 3  39205053.878   206024070.828    39205050.340   160538266.417  
J 4  37819506.956   198742897.217    37819503.114   154864577.604  
C 1                                                                
C 2                                                                
C 3                                                                
C 4                                                                
C 5                                                                
C 7                                                                
C 8                                                                
C 9                                                                
C10                                                                
C13                                                                
C14                                                                
C27                                                                
C28                                                                
C30                                                                
C32                                                                
C33                                                                
> 2023 11 18 16  0 27.0000000  0 44                     
G 1  22831931.024   119982798.614                                    22831929.183    93492984.454    22831928.754    93493138.442  
G 2  24877377.658   130731649.014                                                                                                  
G 3  21451183.006   112726742.818                                    21451180.737    87839021.078    21451180.737    87839028.104  
G 6  22306335.514   117220604.595                                    22306334.066    91340722.084    22306334.441    91340733.092  
G14  20589832.396   108200316.147                                    20589827.947    84311928.427    20589827.786    84311932.422  
G17  20665548.343   108598264.632                                    20665542.857    84621993.579    20665542.893    84622004.587  
G19  21213583.379   111478154.852                                    21213576.285    86866088.640                                  
G22  20637991.718   108453381.840                                    20637985.911    84509129.944                                  
G24  24760760.037   130118694.071                                                                    24760757.642   101391191.374  
G30  25202398.103   132439481.128                                    25202396.620   103199597.269    25202396.406   103199615.237  
R 2  23203881.223                                                                                    23203880.169                  
R 3  22495608.976                                                                                    22495606.063                  
R 4  24006242.150                                                                                    24006238.237                  
R 9  20114008.226                                                                                    20114004.295                  
R10  22785196.256                                                                                                                  
R16  20801064.422                                                                                    20801063.064                  
R18  20813555.870                                                                                    20813552.046                  
R19  19911406.331                                                                                    19911404.741                  
R20  23206048.664                                                                                    23206049.754                  
E 2                                
E13                                
E15                                
E21                                
E27                                
E30                                
J 2  37474796.456   196931490.865    37474793.329   153453138.717  
J 3  39205102.482   206024326.178    39205098.926   160538465.393  
J 4  37819486.335   198742788.871    37819482.475   154864493.188  
C 1                                                                
C 2                                                                
C 3                                                                
C 4                                                                
C 5                                                                
C 7                                                                
C 8                                                                
C 9                                                                
C10                                                                
C13                                                                
C14                                                                
C27                                                                
C28                                                                
C30                                                                
C32                                                                
C33                                                                
betaBison commented 2 months ago

Ahh, yes you are correct. Sorry for that confusing error statement and that I didn't realize sooner that you were trying to add satellite states using the Rinex broadcast data and not the SP3/CLK precise data format.

My colleague, @kanhereashwin, was working on additional compatibility to the add_sv_states_rinex() function in our ashwin/broadcast development branch, but there is currently no timeline for completion of that feature.

An alternate approach would be to use the SP3/CLK "precise" data source instead of Rinex. I've demonstrated how to use the "precise" file types in this Google colab.

navdata = glp.RinexObs("simple.23o")
navdata_with_states = glp.add_sv_states(navdata, source="precise", verbose=True)

I've attached the CSV output when using "precise" data here: navdata.csv

mikehb commented 2 months ago

I followed your google colab example, and noticed that the residuals is very large, not as what the tutorial showed, is there any thing wrong with the code or observation data? I am wondering if I can use glp's residuals as a feature of deep learning.

With RTKLIB, I can get a small pseudorange error, with following equation,

_*psr_error = raw_psr - (geometric_distance - CLIGHT svbias)**

where raw_psr is the pseudorange measurement reported by receiver hardware, sv_bias is calculated from broadcast ephemeris, and geometric_distance is caculated by RTKLIB's geodist,

/* geometric distance ----------------------------------------------------------
* compute geometric distance and receiver-to-satellite unit vector
* args   : double *rs       I   satellilte position (ecef at transmission) (m)
*          double *rr       I   receiver position (ecef at reception) (m)
*          double *e        O   line-of-sight vector (ecef)
* return : geometric distance (m) (0>:error/no satellite position)
* notes  : distance includes sagnac effect correction
*-----------------------------------------------------------------------------*/
extern double geodist(const double *rs, const double *rr, double *e)
{
    double r;
    int i;

    if (norm(rs,3)<RE_WGS84) return -1.0;
    for (i=0;i<3;i++) e[i]=rs[i]-rr[i];
    r=norm(e,3);
    for (i=0;i<3;i++) e[i]/=r;
    return r+OMGE*(rs[0]*rr[1]-rs[1]*rr[0])/CLIGHT;
}

for example, the [P0/P1]_residual is within a few meters,

date_time,sat,snr,P0_res,P1_res,x_sv_m,y_sv_m,z_sv_m
1700323217,G03,11500,2.429305233,0.159939319,-19932410.490,7405890.577,15699302.665
1700323217,G06,10500,5.049664315,3.602273457,5578747.079,25472663.414,4841287.832
1700323217,G14,12000,0.358602792,-4.108652949,-11615178.712,22248895.406,8439965.108
1700323217,G17,12250,-0.949575283,-6.435365330,-5538582.348,14240834.309,22168806.197
1700323217,G19,11500,-1.130671874,-8.224673990,4899558.329,16007821.112,20510298.724
1700323217,G22,12000,-0.437244881,-6.244677342,-6480842.785,21300229.686,15142469.398
1700323217,R03,10500,21.442013793,18.547232073,-23796414.534,876730.199,9276967.987
1700323217,R09,13500,14.993377291,11.062192239,4020025.492,18008845.368,17589441.135
1700323217,R16,13250,14.683513619,13.343336895,-6555382.234,24584797.190,1569233.606

the date_time is the seconds since 1970/1/1 00:00:00

After modifying RTKLIB code to dump the sv position, I noticed that it has a huge difference, about 20KM along x/y/z, between RTKLIB and GLP. The RTKLIB uses broadcast ephemeris which was saved by the receiver, while GLP use SP3 downloaded from website.

Is it a bug of add_sv_states? maybe leap second is not aligned? @betaBison @kanhereashwin

Here is a piece of G03 output from GLP

gps_millis,gnss_sv_id,sv_id,gnss_id,raw_pr_m,carrier_phase,raw_doppler_hz,cn0_dbhz,signal_type,observation_code,rx_name,x_rx_m,y_rx_m,z_rx_m,x_sv_m,y_sv_m,z_sv_m,vx_sv_mps,vy_sv_mps,vz_sv_mps,b_sv_m,b_dot_sv_mps,corr_pr_m,residuals_m
1384358436000.0,G03,3,gps,21450976.137,87838183.34,,,l2,2W,BJCN,-2168641.46537,4404159.40321,4058413.91992,-19911138.39541453,7376002.118896029,15740107.749009116,1177.9897205722953,-1655.610960857457,2255.430202271433,-1700.080263911872,0.007665805999931,21449276.05673609,327.43000829592347
1384358436000.0,G03,3,gps,21450976.155,87838190.348,,,l2,2X,BJCN,-2168641.46537,4404159.40321,4058413.91992,-19911138.39541453,7376002.118896029,15740107.749009116,1177.9897205722953,-1655.610960857457,2255.430202271433,-1700.080263911872,0.007665805999931,21449276.07473609,327.4480082988739
1384358436000.0,G03,3,gps,21450975.726,84178266.901,,,l5,5Q,BJCN,-2168641.46537,4404159.40321,4058413.91992,-19911138.39541453,7376002.118896029,15740107.749009116,1177.9897205722953,-1655.610960857457,2255.430202271433,-1700.080263911872,0.007665805999931,21449275.645736087,327.0190082974732
1384358436000.0,G03,3,gps,21450978.406,112725667.707,,,l1,1C,BJCN,-2168641.46537,4404159.40321,4058413.91992,-19911138.39541453,7376002.118896029,15740107.749009116,1177.9897205722953,-1655.610960857457,2255.430202271433,-1700.080263911872,0.007665805999931,21449278.325736087,329.6990082971752
1384358437000.0,G03,3,gps,21450998.402,87838274.497,,,l2,2W,BJCN,-2168641.46537,4404159.40321,4058413.91992,-19909960.364472967,7374346.362366104,15742363.00943632,1178.0721775926115,-1655.9021317340066,2255.0906924402784,-1700.072598209906,0.0076656055363577,21449298.329401787,325.7572275660932
1384358437000.0,G03,3,gps,21450997.991,84178354.249,,,l5,5Q,BJCN,-2168641.46537,4404159.40321,4058413.91992,-19909960.364472967,7374346.362366104,15742363.00943632,1178.0721775926115,-1655.9021317340066,2255.0906924402784,-1700.072598209906,0.0076656055363577,21449297.91840179,325.3462275676429
1384358437000.0,G03,3,gps,21451000.671,112725784.686,,,l1,1C,BJCN,-2168641.46537,4404159.40321,4058413.91992,-19909960.364472967,7374346.362366104,15742363.00943632,1178.0721775926115,-1655.9021317340066,2255.0906924402784,-1700.072598209906,0.0076656055363577,21449300.59840179,328.0262275673449
1384358437000.0,G03,3,gps,21450998.419,87838281.498,,,l2,2X,BJCN,-2168641.46537,4404159.40321,4058413.91992,-19909960.364472967,7374346.362366104,15742363.00943632,1178.0721775926115,-1655.9021317340066,2255.0906924402784,-1700.072598209906,0.0076656055363577,21449298.34640179,325.7742275670171
mikehb commented 2 months ago

Ahh, yes you are correct. Sorry for that confusing error statement and that I didn't realize sooner that you were trying to add satellite states using the Rinex broadcast data and not the SP3/CLK precise data format.

My colleague, @kanhereashwin, was working on additional compatibility to the add_sv_states_rinex() function in our ashwin/broadcast development branch, but there is currently no timeline for completion of that feature.

An alternate approach would be to use the SP3/CLK "precise" data source instead of Rinex. I've demonstrated how to use the "precise" file types in this Google colab.

navdata = glp.RinexObs("simple.23o")
navdata_with_states = glp.add_sv_states(navdata, source="precise", verbose=True)

I've attached the CSV output when using "precise" data here: navdata.csv

add_sv_states works for me

>>> staNavDataGps_states = glp.add_sv_states(staNavDataGps,source="precise", verbose=True)
ephemeris dates needed: [datetime.date(2023, 11, 18)]
FTP downloading /gnss/products/2288/COD0MGXFIN_20233220000_01D_05M_ORB.SP3.gz from gdc.cddis.eosdis.nasa.gov
using previously downloaded file:
 /home/mikehuang/data/ephemeris/sp3/COD0MGXFIN_20233220000_01D_05M_ORB.SP3
ephemeris dates needed: [datetime.date(2023, 11, 18)]
FTP downloading /gnss/products/2288/COD0MGXFIN_20233220000_01D_30S_CLK.CLK.gz from gdc.cddis.eosdis.nasa.gov
using previously downloaded file:
 /home/mikehuang/data/ephemeris/clk/COD0MGXFIN_20233220000_01D_30S_CLK.CLK
interpolating sp3 for  G01
interpolating sp3 for  G02
interpolating sp3 for  G03
interpolating sp3 for  G06
interpolating sp3 for  G14
interpolating sp3 for  G17
interpolating sp3 for  G19
interpolating sp3 for  G22
interpolating sp3 for  G24
interpolating sp3 for  G30
interpolating clk for  G01
interpolating clk for  G02
interpolating clk for  G03
interpolating clk for  G06
interpolating clk for  G14
interpolating clk for  G17
interpolating clk for  G19
interpolating clk for  G22
interpolating clk for  G24
interpolating clk for  G30
>>>