-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from B612-Asteroid-Institute/jm/aberrated-ephe…
…meris Add the aberrated orbit to the Ephemeris table
- Loading branch information
Showing
2 changed files
with
27 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,19 @@ | ||
import pandas as pd | ||
from quivr import StringColumn, Table | ||
from typing_extensions import Self | ||
|
||
from ..coordinates.cartesian import CartesianCoordinates | ||
from ..coordinates.spherical import SphericalCoordinates | ||
|
||
|
||
class Ephemeris(Table): | ||
|
||
orbit_id = StringColumn(nullable=False) | ||
object_id = StringColumn() | ||
coordinates = SphericalCoordinates.as_column(nullable=False) | ||
|
||
def to_dataframe(self) -> pd.DataFrame: | ||
""" | ||
Convert the Ephemeris table to a pandas DataFrame. | ||
Returns | ||
------- | ||
df : `~pandas.DataFrame` | ||
The Ephemeris table as a DataFrame. | ||
""" | ||
df = pd.DataFrame() | ||
df["orbit_id"] = self.orbit_id | ||
df["object_id"] = self.object_id | ||
df_coordinates = self.coordinates.to_dataframe() | ||
|
||
df = pd.concat([df, df_coordinates], axis=1) | ||
df.rename( | ||
columns={ | ||
"lon": "ra", | ||
"lat": "dec", | ||
"vlon": "vra", | ||
"vlat": "vdec", | ||
}, | ||
inplace=True, | ||
) | ||
return df | ||
|
||
@classmethod | ||
def from_dataframe(cls, df: pd.DataFrame) -> Self: | ||
""" | ||
Instantiate an Ephemeris table from a pandas DataFrame. | ||
Parameters | ||
---------- | ||
df : `~pandas.DataFrame` | ||
The Ephemeris table as a DataFrame. | ||
Returns | ||
------- | ||
ephemeris : `~adam_core.orbits.ephemeris.Ephemeris` | ||
The Ephemeris table. | ||
""" | ||
coordinates = SphericalCoordinates.from_dataframe( | ||
df.rename( | ||
columns={ | ||
"ra": "lon", | ||
"dec": "lat", | ||
"vra": "vlon", | ||
"vdec": "vlat", | ||
"obs_code": "origin.code", | ||
}, | ||
), | ||
"equatorial", | ||
) | ||
return cls.from_kwargs( | ||
orbit_id=df["orbit_id"], | ||
object_id=df["object_id"], | ||
coordinates=coordinates, | ||
) | ||
coordinates = SphericalCoordinates.as_column() | ||
|
||
# The coordinates as observed by the observer will be the result of | ||
# light emitted or reflected from the object at the time of the observation. | ||
# Light, however, has a finite speed and so the object's observed cooordinates | ||
# will be different from its actual geometric coordinates at the time of observation. | ||
# Aberrated coordinates are coordinates that account for the light travel time | ||
# from the time of emission/reflection to the time of observation | ||
aberrated_coordinates = CartesianCoordinates.as_column(nullable=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters