This page was generated by nbsphinx from docs/examples/Cdpp3dView.ipynb.
Interactive online version: Binder badge Google Colab badge

CDPP3DVIEW Provider examples

Only for Google Colab Users

[ ]:
%pip install --upgrade ipympl speasy
[ ]:
try:
    from google.colab import output
    output.enable_custom_widget_manager()
except:
    print("Not running inside Google Collab")

For all users

[1]:
import speasy as spz
%matplotlib inline
import matplotlib.pyplot as plt
Can't get data from proxy server http://sciqlop.lpp.polytechnique.fr/cache
Can't get inventory for provider cdpp3dview from proxy server http://sciqlop.lpp.polytechnique.fr/cache, status code 400

Show inventories

[2]:
print(list(spz.inventories.flat_inventories.cdpp3dview.parameters.keys()))
['GEOTAIL', 'WIND', 'SOHO', 'Pioneer10', 'Pioneer11', 'Voyager_1', 'Voyager_2', 'Mariner 10', 'MEX', 'Mars Odyssey', 'ULYSSES', 'Phobos2', 'Galileo', 'Cassini', 'ACE', 'Chandra (CXO)', 'CLUSTER1', 'CLUSTER2', 'CLUSTER3', 'CLUSTER4', 'Rosetta', 'HelioSwarm0', 'HelioSwarm1', 'HelioSwarm2', 'HelioSwarm3', 'HelioSwarm4', 'HelioSwarm5', 'HelioSwarm6', 'HelioSwarm7', 'HelioSwarm8', 'Stereo-A', 'Stereo-B', 'MESSENGER', 'THEMISA', 'THEMISB', 'THEMISC', 'THEMISD', 'THEMISE', 'VEX', 'COROT', 'Planck', 'SVOM', 'Jason 2', 'INTERBALL-Auroral', 'INTERBALL-Tail', 'Giotto', 'PICARD', 'MRO', 'MSL', 'Juno', 'JUICE', 'MAVEN', 'MMO', 'MPO', 'BepiColombo', 'Solar Orbiter', 'MGS', 'Parker Solar Probe', 'Europa Clipper', 'Proba2', 'ISEE1', 'ISEE2', 'ISEE3', 'Doublestar1', 'Doublestar2', 'IMP-8', 'POLAR', 'CHAMP', 'DEMETER', 'FAST', 'Freja', 'IMAGE', 'AMPTE-IRM', 'Oersted', 'Reimei', 'SDO', 'Swarm-A', 'Swarm-B', 'Swarm-C', 'Timed', 'TRACE', 'Helios1', 'Helios2', 'MMS1', 'MMS2', 'MMS3', 'MMS4', 'RBSPA', 'RBSPB', 'XMM', 'Herschel', 'Gaia', 'TGO', 'DSCOVR', 'EMM', 'ARASE', 'Akebono', 'Alouette1', 'Alouette2', 'AMPTE-CCE', 'AMPTE-UKS', 'New Horizons', 'Smile', 'Henri', 'Marguerite', 'Cassiope', 'CRRES', 'CSSWE', 'DE1', 'DE2', 'DMSPF06', 'DMSPF07', 'DMSPF08', 'DMSPF09', 'DMSPF10', 'DMSPF11', 'DMSPF12', 'DMSPF13', 'DMSPF14', 'DMSPF15', 'DMSPF16', 'DMSPF17', 'DMSPF18', 'DMSPF19', 'Equator-S', 'GOES06', 'GOES07', 'GOES08', 'GOES09', 'GOES10', 'GOES11', 'GOES12', 'GOES13', 'GOES14', 'GOES15', 'GOES16', 'Grace1', 'Grace2', 'Hawkeye', 'IMP-7', 'ISIS1', 'ISIS2', 'ISS', 'METOP1B', 'METOP2A', 'NOAA5', 'NOAA6', 'NOAA7', 'NOAA8', 'NOAA10', 'NOAA12', 'NOAA14', 'NOAA15', 'NOAA16', 'NOAA17', 'NOAA18', 'NOAA19', 'Ohzora', 'Rhessi', 'Rocsat1', 'Sampex', 'Scatha', 'SNOE', 'ST5a', 'ST5b', 'ST5c', 'TWINS1', 'TWINS2', 'UARS', 'Aureol-3', 'CNOFS', 'ICON', 'Chandrayaan-1', 'Kaguya', 'HERA', 'EscaPADE-B', 'EscaPADE-G', 'Sun', 'Mercury', 'Venus', 'Earth', 'Moon', 'Mars', 'Phobos', 'Deimos', 'Jupiter', 'Io', 'Europa', 'Ganymede', 'Callisto', 'Amalthea', 'Thebe', 'Saturn_barycenter', 'Saturn', 'Mimas', 'Enceladus', 'Tethys', 'Dione', 'Rhea', 'Titan', 'Hyperion', 'Iapetus', 'Phoebe', 'Helene', 'Telesto', 'Methone', 'Pallene', 'Anthe', 'Uranus', 'Ariel', 'Umbriel', 'Titania', 'Oberon', 'Miranda', 'Neptune', 'Triton', 'Neired', 'Pluto', 'Charon', 'Churyumov-Gerasimenko', 'Halley', 'Grigg-Skjellerup', 'Lutetia', 'Steins', 'Didymos', 'Dimorphos']

