Skip to content
Snippets Groups Projects

Make setup_orekit_curdir optionally load data from folder

1 unresolved thread
1 file
+ 17
6
Compare changes
  • Side-by-side
  • Inline
+ 17
6
@@ -24,9 +24,10 @@ import shutil
from datetime import datetime
import math
import os
from java.io import File
from orekit import JArray
from org.orekit.data import DataProvidersManager, ZipJarCrawler
from org.orekit.data import DataProvidersManager, ZipJarCrawler, DirectoryCrawler
from org.orekit.time import TimeScalesFactory, AbsoluteDate
from org.orekit.utils import ElevationMask
@@ -58,22 +59,27 @@ def download_orekit_data_curdir(filename='orekit-data.zip'):
def setup_orekit_curdir(filename='orekit-data.zip'):
"""Setup the java engine with orekit.
This function loads the orekit-data.zip from the current directory
and sets up the Orekit DataProviders to access it.
This function loads the Orekit data from either:
- A zip in the current directory (by default orekit-data.zip),
- A folder,
depending on whether `filename` is the path to a file or to a folder.
Then the function sets up the Orekit DataProviders to access it.
The JVM needs to be initiated prior to calling this function:
orekit.initVM()
Args:
filename (str): Name of zip with orekit data. Default filename is 'orekit-data.zip'
filename (str): Name of zip or folder with orekit data. Default filename is 'orekit-data.zip'
"""
DM = DataProvidersManager.getInstance()
datafile = File(filename)
if not datafile.exists():
print('File :', datafile.absolutePath, ' not found')
print('File or folder:', datafile.absolutePath, ' not found')
print("""
The Orekit library relies on some external data for physical models.
@@ -90,7 +96,12 @@ def setup_orekit_curdir(filename='orekit-data.zip'):
""")
crawler = ZipJarCrawler(datafile)
if os.path.isdir(filename):
crawler = DirectoryCrawler(datafile)
elif os.path.isfile(filename):
crawler = ZipJarCrawler(datafile)
else:
print('filename ', filename, ' is neither a file nor a folder')
DM.clearProviders()
DM.addProvider(crawler)
Loading