Hello everyone, good morning! I’m having my first experience with Orekit and I already have a big challenge, which is to make a geolocation algorithm.
Well, when I looked at the tutorials and some posts here on the forum on this subject (Efficient way to load DEM tiles in Rugged Python) and (TileUpdater in Python), I decided not to start from scratch, but to take advantage of what had already been done.
I updated the OreKit library to the latest one in order to be able to import PythonTileUpdate
. I also used the DEMTileUpdater class using SRTM.
When I try to initialize the RuggedBuilder, I get an error when defining the DEM, where I get the following error: NotImplementedError: ('instantiating java class', <class 'tu2.DEMTileUpdater'>)
. The error points exactly to the line of ruggedbuilder.setDigitalElevationModel(DEMTileUpdater(), nb_tiles)
, indicating that the error comes from the class.
I’ve noticed that other people have pointed out the same error type in different situations, but in their case it was due to a missing instance. Which I don’t think is the case with me.
Is there something I’m missing? Any variables or instances? In the DEMTileUpdater class, should I pass the coordinates? I understand that I’m not.
Thank you very much!
tu2.py, the class published by @yzokras
import srtm
import numpy as np
from org.orekit.rugged.raster import PythonTileUpdater
class DEMTileUpdater(PythonTileUpdater):
def __init__(self):
super(DEMTileUpdater, self).__init__()
self.n_lat = 101 # Number of rows in tile
self.n_lon = 101 # Number of columns in tile
self.tile_size_lat = float(np.deg2rad(1.0)) # Tile size in radians
self.tile_size_lon = float(np.deg2rad(1.0)) # Tile size in radians
self.delta_lat = self.tile_size_lat / self.n_lat # row sample size in radians
self.delta_lon = self.tile_size_lon / self.n_lon # column sample size in radians
self.elevation_data = srtm.get_data() # srtm object to get srtm data
def updateTile(self, latitude, longitude, tile):
min_latitude = latitude - self.tile_size_lat / 2.0
min_longitude = longitude - self.tile_size_lon / 2.0
tile.setGeometry(min_latitude, # minLatitude
min_longitude, # minLongitude
self.delta_lat, # latitudeStep
self.delta_lon, # longitudeStep
self.n_lat, # latitudeRows
self.n_lon) # longitudeColumns
for i in range(0,self.n_lat):
for j in range(0,self.n_lon):
"""
Get elevation from srtm reader
"""
elevation = self.elevation_data.get_elevation(np.rad2deg(min_latitude + i*self.delta_lat),
np.rad2deg(min_longitude + j*self.delta_lon))
if elevation is None:
elevation = 0.0
tile.setElevation(i, j, float(elevation))
- My RuggedBuilder
from tu2 import DEMTileUpdater
b_tiles = 2
algo_id = AlgorithmId.DUVENHAGE
nbPVPoints = 1
nbQPoints = 1
tStep = 0.1
timeTolerance = 10.
# Initialize RuggedBuilder with adjusted parameters
ruggedbuilder = RuggedBuilder()
ruggedbuilder.setDigitalElevationModel(DEMTileUpdater(), nb_tiles)
ruggedbuilder.setAlgorithm(algo_id)
ruggedbuilder.setEllipsoid(EllipsoidId.WGS84, BodyRotatingFrameId.ITRF)
ruggedbuilder.setTimeSpan(start_date, stop_date, tStep, timeTolerance)
ruggedbuilder.setTrajectory(InertialFrameId.EME2000,
satellite_pv_list,
nbPVPoints,
CartesianDerivativesFilter.USE_P,
satellite_q_list,
nbQPoints,
AngularDerivativesFilter.USE_R)
ruggedbuilder.addLineSensor(line_sensor)
rugged = ruggedbuilder.build()