solarwindpy.core.spacecraft
Contais Spacecraft class.
Class inherets from Base and contains Vector objects.
Classes
|
Representation of a spacecraft trajectory. |
- class Spacecraft(data, name, frame)[source]
Bases:
BaseRepresentation of a spacecraft trajectory.
- Parameters:
data (
pandas.DataFrame) – Vector position (and optionally velocity) with MultiIndex columns("M", "C").name (str) – Identifier of the spacecraft.
frame (str) – Reference frame of the vectors, e.g.
"HCI"or"GSE".
- __init__(data, name, frame)[source]
Initialize a spacecraft with data.
- Parameters:
data (pd.DataFrame) – 2-level MultiIndex columns identifying measurment “M” and component “C”. Should contain at a minimum vector position. Can also contain vector velocity and Carrington location. If vector velocity included, it should be in the same frame of reference as the position.
name (str) – Identify the spacecraft, e.g. Parker Solar Probe (PSP) or Wind. Internally stored in all caps for consistency.
frame (str) – The frame of reference for the spacecraft position and velocity, e.g. Geocentric Solar Ecliptic (GSE) or Heliocentric Internal (HCI).
Examples
>>> epoch = pd.Series({0: pd.to_datetime("1995-01-01"), ... 1: pd.to_datetime("2015-03-23"), ... 2: pd.to_datetime("2022-10-09")}, name="Epoch") >>> data = {("pos", "x", ""): {0: -42, 1: -22, 2: -34}, ... ("pos", "y", ""): {0: 23, 1: 31, 2: 11}, ... ("pos", "z", ""): {0: 35, 1: 27, 2: 49}, ... ("v", "x", ""): {0: 9.0, 1: 10.0, 2: 8.0}, ... ("v", "y", ""): {0: -80.0, 1: -70.0, 2: -90.0}, ... ("v", "z", ""): {0: -0.5, 1: 0.5, 2: 1.5}, ... ("carr", "lat", ""): {0: -2.0, 1: -1.0, 2: 3.0}, ... ("carr", "lon", ""): {0: -26.0, 1: -36.0, 2: -16.0}} >>> spacecraft = pd.DataFrame.from_dict(data, ... orient="columns", ... dtype=np.float64) >>> spacecraft.index = epoch >>> spacecraft.columns.names = ["M", "C", "S"] >>> spacecraft = spacecraft.xs("", axis=1, level="S") >>> spacecraft M pos v carr C x y z x y z lat lon Epoch 1995-01-01 -42.0 23.0 35.0 9.0 -80.0 -0.5 -2.0 -26.0 2015-03-23 -22.0 31.0 27.0 10.0 -70.0 0.5 -1.0 -36.0 2022-10-09 -34.0 11.0 49.0 8.0 -90.0 1.5 3.0 -16.0 >>> spacecraft = Spacecraft(spacecraft, "PSP", "HCI")
- property frame
Spacecraft’s frame of reference (e.g. GSE, HCI, etc.).
- property name
Spacecraft name (e.g. WIND, PSP).
- property position
Position vector of the spacecraft.
- Returns:
Position vector with x, y, z components.
- Return type:
- property pos
Shortcut to position property.
- Returns:
Position vector with x, y, z components.
- Return type:
- property r
Shortcut to
position.
- property velocity
Velocity vector of the spacecraft.
- Returns:
Velocity vector with x, y, z components.
- Return type:
- Raises:
KeyError – If spacecraft velocity data is not available.
- property v
Shortcut to
velocity.
- property carrington
Carrington latitude and longitude.
- property distance2sun
Radial distance to Sun in meters.
- set_frame_name(frame, name)[source]
Set the coordinate frame and spacecraft name.
- Parameters:
- Raises:
NotImplementedError – If frame is not ‘GSE’ or ‘HCI’.
- set_data(data)[source]
Set the spacecraft data.
- Parameters:
data (pd.DataFrame) – Spacecraft position/velocity data.
- property constants: Constants
Physical constants.
- Returns:
Physical constants instance.
- Return type:
uc.Constants
- property data: DataFrame
Underlying DataFrame containing the data.
- Returns:
Data with MultiIndex columns.
- Return type:
pd.DataFrame
- head()
Return the first few rows of the data.
- Returns:
First few rows of the data.
- Return type:
pd.DataFrame
- property logger: Logger
Logger instance for this object.
- Returns:
Logger instance.
- Return type:
- static mi_tuples(x: Tuple[Tuple[str, ...], ...]) MultiIndex
Create a MultiIndex from tuples with appropriate names.
- Parameters:
x (Tuple[Tuple[str, ...], ...]) – Tuples to create MultiIndex from.
- Returns:
MultiIndex created from tuples.
- Return type:
MI
- tail()
Return the last few rows of the data.
- Returns:
Last few rows of the data.
- Return type:
pd.DataFrame
- property units: Units
Units conversion factors.
- Returns:
Units conversion instance.
- Return type:
uc.Units