Package: adam-core
Asteroid Institute ADAM CoreA set of shared astrodynamics libraries and utilities.adam_coreis used by a variety of library and services at Asteroid Institute. Sharing these common classes, types, and conversions amongst our tools ensures consistency and accuracy.UsageOrbitsTo define an orbit:fromastropy.timeimportTimefromadam_core.coordinatesimportKeplerianCoordinatesfromadam_core.coordinatesimportTimesfromadam_core.coordinatesimportOriginfromadam_core.orbitsimportOrbitskeplerian_elements=KeplerianCoordinates.from_kwargs(times=Times.from_astropy(Time([59000.0],scale="tdb",format="mjd")),a=[1.0],e=[0.002],i=[10.],raan=[50.0],ap=[20.0],M=[30.0],origin=Origin.from_kwargs(code=["SUN"]),frame="ecliptic")orbits=Orbits.from_kwargs(orbit_ids=["1"],object_ids=["Test Orbit"],coordinates=keplerian_elements.to_cartesian(),)Note that internally, all orbits are stored in Cartesian coordinates. Cartesian coordinates do not have any
singularities and are thus more robust for numerical integration. Any orbital element conversions to Cartesian
can be done on demand by callingto_cartesian()on the coordinates object.The underlying orbits class is 2 dimensional and can store elements and covariances for multiple orbits.fromastropy.timeimportTimefromadam_core.coordinatesimportKeplerianCoordinatesfromadam_core.coordinatesimportTimesfromadam_core.coordinatesimportOriginfromadam_core.orbitsimportOrbitskeplerian_elements=KeplerianCoordinates.from_kwargs(times=Times.from_astropy(Time([59000.0,60000.0],scale="tdb",format="mjd")),a=[1.0,3.0],e=[0.002,0.0],i=[10.,30.],raan=[50.0,32.0],ap=[20.0,94.0],M=[30.0,159.0],origin=Origin.from_kwargs(code=["SUN","SUN"]),frame="ecliptic")orbits=Orbits.from_kwargs(orbit_ids=["1","2"],object_ids=["Test Orbit 1","Test Orbit 2"],coordinates=keplerian_elements.to_cartesian(),)Orbits can be easily converted to a pandas DataFrame:orbits.to_dataframe()orbit_idsobject_idstimes.jd1times.jd2xyzvxvyvz...cov_vy_ycov_vy_zcov_vy_vxcov_vy_vycov_vz_xcov_vz_ycov_vz_zcov_vz_vxcov_vz_vycov_vz_vz01TestOrbit12459000.00.5-0.1664030.9752730.133015-0.016838-0.0031170.001921...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN12TestOrbit22460000.00.50.572777-2.571820-1.4344570.0093870.002900-0.001452...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaNOrbits can also be defined with uncertainties.importnumpyasnpfromastropy.timeimportTimefromadam_core.coordinatesimportKeplerianCoordinatesfromadam_core.coordinatesimportTimesfromadam_core.coordinatesimportOriginfromadam_core.coordinatesimportCoordinateCovariancesfromadam_core.orbitsimportOrbitskeplerian_elements=KeplerianCoordinates.from_kwargs(times=Times.from_astropy(Time([59000.0],scale="tdb",format="mjd")),a=[1.0],e=[0.002],i=[10.],raan=[50.0],ap=[20.0],M=[30.0],covariances=CoordinateCovariances.from_sigmas(np.array([[0.002,0.001,0.01,0.01,0.1,0.1]])),origin=Origin.from_kwargs(code=["SUN"]),frame="ecliptic")orbits=Orbits.from_kwargs(orbit_ids=["1"],object_ids=["Test Orbit with Uncertainties"],coordinates=keplerian_elements.to_cartesian(),)orbits.to_dataframe(sigmas=True)orbit_idsobject_idstimes.jd1times.jd2xyzvxvyvz...cov_vy_ycov_vy_zcov_vy_vxcov_vy_vycov_vz_xcov_vz_ycov_vz_zcov_vz_vxcov_vz_vycov_vz_vz01TestOrbitwithUncertainties2459000.00.5-0.1664030.9752730.133015-0.016838-0.0031170.001921...3.625729e-08-1.059731e-08-9.691716e-111.872922e-091.392222e-08-1.759744e-09-1.821839e-09-7.865582e-112.237521e-103.971297e-11To query orbits from JPL Horizons:fromastropy.timeimportTimefromadam_core.orbits.queryimportquery_horizonstimes=Time([60000.0],scale="tdb",format="mjd")object_ids=["Duende","Eros","Ceres"]orbits=query_horizons(object_ids,times)To query orbits from JPL SBDB:fromadam_core.orbits.queryimportquery_sbdbobject_ids=["Duende","Eros","Ceres"]orbits=query_sbdb(object_ids)Orbital Element ConversionsOrbital elements can be accessed via the corresponding attribute. All conversions, including covariances, are done on demand and stored.# Cartesian Elementsorbits.coordinates# To convert to other representationscometary_elements=orbits.coordinates.to_cometary()keplerian_elements=orbits.coordinates.to_keplerian()spherical_elements=orbits.coordinates.to_spherical()PropagatorThe propagator class inadam_coreprovides a generalized interface to the supported orbit integrators and ephemeris generators. By default,adam_coreships with PYOORB.To propagate orbits with PYOORB (here we grab some orbits from Horizons first):importnumpyasnpfromastropy.timeimportTimefromastropyimportunitsasufromadam_core.orbits.queryimportquery_horizonsfromadam_core.propagatorimportPYOORB# Get orbit to propagateinitial_time=Time([60000.0],scale="tdb",format="mjd")object_ids=["Duende","Eros","Ceres"]orbits=query_horizons(object_ids,initial_time)# Make sure PYOORB is readypropagator=PYOORB()# Define propagation timestimes=initial_time+np.arange(0,100)*u.d# Propagate orbits! This function supports multiprocessing for large# propagation jobs.propagated_orbits=propagator.propagate_orbits(orbits,times,chunk_size=100,num_jobs=1,)Low-level APIsGetting the heliocentric ecliptic state vector of a DE440 body at a given set of times (in this case the barycenter of the Jovian system):importnumpyasnpfromastropy.timeimportTimefromadam_core.coordinates.originimportOriginCodesfromadam_core.utils.spiceimportget_perturber_statestates=get_perturber_state(OriginCodes.JUPITER_BARYCENTER,Time(np.arange(59000,60000),format="mjd",scale="tdb"),frame="ecliptic",origin=OriginCodes.SUN,)Package Structureadam_core
├──constants.py# Shared constants├──coordinates# Coordinate classes and transformations├──dynamics# Numerical solutions├──orbits# Orbits class and query utilities└──utils# Utility classes like Indexable or conversions like times_from_dfInstallationADAM Core is available on PyPIpipinstalladam_coreDevelopmentDevelopment is made easy with our Docker container environment.# Build the containerdockercomposebuild# Run tests in the containerdockercomposerunadam_corepytest.# Run a shell in the containerdockercomposerunadam_corebash