Reading DCB files with sinexLoader

Hi everyone ! I am new to Orekit in Python and I need to read GNSS - Differential Code Biases files. SinexLoader documentation says that it can read DCB files but I haven’t succeeded to read any .bia or .bsx . It is worth mentioning that I can read .snx files with no problem (but they usually contain station/receivers informations and I am interested in satellite data (which are rarely in sinex 2.0)). Here is an example :

import orekit
vm = orekit.initVM()
import java.io
import org.orekit

from orekit.pyhelpers import setup_orekit_curdir, download_orekit_data_curdir
setup_orekit_curdir()

bias = "cnt23136.bia"
TS = org.orekit.time.TimeScalesFactory.getGPS()
DS = org.orekit.data.DataSource(bias)
sinFile = org.orekit.files.sinex.SinexLoader(DS)
dcbG02 = sinFile.getDcbSatellite("G02")

Do you get some error message or just an empty result?

I got the following error :

Traceback (most recent call last):

  Cell In[107], line 1
    sinFile = org.orekit.files.sinex.SinexLoader(DS)

JavaError: <super: <class 'JavaError'>, <JavaError object>>
    Java stacktrace:
java.lang.IllegalArgumentException: No enum constant org.orekit.gnss.ObservationType.
	at java.lang.Enum.valueOf(Enum.java:238)
	at org.orekit.gnss.ObservationType.valueOf(ObservationType.java:30)
	at org.orekit.files.sinex.Dcb.addDcbLine(Dcb.java:99)
	at org.orekit.files.sinex.SinexLoader$Parser.loadData(SinexLoader.java:706)
	at org.orekit.files.sinex.SinexLoader.<init>(SinexLoader.java:253)
	at org.orekit.files.sinex.SinexLoader.<init>(SinexLoader.java:222)

I am wondering if the SinexLoader is actually really made to read DCBs…

It is made to read DCB and there are non-regression tests for that. See for example this file
The culprit seem to be the field with the measurement code. Could you show us the file, or just the few lines that trigger the error?
There are 321 observation types that are recognized. You can find them : https://gitlab.orekit.org/orekit/orekit/-/blob/develop/src/main/java/org/orekit/gnss/ObservationType.java?ref_type=heads

Does you file matches these?

Note that in version 13.0, it will be possible to use custom observation types in addition to the predefined ones. This is already available in the develop-13 branch for Rinex obs files, it could be easily added to Sinex DCB files.

Thank you for your answer ! I can at least tell you that I succeeded to extract DCBs from the .BSX file in the example you mentioned :partying_face:.
It seems that the issue is in the first line, here is a non-working example :

%=BIA 1.00 CAS 24:126:07127   CAS 2024:123:00000 2024:124:00000 R 00005991      

against the working one

%=BIA 1.00 DLR 2022:011:58414 DLR 2021:274:00000 2022:001:00000 R 00246696

(if I replace this line with the one from your example it works perfectly, with both .bsx and .bia files from the CDDIS).

The error in this case :

JavaError: <super: <class 'JavaError'>, <JavaError object>>
    Java stacktrace:
org.orekit.errors.OrekitException: impossible d'analyser la ligne 1 du fichier C:/Users/hlabriji/Downloads/CAS0OPSRAP_20241230000_01D_01D_DCB.BIA/CAS0OPSRAP_20241230000_01D_01D_DCB.BIA :
%=BIA 1.00 CAS 2024:126:07127   CAS 2024:123:00000 2024:124:00000 R 00005991      
	at org.orekit.files.sinex.SinexLoader$Parser.loadData(SinexLoader.java:425)
	at org.orekit.files.sinex.SinexLoader.<init>(SinexLoader.java:253)
	at org.orekit.files.sinex.SinexLoader.<init>(SinexLoader.java:222)

BUT it works when I manually remove the extra space before the second “CAS” (the name of the center) ! maybe there is an issue with the parsing of this first line ?

I still don’t understand why it is not working for my DCB file from CNES …

And here is the first lines of the CNES file :

%=BIA 1.00 CNT 2024:133:01864 CNT 2024:132:00000 2024:132:86370 P 00000 0
*-------------------------------------------------------------------------------------------------------
* Solution INdependent EXchange Format (SINEX)                                                          
*-------------------------------------------------------------------------------------------------------
+FILE/REFERENCE                                                                                         
 DESCRIPTION        Multi-GNSS Code and Phase Biases for satellites                                     
 INPUT              CNES OSB solutions in internal format                                               
 OUTPUT             CNES OSB solutions in Bias SINEX format                                             
 CONTACT            contact_ppp@cnes.fr                                                                 
 SOFTWARE           PPP-Wizard                                                                          
