Coordinates conversion tool
Model API name: coordinate-conversion
Coordinates conversion tool
Version: v1
External Input: trajectory
Input | Value |
---|---|
Model name |
sapre
sapre_upload
|
trajectory
|
Model result name | trajectory |
Quantity | trajectory |
Input group: trajectory / multiplicity: one
Input | Description | Valid values | Default | Quantity |
---|---|---|---|---|
epochs | List of epochs in the format specified by 'inputDateFormat' |
|
[[]] | number |
coordinates | List of coordinate data, [x, y, z] or [x, y, z, vx, vy, vz] |
|
[[]] | number |
inputDateFormat | Input date format |
ET=ET ISO=ISO JDCT=Julian date MJD=Modified Julian date CMJD=CNES modified Julian date datetime=Python datetime |
ISO | number |
inputDistanceUnits | Input altitude units |
m=m km=km rb=Units of body radius |
km | number |
outputDistanceUnits | Output altitude units |
m=m km=km rb=Units of the position coordinates |
km | number |
outputDateFormat | Output date format |
ET=ET ISO=ISO JDCT=Julian date MJD=Modified Julian date CMJD=CNES modified Julian date datetime=Python datetime |
datetime | number |
inputCoordSystem | Input coordinate frame |
|
number | |
outputCoordSystem | Output coordinate frame |
|
J2000 | number |
inputFrameBody | Body for the input frame |
|
number | |
outputFrameBody | Body for the output frame |
|
number |
|
None
# coding=utf-8
import csv
import datetime
from io import StringIO
from os import path
import numpy as np
from nom_client.nom_client import NoMClient
_here = path.abspath(path.dirname(__file__))
saturn_radius = 60280 # km
nom_client = NoMClient(project_name="Trajectory example", debug_output=True)
##with open(path.join(_here, 'resources', 'saturn_equ_solar.txt')) as csv_file:
# ss = np.genfromtxt(csv_file, delimiter=" ", autostrip=True)
# d = 3
import re
saturn_equ_vectors = []
with open(path.join(_here, 'resources', 'out4_saturn_snc.txt')) as csv_file:
csv_reader = csv.reader(csv_file, delimiter="\t")
line_count = 0
for row in csv_reader:
row = [float(x) for x in row]
saturn_equ_vectors.append(row)
saturn_enis_vectors = []
with open(path.join(_here, 'resources', 'out4_ENCELADUS_snc.txt')) as csv_file:
csv_reader = csv.reader(csv_file, delimiter="\t")
line_count = 0
for row in csv_reader:
row = [float(x) for x in row]
saturn_enis_vectors.append(row)
saturn_tiis_vectors = []
with open(path.join(_here, 'resources', 'out4_TITAN_snc.txt')) as csv_file:
csv_reader = csv.reader(csv_file, delimiter="\t")
line_count = 0
for row in csv_reader:
row = [float(x) for x in row]
saturn_tiis_vectors.append(row)
trajectory_conversion_model = nom_client.get_model('coordinate-conversion')
epochs = np.array(saturn_equ_vectors).T[6:7][0]
saturn_equ_vectors = np.array(saturn_equ_vectors).T[0:3].T*saturn_radius
saturn_enis_vectors = np.array(saturn_enis_vectors).T[0:3].T*saturn_radius
saturn_tiis_vectors = np.array(saturn_tiis_vectors).T[0:3].T*saturn_radius
epochs = epochs[0:4]
saturn_equ_vectors = saturn_equ_vectors[0:4]
saturn_enis_vectors = saturn_enis_vectors[0:4]
saturn_tiis_vectors = saturn_tiis_vectors[0:4]
import spiceypy as spice
eee = []
trajectory_conversion_model.set_params(epochs=epochs, coordinates=saturn_equ_vectors,
inputCoordSystem="saturn_equatorial_solar",
outputCoordSystem="saturn_enis",
inputDateFormat="ET", outputDateFormat="ISO", inputDistanceUnits="km",
outputDistanceUnits="km")
conversion_results = nom_client.run_model(trajectory_conversion_model, model_timeout=1000)
print(conversion_results)
conversion_results_data = conversion_results['trajectory']
date_c = conversion_results_data.get_variable_data('date').squeeze()
x_c = conversion_results_data.get_variable_data('x').squeeze() #/ saturn_radius
y_c = conversion_results_data.get_variable_data('y').squeeze() #/ saturn_radius
z_c = conversion_results_data.get_variable_data('z').squeeze() #/ saturn_radius
for i in range(0, len(date_c)):
print(f"{x_c[i]} {y_c[i]} {z_c[i]} | {saturn_enis_vectors[i][0]} {saturn_enis_vectors[i][1]} {saturn_enis_vectors[i][2]}")
#
#
# import matplotlib.pyplot as plt
#
# fig = plt.figure()
# ax = fig.add_subplot(111, projection='3d')
# ax.plot(x_c, y_c, z_c)
# plt.show()
# coding=utf-8
from os import path
import numpy as np
from nom_client.nom_client import NoMClient
_here = path.abspath(path.dirname(__file__))
saturn_radius = 60280 # km
enceledus_radius = 250 # km
nom_client = NoMClient(project_name="Trajectory example", default_server_id="local_server")
trajectory_model = nom_client.get_model('trajectory')
trajectory_model.set_params(orbitSpecificationCode=201,
startDate="2024-03-30 00:00:00",
missionDuration=10,
naifCode=602,
duration=10, # days
semiMajorAxis=10 * enceledus_radius,
raan=0,
inclination=60,
trueAnomaly=0,
eccentricity=0.7,
argumentOfPerigee=10,
altitudeSteps=[5 * enceledus_radius, 15 * enceledus_radius],
timeSteps=[60, 150, 1000]
)
trajectory_model_results = nom_client.run_model(model=trajectory_model)
trajectory_data = trajectory_model_results['trajectory']
date = trajectory_data.get_variable_data('mjd').squeeze()
x = trajectory_data.get_variable_data('position').squeeze()[0]
y = trajectory_data.get_variable_data('position').squeeze()[1]
z = trajectory_data.get_variable_data('position').squeeze()[2]
print("{0}, {1}, {2}, {3}".format(date[0], x[0], y[0], z[0]))
trajectory_conversion_model = nom_client.get_model('coordinate-conversion')
trajectory_conversion_model.set_external_input(external_input_name="trajectory",
external_input=trajectory_model_results)
# SATURN_EQUATORIAL_SOLAR or CASSINI_SZM_ENCELADUS
trajectory_conversion_model.set_params(inputCoordSystem="J2000", outputCoordSystem="CASSINI_SZM_ENCELADUS",
inputDateFormat="JDCT", outputDateFormat="ISO", inputDistanceUnits="km",
outputDistanceUnits="km")
conversion_results = nom_client.run_model(trajectory_conversion_model)
print(conversion_results)
conversion_results_data = conversion_results['trajectory']
date_c = conversion_results_data.get_variable_data('date').squeeze()
x_c = conversion_results_data.get_variable_data('x').squeeze()
y_c = conversion_results_data.get_variable_data('y').squeeze()
z_c = conversion_results_data.get_variable_data('z').squeeze()
for i, e in enumerate(date):
print("{0}, {1}, {2}, {3}".format(date_c[i], x_c[i], y_c[i], z_c[i]))
import plotly.graph_objects as go
fig = go.Figure(data=go.Scatter3d(x=x_c, y=y_c, z=z_c))
fig.add_trace(go.Scatter3d(x=x, y=y, z=z))
fig.update_traces(marker=dict(size=1))
xs = ys = zs = np.arange(0, 1)
fig.add_trace(go.Scatter3d(mode='markers',x=xs,y=ys,z=zs,
marker=dict(sizemode='diameter')
))
fig.show()
# coding=utf-8
from os import path
import numpy as np
from nom_client.nom_client import NoMClient
_here = path.abspath(path.dirname(__file__))
saturn_radius = 60280 # km
nom_client = NoMClient(project_name="Trajectory example",
default_server_id="local_server", debug_output=True)
trajectory_conversion_model = nom_client.get_model('coordinate-conversion')
'''
lat lon alt radius
02/02/2005 00:00:00
GEOD 73.64 -132.15 -4644.48
GEO 74.02 -132.15 1732.05
GEI 74.02 0.14 1732.05
MAG 69.17 -63.36 1732.05
SM 69.17 38.15 1732.05
GSM 54.74 45.00 1732.05
GSE 75.42 53.38 1732.05
GEI-2000 73.99 0.07 1732.05
'''
#spherical alt lat lon
inputs = [[1732.05, 75.42, 53.38 ]]
epochs = ["2005-02-02T00:00:00.000"]
trajectory_conversion_model.set_params(coordinates=inputs, epochs=epochs,
inputCoordSystem="GSE", outputCoordSystem="GEO",
inputDateFormat="ISO", outputDateFormat="ISO",
inputDistanceUnits="km",outputDistanceUnits="km")
conversion_results = nom_client.run_model(trajectory_conversion_model)
conversion_results_data = conversion_results['trajectory']
type_ = conversion_results_data['qualifiers']['coordinates']
if type_ == 'cartesian':
date_c = conversion_results_data.get_variable_data('date')
x_c = conversion_results_data.get_variable_data('x')
y_c = conversion_results_data.get_variable_data('y')
z_c = conversion_results_data.get_variable_data('z')
print("{0}, {1}, {2}, {3}".format(date_c[0][0], x_c[0][0], y_c[0][0], z_c[0][0]))
else:
date_c = conversion_results_data.get_variable_data('date')
x_c = conversion_results_data.get_variable_data('latitude')
y_c = conversion_results_data.get_variable_data('longitude')
z_c = conversion_results_data.get_variable_data('altitude')
print("{0}, {1}, {2}, {3}".format(date_c[0][0], x_c[0][0], y_c[0][0], z_c[0][0]))
No references