Completion works well

cdpp3dview tree is like

Trajectory
└── <BodyType>
    └── <Body>
[3]:
spz.inventories.tree.cdpp3dview.Trajectories.ASTEROID.Didymos
[3]:
<ParameterIndex: Didymos>

get_data() with string or ParameterIndex

[4]:
# with ParameterIndex as product
dimorphos_ParamIdx = spz.inventories.tree.cdpp3dview.Trajectories.ASTEROID.Dimorphos
dimorphos_SpzVar = spz.get_data(dimorphos_ParamIdx, '2008-1-1', '2008-1-2')
dimorphos_SpzVar
[4]:
SpeasyVariable(
    Name: 'pos',
    Time Range: 2008-01-01T00:00:00.000000000 - 2008-01-01T23:50:00.000000000
    Shape: (144, 3),
    Unit: 'km',
    Columns: ['x', 'y', 'z'],
    Meta: {
        CATDESC: 'position in J2000 frame',
        DISPLAY_TYPE: 'time_series',
        FIELDNAM: 'Position',
        UNITS: 'km',
        VAR_TYPE: 'data',
        DEPEND_0: 'Epoch',
        LABL_PTR_1: ['x', 'y', 'z'],
        },
    Size: '3.5 kB',
    )
[5]:
dimorphos_SpzVar.to_dataframe()
[5]:
x y z
2008-01-01 00:00:00 148738016.0 38082860.0 7979088.0
2008-01-01 00:10:00 148731184.0 38100460.0 7987508.5
2008-01-01 00:20:00 148724368.0 38118064.0 7995928.5
2008-01-01 00:30:00 148717536.0 38135664.0 8004348.5
2008-01-01 00:40:00 148710704.0 38153264.0 8012768.5
... ... ... ...
2008-01-01 23:10:00 147770688.0 40524640.0 9148443.0
2008-01-01 23:20:00 147763600.0 40542172.0 9156847.0
2008-01-01 23:30:00 147756496.0 40559700.0 9165252.0
2008-01-01 23:40:00 147749408.0 40577232.0 9173656.0
2008-01-01 23:50:00 147742304.0 40594760.0 9182060.0

144 rows × 3 columns

[6]:
# With String as product
ace_product_str = 'cdpp3dview/ACE'
spz.get_data(ace_product_str, '2008-1-1', '2008-1-2')
[6]:
SpeasyVariable(
    Name: 'pos',
    Time Range: 2008-01-01T00:00:00.000000000 - 2008-01-01T23:50:00.000000000
    Shape: (144, 3),
    Unit: 'km',
    Columns: ['x', 'y', 'z'],
    Meta: {
        CATDESC: 'position in J2000 frame',
        DISPLAY_TYPE: 'time_series',
        FIELDNAM: 'Position',
        UNITS: 'km',
        VAR_TYPE: 'data',
        DEPEND_0: 'Epoch',
        LABL_PTR_1: ['x', 'y', 'z'],
        },
    Size: '3.5 kB',
    )

get_data() with coordinate_frame as additionnal parameter

raise Exception if frame not available

[7]:
spz.get_data(ace_product_str, '2008-1-1', '2008-1-2', coordinate_frame="HEEQ")
[7]:
SpeasyVariable(
    Name: 'pos',
    Time Range: 2008-01-01T00:00:00.000000000 - 2008-01-01T23:50:00.000000000
    Shape: (144, 3),
    Unit: 'km',
    Columns: ['x', 'y', 'z'],
    Meta: {
        CATDESC: 'position in HEEQ frame',
        DISPLAY_TYPE: 'time_series',
        FIELDNAM: 'Position',
        UNITS: 'km',
        VAR_TYPE: 'data',
        DEPEND_0: 'Epoch',
        LABL_PTR_1: ['x', 'y', 'z'],
        },
    Size: '3.5 kB',
    )