-FILE/REFERENCE                                                                                         
*-------------------------------------------------------------------------------------------------------
+BIAS/DESCRIPTION                                                                                       
 PARAMETER_SPACING                                30                                                     
 DESCRIPTION        GPS     C1C                                                    	                        
 DESCRIPTION        GPS     C1P                                                    	                        
 DESCRIPTION        GPS     C1W                                                    	                        
 DESCRIPTION        GPS     C2S                                                    	                        
 DESCRIPTION        GPS     C2L                                                    	                        
 DESCRIPTION        GPS     C2X                                                    	                        
 DESCRIPTION        GPS     C2W                                                    	                        
 DESCRIPTION        GPS     C5Q                                                    	                        
 DESCRIPTION        GPS     C5X                                                    	                        
 DESCRIPTION        GPS     L1C                                                    	                        
 DESCRIPTION        GPS     L2W                                                    	                        
 DESCRIPTION        GPS     L5I                                                    	                        
 DESCRIPTION        GLONASS C1C                                                    	                        
 DESCRIPTION        GLONASS C1P                                                    	                        
 DESCRIPTION        GLONASS C2C                                                    	                        
 DESCRIPTION        GLONASS C2P                                                    	                        
 DESCRIPTION        GALILEO C1C                                                    	                        
 DESCRIPTION        GALILEO C5Q                                                    	                        
 DESCRIPTION        GALILEO C7Q                                                    	                        
 DESCRIPTION        GALILEO C6C                                                    	                        
 DESCRIPTION        GALILEO L1C                                                    	                        
 DESCRIPTION        GALILEO L5Q                                                    	                        
 DESCRIPTION        GALILEO L7Q                                                    	                        
 DESCRIPTION        GALILEO L6C                                                    	                        
-BIAS/DESCRIPTION                                                                                       
*-------------------------------------------------------------------------------------------------------
+BIAS/SOLUTION                                                                                          
*BIAS SVN_ PRN STATION__ OBS1 OBS2 BIAS_START____ BIAS_END______ UNIT __ESTIMATED_VALUE____ _STD_DEV___ __ESTIMATED_SLOPE____ _STD_DEV___
 OSB       G02           C1C       2024:132:00000 2024:132:00030 ns                -10.6073
 OSB       G02           C1P       2024:132:00000 2024:132:00030 ns                -10.3738
 OSB       G02           C1W       2024:132:00000 2024:132:00030 ns                -12.0750
 OSB       G02           C2W       2024:132:00000 2024:132:00030 ns                -19.8804
 OSB       G02           L1C       2024:132:00000 2024:132:00030 ns                  1.8119
 OSB       G02           L2W       2024:132:00000 2024:132:00030 ns                  2.9540

This is indeed the problem. This file is not compliant with SINEX format (see sinex bias 1.00 section 4.1). Nothe that the other file you put in your next message is different, it is still not compliant with Sinex 1.0 format (last fields are ‘P’, ‘00000’ and ‘0’), but this second file can be parsed as we ignore these fields.

Anyway, I would suggest first to ask CNES to produce conformant files (I am in fact more concerned about the last fields than the extra space), but before they change anything, you can apply the following patch to Orekit and recompile it if you can so it is able to load these non-conformant files.
SinexLoader.patch (1.1 KB)

I will apply this patch in the upcoming 13.0 version.

Rectification: don’t apply the patch it will break other files parsing.
I’ll provide a new patch soon.

Here is a new patch:

SinexLoader.patch (1.1 KB)

I have created (and fixed) issue-1535 for this.

1 Like

Coming back to this thread.
I think your last file could not be parsed by Orekit yet because it contains OSB data (i.e. absolute, with one observable only), not DSB data (i.e. differential, with two observables). The parser fails to check the key in the first column (DSB, OSB, ISB) and I guess it will fail to load the values as the second observable is blank in OSB case.

Here is an update about this discussion.
The Sinex parsers (both regular sinex files and sinex-bias files) have been completely revamped in the develop-13 branch, in order to solve issue 1538.

In the new implementation, the SinexLoader class has been removed and replaced by two parsers (SinexParser and SinexBiasParser), both with a parse method that takes several DataSource instances as argument and return a Sinex or a SinexBias container.

The SinexBiasParser should load properly both DSB and OSB biases. It still does not support ISB.