Creating functions using python wrapper

Goal: I am looking to build functions to incorporate into my app. (Example Ground Track Repeat)

Issue: I can run the examples fine within my environment (Pycharm Jupyter Notebook). However, I get this error whenever I try to use actual Python to build a function (using the same code from the notebook).

Code:

import orekit
vm = orekit.initVM()

from org.orekit.data import DataProvidersManager, ZipJarCrawler
from org.orekit.frames import FramesFactory
from org.orekit.bodies import OneAxisEllipsoid
from org.orekit.time import TimeScalesFactory, AbsoluteDate
from org.orekit.orbits import KeplerianOrbit, PositionAngleType
from org.orekit.utils import Constants, IERSConventions
from org.orekit.propagation.analytical import EcksteinHechlerPropagator

from orekit.pyhelpers import setup_orekit_curdir

from math import radians
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap

setup_orekit_curdir()

## Some Constants
ae = Constants.WGS84_EARTH_EQUATORIAL_RADIUS
mu = Constants.WGS84_EARTH_MU
utc = TimeScalesFactory.getUTC()

print(utc)

Error:

Traceback (most recent call last):
  File "C:\Users\user\.conda\envs\orekit_envi_conda\Lib\site-packages\IPython\core\interactiveshell.py", line 3553, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-f2e64fb75a33>", line 24, in <module>
    utc = TimeScalesFactory.getUTC()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
orekit.JavaError: <super: <class 'JavaError'>, <JavaError object>>
    Java stacktrace:
org.orekit.errors.OrekitException: no IERS UTC-TAI history data loaded
	at org.orekit.time.LazyLoadedTimeScales.getUTC(LazyLoadedTimeScales.java:191)
	at org.orekit.time.TimeScalesFactory.getUTC(TimeScalesFactory.java:130)

Appreciate any help!

Hello @snr and welcome to the Orekit forum !

First of all, thank you for your post which is very detailed :+1:.

Solution

You can download the orekit data using this link. You then need to place it in the same directory as your script.

Explanation

Your error is hopefully not a big one, you simply need to load orekit data to fix your code. Iā€™m going to cite @petrus.hyvonen tutorial on this one :

 The orekit library needs a data file with various information on time and earth rotation parameters.
 This file, called orekit-data.zip is loaded from current dir as default.
 This routine of setting up these parameters is commonly used in the notebooks, so a python specific function is created for this, setup_orekit_curdir()

You can read this for more information.

Cheers,
Vincent

1 Like

Vincent, thank you for the welcome and quick response!

I have been a long-time user of STK, so my wallet and I appreciate all the work you and the other developers have put into this project!

I think the issue was the way I set up my environment.

For those interested in how I fixed it. Here is what I did:

  1. Follow the install documentation
  2. Ensure: conda install -c conda-forge conda-wrappers

Best,

SNR

2 Likes