[8]:
from speasy.data_providers.cdpp3dview import Cdpp3dViewWebException
from sys import stderr
# with no such frame raises exception , show available frames
try:
    spz.get_data(ace_product_str, '2008-1-1', '2008-1-2', coordinate_frame="HEEY")
except Cdpp3dViewWebException as e:
    print("ERROR IN ARGUMENTS", file=stderr)
    print(str(e), file=stderr)
ERROR IN ARGUMENTS
Coordinate frame 'HEEY' is not available.
Available frames are: ['J2000', 'ECLIPJ2000', 'HEE', 'HEEQ', 'HCI', 'IAU_SUN', 'MESO', 'MEME', 'MECLIP', 'MESE', 'MESEQ', 'IAU_MERCURY', 'VSO', 'VME', 'IAU_VENUS', 'GSE', 'EME', 'GSEQ', 'ECLIPDATE', 'MAG', 'GSM', 'SM', 'IAU_EARTH', 'LSE', 'LME', 'IAU_MOON', 'MSO', 'MME', 'IAU_MARS', 'PSE', 'PME', 'DSE', 'DME', 'JSO', 'JEME', 'JECLIP', 'JSM', 'SYSTEM_3', 'IAU_JUPITER', 'IPHIO', 'EPHIO', 'GPHIO', 'CPHIO', 'KSO', 'KEME', 'KECLIP', 'KSM', 'IAU_SATURN', 'MIIS', 'ENIS', 'TEIS', 'DIIS', 'RHIS', 'TIIS', 'UEME', 'UECLIP', 'USO', 'IAU_URANUS', 'NEME', 'NECLIP', 'NSO', 'IAU_NEPTUNE', 'PEME', 'PECLIP', 'PSO', 'IAU_PLUTO', '67PCG_EME', '67PCG_CSO', 'LUTETIA_EME', 'LUTETIA_CSO', 'STEINS_EME', 'STEINS_CSO', 'HALLEY_EME', 'HALLEY_CSO', 'GRIGGSKELL_EME', 'GRIGGSKELL_CSO', 'IAU_DIDYMOS', 'DIDYMOS_EME', 'DIDYMOS_CSO']

What if wrong date_range

[9]:
spz.get_data(ace_product_str, '1900-1-1', '1900-1-2')
You are requesting ACE outside of its definition range <DateTimeRange: 1997-08-26T17:48:00+00:00 -> 2026-03-22T17:49:00+00:00>

Request other sampling than default ‘600’

[10]:
# with default 600
spz.get_data(ace_product_str, '2008-01-01T12:00:00', '2008-01-01T13:00:00').to_dataframe().head()
[10]:
x y z
2008-01-01 12:00:00 -26201596.0 131450416.0 57144592.0
2008-01-01 12:10:00 -26219240.0 131447448.0 57143312.0
2008-01-01 12:20:00 -26236884.0 131444472.0 57142032.0
2008-01-01 12:30:00 -26254528.0 131441496.0 57140748.0
2008-01-01 12:40:00 -26272170.0 131438520.0 57139468.0
[11]:
# with sampling = one minute
spz.get_data(ace_product_str, '2008-01-01T12:00:00', '2008-01-01T13:00:00', sampling='60').to_dataframe().head()
[11]:
x y z
2008-01-01 12:00:00 -26201596.0 131450416.0 57144592.0
2008-01-01 12:01:00 -26203360.0 131450120.0 57144464.0
2008-01-01 12:02:00 -26205124.0 131449824.0 57144336.0
2008-01-01 12:03:00 -26206890.0 131449528.0 57144208.0
2008-01-01 12:04:00 -26208654.0 131449232.0 57144080.0

Other utilities

[12]:
[12]:
<DateTimeRange: 1972-03-05T12:00:00+00:00 -> 2049-12-31T00:00:00+00:00>

A Simple Example with MEX trajectory in frame MSO

[13]:
plt.figure()
mex_parameter = spz.inventories.tree.cdpp3dview.Trajectories.SPACECRAFT.MEX
mex_traj = spz.get_data(mex_parameter, '20200102', '20200103', coordinate_frame="MSO", sampling=60)
mex_traj.plot()
plt.tight_layout()
plt.show()
../_images/examples_Cdpp3dView_25_0.png