JB2008 Model Instantiation

Hello all,

I am trying to instantiate different atmospheres to use in my orbit propagation and am having some trouble with JB2008.
I had a look at some older posts (Implementing the JR2008 atmospheric model and Atmosphere Model) and am wondering whether it is still the case that I have to provide the SOLFSMY file myself? And if I do I am not sure how to do it correctly…
Currently my implementation of DTM2000 and NRLMSISE00 work but JB2008 does not.

My DTM and NRLMSISE implementation is as follows:

#DTM200 and NRLMSISE00
from org.orekit.models.earth.atmosphere import NRLMSISE00, DTM2000
from org.orekit.models.earth.atmosphere.data import MarshallSolarActivityFutureEstimation
msafe = MarshallSolarActivityFutureEstimation(
    MarshallSolarActivityFutureEstimation.DEFAULT_SUPPORTED_NAMES,
    MarshallSolarActivityFutureEstimation.StrengthLevel.AVERAGE)
atmosphere = NRLMSISE00(msafe, sun, wgs84Ellipsoid)
# atmosphere = DTM2000(msafe, sun, wgs84Ellipsoid)

For JB2008 I have been trying along these lines but I have not managed to feed the SOLFSYM and DTCFILE to the JB2008 successfully:

from org.orekit.models.earth.atmosphere.data import JB2008SpaceEnvironmentData, SOLFSMYDataLoader, DtcDataLoader
from org.orekit.models.earth.atmosphere import JB2008, JB2008InputParameters

sol_data_loader = SOLFSMYDataLoader(utc)
dtc_data_loader = DtcDataLoader(utc)
# i downloaded these manually from https://sol.spacenvironment.net/
sol_file_path = "external/jb08_inputs/SOLFSMY.TXT"
dtc_file_path = "external/jb08_inputs/DTCFILE.TXT"

with open(sol_file_path, 'rb') as sol_file, open(dtc_file_path, 'rb') as dtc_file:
    sol_data_loader.loadData(sol_file, "SOLFSMY.TXT")
    dtc_data_loader.loadData(dtc_file, "DTCFILE.TXT")

jb08_data = JB2008SpaceEnvironmentData(JB2008SpaceEnvironmentData.DEFAULT_SUPPORTED_NAMES_SOLFSMY,
                                       JB2008SpaceEnvironmentData.DEFAULT_SUPPORTED_NAMES_DTC)

jb08_params = JB2008InputParameters()
atmosphere = JB2008(jb08_data, sun, wgs84Ellipsoid, utc)

The error I am currently stuck on is:

---------------------------------------------------------------------------
InvalidArgsError                          Traceback (most recent call last)
Cell In[46], line 10
      7 dtc_file_path = "external/jb08_inputs/DTCFILE.TXT"
      9 with open(sol_file_path, 'rb') as sol_file, open(dtc_file_path, 'rb') as dtc_file:
---> 10     sol_data_loader.loadData(sol_file, "SOLFSMY.TXT")
     11     dtc_data_loader.loadData(dtc_file, "DTCFILE.TXT")
     13 jb08_data = JB2008SpaceEnvironmentData(JB2008SpaceEnvironmentData.DEFAULT_SUPPORTED_NAMES_SOLFSMY,
     14                                        JB2008SpaceEnvironmentData.DEFAULT_SUPPORTED_NAMES_DTC)

InvalidArgsError: (<class 'org.orekit.models.earth.atmosphere.data.SOLFSMYDataLoader'>, 'loadData', (<_io.BufferedReader name='external/jb08_inputs/SOLFSMY.TXT'>, 'SOLFSMY.TXT'))

Any help much appreciated.

Best,
Charles

Apologies for this post, I have now solved the issue.

For anyone who might encounter the same problem this is my current implementation:

        from org.orekit.models.earth.atmosphere.data import JB2008SpaceEnvironmentData, SOLFSMYDataLoader, DtcDataLoader
        from org.orekit.models.earth.atmosphere import JB2008, JB2008InputParameters
        from org.orekit.data import DataSource
        import requests
        from java.io import File

        # Function to download file and return a java.io.File object
        def download_file(url, local_filename):
            with requests.get(url, stream=True) as r:
                r.raise_for_status()
                with open(local_filename, 'wb') as f:
                    for chunk in r.iter_content(chunk_size=8192):
                        f.write(chunk)
            return File(local_filename)

        # Download SOLFSMY and DTCFILE files
        solfsmy_file = download_file("https://sol.spacenvironment.net/JB2008/indices/SOLFSMY.TXT", "external/jb08_inputs/SOLFSMY.TXT")
        dtcfile_file = download_file("https://sol.spacenvironment.net/JB2008/indices/DTCFILE.TXT", "external/jb08_inputs/DTCFILE.TXT")

        # Create DataSource instances
        solfsmy_data_source = DataSource(solfsmy_file)
        dtcfile_data_source = DataSource(dtcfile_file)

        jb08_data = JB2008SpaceEnvironmentData(solfsmy_data_source,
                                            dtcfile_data_source)
        from org.orekit.time import TimeScalesFactory
        utc = TimeScalesFactory.getUTC()
        atmosphere = JB2008(jb08_data, sun, wgs84Ellipsoid, utc)
        isotropicDrag = IsotropicDrag(float(cross_section), float(cd))
        dragForce = DragForce(atmosphere, isotropicDrag)
        force_models.append(dragForce)

Best,
Charles

3 Likes