How to measure the shock normal and angle¶

In [1]:
import sys
from datetime import datetime
from rich.console import Console
console = Console(highlight=False)#,force_jupyter=False,width=999)


from cdasws.cdasws import CdasWs, TimeInterval
from cdasws.datarepresentation import DataRepresentation as dr
from cdasws.doi import get_doi_landing_page_url, get_doi_badge_url, get_doi_hdp_url

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

from IPython.core.display import HTML

today = datetime.now().strftime('%Y-%B-%d')

cdas = CdasWs()

def display_link(
    url: str,
    text: str) -> None:
    display(HTML(f'<a href="{url}" target="_blank">{text}</a>'))

def display_image_link(
    url: str,
    image_url: str) -> None:
    display(HTML(f'<a href="{url}" target="_blank"><img src={image_url}/></a>'))
    

# Injects CSS to target the notebook's standard output stream container
display(HTML('''
<style>
div.output_area pre {
    font-size: 16px !important;
}
</style>
'''))

Read observational data¶

In [2]:
# Fetch all observatory groups
obs_groups = cdas.get_observatory_groups()

# Print the names
print("Observatory -> IDs\n")
for indx, group in enumerate(obs_groups):
    #print("'%s'" %(group['Name']),',', end="")
    print("\033[1;32m%s\033[0m -> %s" %(group['Name'], group['ObservatoryId']))
    #print(f'{group["Name"]}')#"'%s'" %(group['Name']),',', end="")
Observatory -> IDs

ACE -> ['AC', 'ACE', 'OMNI (1AU IP Data)']
AMPTE -> ['AMPTE-CCE']
ARTEMIS -> ['THB', 'THC']
AWE -> ['AWE']
Alouette -> ['Alouette-2']
Apollo -> ['ALSEP']
Arase (ERG) -> ['Arase(ERG)', 'ERG']
Balloons -> ['PMC Turbo', 'bar_1A', 'bar_1B', 'bar_1C', 'bar_1D', 'bar_1G', 'bar_1H', 'bar_1I', 'bar_1J', 'bar_1K', 'bar_1M', 'bar_1N', 'bar_1O', 'bar_1Q', 'bar_1R', 'bar_1S', 'bar_1T', 'bar_1U', 'bar_1V', 'bar_2A', 'bar_2B', 'bar_2C', 'bar_2D', 'bar_2E', 'bar_2F', 'bar_2I', 'bar_2K', 'bar_2L', 'bar_2M', 'bar_2N', 'bar_2O', 'bar_2P', 'bar_2Q', 'bar_2T', 'bar_2W', 'bar_2X', 'bar_2Y', 'bar_3A', 'bar_3B', 'bar_3C', 'bar_3D', 'bar_3E', 'bar_3F', 'bar_3G', 'bar_4A', 'bar_4B', 'bar_4C', 'bar_4D', 'bar_4E', 'bar_4F', 'bar_4G', 'bar_4H', 'bar_5A', 'bar_6A', 'bar_7A']
BioSentinel -> ['BioSentinel']
CNOFS -> ['CNOFS']
CRRES -> ['CRRES Satellite']
Cassini -> ['CASSINI', 'Cassini']
Cluster -> ['C1', 'C2', 'C3', 'C4', 'CL', 'CT']
DMSP -> ['DMSP', 'dmsp', 'dmsp-f12', 'dmsp-f13', 'dmsp-f14', 'dmsp-f15', 'dmsp-f16', 'dmsp-f17', 'dmsp-f18', 'dmsp-f6', 'dmsp-f7', 'dmsp-f8', 'dmsp-f9']
DSCOVR -> ['DSCOVR']
Demonstration and Science Experiments (DSX) -> ['DSX']
Dynamics Explorer -> ['DE', 'DE-1', 'DE-2', 'DE1']
Equator-S -> ['EQ']
FAST -> ['FAST']
Formosat -> ['FS-5', 'ROCSAT-1(FORMOSAT-1)']
GOES -> ['G0', 'G10', 'G12', 'GOES-08', 'GOES-09', 'GOES-10', 'GOES-11', 'GOES-12', 'GOES-13', 'GOES-14', 'GOES-15', 'GOES-16', 'GOES-17', 'GOES-18', 'GOES-19', 'GOES10', 'GOES11', 'GOES12', 'GOES13', 'GOES14', 'GOES15', 'GOES16', 'GOES17', 'GOES18', 'GOES8', 'GOES9', 'GOES_10', 'GOES_11', 'GOES_12', 'GOES_6', 'GOES_7', 'GOES_8', 'GOES_9', 'g11']
GOLD -> ['GOLD']
GPS -> ['GPS']
Genesis -> ['Genesis']
Geosynchronous Investigations -> ['STPSat-6']
Geotail -> ['GEOTAIL']
Ground-Based Investigations -> ['CANOPUS', 'DARN', 'FMI', 'SESAME', 'THG_L2']
Hawkeye -> ['HK']
Helio Ephemeris -> ['BEPICOLOMBO', 'BORRELLY', 'COMETGS', 'COMETHMP', 'DAWN', 'EARTH', 'GALILEO', 'GIACOBINI', 'GIOTTO', 'HALEBOPP', 'HALLEY', 'HYAKUTAKE', 'JUICE', 'JUNO', 'JUPITER', 'MARS', 'MERCURY', 'MOON', 'MSL', 'NEPTUNE', 'PHOBOS2', 'PLUTO', 'PSYCHE', 'ROSETTA', 'SAKIGAKE', 'SATURN', 'SOLAR-1', 'SUISEI', 'URANUS', 'VENUS', 'WILD2']
Helios -> ['HELIOS', 'HELIOS-1', 'HELIOS-2', 'HELIOS1', 'HELIOS2', 'Helios-1', 'Helios-2']
IBEX -> ['IBEX']
ICON -> ['ICON', 'ICON ']
IMAGE -> ['IM', 'IMAGE']
IMAP -> ['IMAP']
IMP (All) -> ['I8', 'IMP-8', 'IMP7', 'IMP8', 'OMNI (1AU IP Data)']
ISEE -> ['ISEE 1', 'ISEE-1', 'ISEE-3', 'ISEE1', 'ISEE2']
ISIS -> ['ISIS-1', 'ISIS-2']
ISS -> ['AWE', 'ISS']
Interball -> ['INTERBALL-AURORAL', 'INTERBALL-GROUND', 'INTERBALL-TAIL']
LANL -> ['L1', 'LANL-97A', 'LANL1989_046', 'LANL1990_095', 'LANL1991_080', 'LANL1994_084', 'Lanl-01A', 'Lanl-02A', 'Lanl-97A', 'Lanl1989_046', 'Lanl1990_095', 'Lanl1991_080', 'Lanl1994_084']
MAVEN -> ['MAVEN']
MESSENGER -> ['MESSENGER']
MMS -> ['MMS1', 'MMS2', 'MMS3', 'MMS4', 'mms1', 'mms2', 'mms3', 'mms4']
Mariner -> ['MARINER2', 'Mariner2']
Mars Global Surveyor (MGS) -> ['MGS']
Mars Science Laboratory (MSL) -> ['MSL']
Moon -> ['BGM1']
NOAA -> ['MetOp1', 'MetOp2', 'MetOp3', 'NOAA05', 'NOAA07', 'NOAA08', 'NOAA10', 'NOAA12', 'NOAA14', 'NOAA15', 'NOAA16', 'NOAA18', 'NOAA19']
New Horizons -> ['NEW_HORIZONS', 'NH']
OMNI (Combined 1AU IP Data; Magnetic and Solar Indices) -> ['OMNI (1AU IP Data)']
POES/MetOp -> ['MetOp1', 'MetOp2', 'MetOp3', 'NOAA15', 'NOAA16', 'NOAA18', 'NOAA19']
Parker Solar Probe (PSP) -> ['PSP', 'PSP_FLD']
Pioneer -> ['PIONEER10', 'PIONEER11', 'Pioneer10', 'Pioneer11', 'Pioneer6', 'Pioneer7', 'PioneerVenus']
Polar -> ['PO', 'POLAR', 'Polar', 'po']
REACH -> ['REACH', 'reach']
SAMPEX -> ['SAMPEX']
SOHO -> ['SOHO']
SOLAR -> ['SOLAR-1']
ST5 -> ['ST5']
STEREO -> ['Ahead', 'Behind', 'STA', 'STB', 'STEREO', 'STEREOA', 'STEREOB', 'sta', 'stb']
Smallsats/Cubesats -> ['CIRBE', 'CSSWE', 'Munin', 'SNOE', 'ac6a', 'ac6b', 'ela', 'elb']
Solar Orbiter -> ['SOLO', 'solo']
Sounding Rockets -> ['Dynamo-2', 'Endurance', 'RENU2', 'TOOWINDY']
THEMIS -> ['THA', 'THB', 'THC', 'THD', 'THE', 'THEMIS', 'THG', 'THG_L1', 'THG_L2']
TIMED -> ['TIMED']
TRACERS -> ['TRACERS1', 'TRACERS2', 'TS1', 'TS2']
TSS-1R -> ['TSS-1R']
TWINS -> ['TWINS-', 'TWINS1', 'TWINS2']
Ulysses -> ['ULYSSES', 'Ulysses']
Van Allen Probes (RBSP) -> ['RBSP', 'RBSP-A', 'RBSP-A-RBSPICE', 'RBSP-B', 'RBSP-B-RBSPICE', 'RBSPA', 'RBSPB', 'rbsp-a', 'rbsp-b', 'rbspa', 'rbspb']
Voyager -> ['VG1', 'VG2', 'VGR-1', 'VGR-2', 'VOYAGER1', 'VOYAGER2', 'Voyager 1', 'Voyager 2', 'Voyager1', 'Voyager2']
Wind -> ['OMNI (1AU IP Data)', 'WI', 'WIND', 'Wi', 'Wind', 'wi']
In [3]:
# Fetch all instrument types
instrument_types = cdas.get_instrument_types()

# print the names
for group in instrument_types:
    print("'%s'" %(group['Name']))
' Particles (space)'
'Activity Indices'
'Dust and Debris'
'Electric Fields (space)'
'Engineering'
'Ephemeris/Attitude/Ancillary'
'Ground-Based HF-Radars'
'Ground-Based Imagers'
'Ground-Based Magnetometers, Riometers, Sounders'
'Ground-Based VLF/ELF/ULF, Photometers'
'Housekeeping'
'Imagers (space)'
'Imaging and Remote Sensing (ITM/Earth)'
'Imaging and Remote Sensing (Magnetosphere/Earth)'
'Imaging and Remote Sensing (Sun)'
'Magnetic Fields (Balloon)'
'Magnetic Fields (space)'
'Particle Flux (space)'
'Particles (space)'
'Plasma and Solar Wind'
'Radio and Plasma Waves (space)'
'Space Weather Monitor'
In [4]:
### user-specified ###
myobservatory=['Wind']
myinstrument =['Plasma and Solar Wind', 'Magnetic Fields (space)']
In [22]:
all_datasets = []
for obs in myobservatory:
    print('for %s' %(obs))
    print('Dataset with the link -> Label')
    datasets = cdas.get_datasets(observatoryGroup=obs,instrumentType=myinstrument)
    if datasets:
        all_datasets.extend(datasets)
        
    lines=[]
    for index, dataset in enumerate(datasets):
        dataset_id = dataset["Id"]
        dataset_label = dataset["Label"]
        dataset_note = dataset['Notes']
        #dataset_note = dataset['DatasetLink']['Url']
        #skt_url = f"https://cdaweb.gsfc.nasa.gov/pub/software/cdawlib/0SKELTABLES/{dataset_id}_00000000_v01.skt"
        #response = requests.get(skt_url)
        #skeleton_table_text = response.text

        #doi_info = dataset["Doi"]
        #
        #if doi_info:
        #    # Generate the landing page metadata URL
        #    metadata_url = get_doi_landing_page_url(doi_info)
        #else:
        #    # Fallback if no DOI info is provided directly in the dataset object
        #    metadata_url = f"https://nasa.gov{dataset_id}"

        #print('\033[1;32m%s\033[0m -> %s, %s' %(dataset_id, dataset_label,dataset_note))#, display_link(metadata_url, 'metadata')))
        #print("'\033[1m%s\033[0m' -> %s" %(dataset_id, dataset_label))#, display_link(metadata_url, 'metadata')))
        #print("%s" %(dataset_note))#, display_link(metadata_url, 'metadata')))
        #print('')
        #display(Markdown('\033[1;32m%s\033[0m -> %s' %(dataset_id, dataset_label)))#, display_link(metadata_url, 'metadata')))
        #print(f'{index}. {dataset_id}, {dataset_label}')
        lines.append("[bold green][link=%s]%s[/link][/] -> %s" %(dataset_note,dataset_id,dataset_label))
    console.print("\n".join(lines),justify='left', soft_wrap=True)

    print('='*100)
    print(' ')
for Wind
Dataset with the link -> Label
OMNI2_H0_MRG1HR -> OMNI Combined, Definitive, Hourly IMF and Plasma Data, and Energetic Proton Fluxes, Time-Shifted to the Nose of the Earth's Bow Shock, plus Solar and Magnetic Indices - J.H. King, N. Papitashvili (ADNET, NASA GSFC)     
OMNI_COHO1HR_MERGED_MAG_PLASMA -> OMNI Combined merged hourly magnetic field, plasma and ephermis data - J.H. King, N. Papatashvilli (AdnetSystems, NASA GSFC)                                                                                
OMNI_HRO2_1MIN -> OMNI Combined, Definitive 1-minute IMF and Definitive Plasma Data Time-Shifted to the Nose of the Earth's Bow Shock, plus Magnetic Indices - J.H. King, N. Papatashvilli (AdnetSystems, NASA GSFC)                          
OMNI_HRO2_5MIN -> OMNI Combined, Definitive 5-minute IMF and Definitive Plasma, and Energetic Proton Fluxes, Time-Shifted to the Nose  of the Earth's Bow Shock, plus Magnetic Indices - J.H. King, N. Papatashvilli (AdnetSystems, NASA GSFC)
OMNI_HRO_1MIN -> OMNI Combined, Definitive, 1-minute IMF and Plasma Data Time-Shifted to the Nose of the Earth's Bow Shock, plus Magnetic Indices - J.H. King, N. Papatashvilli (AdnetSystems, NASA GSFC)                                     
OMNI_HRO_5MIN -> OMNI Combined, Definitive, 5-minute IMF and Plasma, and Energetic Proton Fluxes, Time-Shifted to the Nose  of the Earth's Bow Shock, plus Magnetic Indices - J.H. King, N. Papatashvilli (AdnetSystems, NASA GSFC)           
WIND_3DP_ECHSFITS_E0-YR -> Wind spacecraft, 3DP accurate electron parameters - Chadi S. Salem (University of California, Berkeley)                                                                                                            
WI_ELM2_3DP -> Electron Moments (ground-computed), EESA Low, Wind 3DP - R. Lin/S. Bale (UC Berkeley)                                                                                                                                          
WI_EMFITS_E0_3DP -> Wind spacecraft, 3DP electron moments - Stuart D. Bale (University of California, Berkeley)                                                                                                                               
WI_EM_3DP -> Electron Plasma moments (computed on-board) (NOT CORRECTED FOR S/C POTENTIAL) @ 3 second (spin) resolution (version 3), EESA LOW, Wind 3DP - R. Lin/S. Bale (UC Berkeley)                                                        
WI_H0_MFI -> Wind Magnetic Fields Investigation: 3 sec, 1 min, and hourly Definitive Data. - A. Koval (UMBC, NASA/GSFC)                                                                                                                       
WI_H0_SWE -> Wind SWE (Solar Wind Experiment), 6 - 12 sec Solar Wind Electron Moments - K. Ogilvie (GSFC Code 692)                                                                                                                            
WI_H1_SWE -> Wind Solar Wind Experiment, 92-sec Solar Wind Alpha and Proton Anisotropy Analysis - K. Ogilvie (NASA GSFC)                                                                                                                      
WI_H1_SWE_RTN -> Solar wind proton and alpha parameters, including anisotropic temperatures, derived by non-linear fitting of the measurements and with moment techniques. Data in RTN - Bennett Maruca (University of Delaware)              
WI_H2_MFI -> Wind Magnetic Fields Investigation, High-resolution Definitive Data - A. Koval (UMBC, NASA/GSFC)                                                                                                                                 
WI_H3-RTN_MFI -> Wind Magnetic Fields Investigation: 3 sec, 1 min, and hourly Definitive Data (RTN). - A. Koval (UMBC, NASA/GSFC)                                                                                                             
WI_H3_SWE -> Wind Solar Wind Experiment (SWE), 9 sec solar wind electron pitch-angle distributions at 12 sec cadence - K. Ogilvie (NASA/GSFC)                                                                                                 
WI_H4-RTN_MFI -> Wind Magnetic Fields Investigation, High-resolution Definitive Data (RTN) - A. Koval (UMBC, NASA/GSFC)                                                                                                                       
WI_H4_SWE -> Wind Solar Wind Experiment (SWE), 3 sec solar wind electron pitch-angle distributions at 6-12 sec cadence - K. Ogilvie (NASA/GSFC)                                                                                               
WI_H5_SWE -> Wind Solar Wind Experiment (SWE), 9 sec solar wind electron moments at 12 sec cadence - K. Ogilvie (NASA/GSFC)                                                                                                                   
WI_K0_3DP -> Wind 3-D Plasma Analyzer, Key Parameters [PRELIM] - R. Lin/S. Bale (UC Berkeley)                                                                                                                                                 
WI_K0_GIFWALK -> Links to Wind KP pre-generated survey and other plots - Polar-Wind-Geotail Ground System (NASA GSFC)                                                                                                                         
WI_K0_MFI -> Wind Magnetic Fields Investigation, Key Parameters [PRELIM] - R. Lepping (NASA/GSFC)                                                                                                                                             
WI_K0_SMS -> Solar Wind and Suprathermal Ion Composition  Instrument, Key Parameters [PRELIM] - G. Gloeckler (U of Maryland)                                                                                                                  
WI_K0_SWE -> Wind SWE (Solar Wind Experiment), Key Parameters [PRELIM] - K. Ogilvie (NASA GSFC)                                                                                                                                               
WI_K0_SWE_RTN -> Wind Solar Wind Experiment, Key Parameters in RTN [PRELIM] - Bennett Maruca (University of Delaware)                                                                                                                         
WI_K1-RTN_MFI -> Wind Magnetic Fields Investigation, Key Parameters in RTN [PRELIM] - Andriy Koval (UMBC&GSFC)                                                                                                                                
WI_L2-30MIN_SMS-STICS-AFM-MAGNETOSPHERE -> Solar Wind and Suprathermal Ion Composition  Instrument, Key Parameters - S. T. Lepri (U of Michigan)                                                                                              
WI_L2-30MIN_SMS-STICS-AFM-SOLARWIND -> Solar Wind and Suprathermal Ion Composition  Instrument, Key Parameters - S. T. Lepri (U of Michigan)                                                                                                  
WI_L2-30MIN_SMS-STICS-ERPA-MAGNETOSPHERE -> Magnetosphere and Suprathermal Ion Composition  Instrument, Key Parameters - S. T. Lepri (U of Michigan)                                                                                          
WI_L2-30MIN_SMS-STICS-ERPA-SOLARWIND -> Solar Wind and Suprathermal Ion Composition  Instrument, Key Parameters - S. T. Lepri (U of Michigan)                                                                                                 
WI_L2-3MIN_SMS-STICS-VDF-MAGNETOSPHERE -> Magnetosphere and Suprathermal Ion Composition  Instrument, Key Parameters - S. T. Lepri (U of Michigan)                                                                                            
WI_L2-3MIN_SMS-STICS-VDF-SOLARWIND -> Solar Wind and Suprathermal Ion Composition Instrument, Key Parameters - S. T. Lepri (U of Michigan)                                                                                                    
WI_L2_3MIN_SMS-STICS-NVT-MAGNETOSPHERE -> Solar Wind and Suprathermal Ion Composition  Instrument, Key Parameters - S. T. Lepri (U of Michigan)                                                                                               
WI_L2_3MIN_SMS-STICS-NVT-SOLARWIND -> Solar Wind and Suprathermal Ion Composition  Instrument, Key Parameters - S. T. Lepri (U of Michigan)                                                                                                   
WI_M0_SWE -> Wind Solar Wind Experiment (SWE), 9 sec solar wind electron pitch-angle distribution averages - K. Ogilvie (NASA/GSFC)                                                                                                           
WI_M2_SWE -> Wind Solar Wind Experiment (SWE), 3 sec solar wind electron pitch-angle distribution averages - K. Ogilvie (NASA/GSFC)                                                                                                           
WI_PLSP_3DP -> Ion omnidirectional fluxes 0.4-3 keV and moments, often at ~24 second resolution, PESA Low, Wind 3DP - R. Lin/S. Bale (UC Berkeley)                                                                                            
WI_PM_3DP ->  Ion moments (computed on-board) @ 3 second (spin) resolution, PESA LOW, Wind 3DP - R. Lin/S. Bale (UC Berkeley)                                                                                                                 
WI_STRAHL0_SWE -> Wind Solar Wind Experiment (SWE) strahl detector, ~1/2 sec solar wind electron pitch-angle distributions at ~12 sec cadence - K. Ogilvie (NASA/GSFC)                                                                        
WI_SW-ION-DIST_SWE-FARADAY -> Faraday Cup orientation and charge flux - Keith Ogilvie (NASA GSFC)                                                                                                                                             
====================================================================================================
 
In [6]:
### user-specified ###
mydataset=['WI_H0_MFI','WI_PM_3DP'] #the order should be consistent with the list above.
In [7]:
mydois=[]
for index, dataset in enumerate(all_datasets):
    dataset_id = dataset["Id"]
    dataset_label = dataset["Label"]

    if dataset_id in mydataset:  # select this dataset for use below
        doi=dataset['Doi']
        #print(doi)
        mydois.append(dataset['Doi'])
        print(f'\nSelected dataset: {dataset_id} (doi:{doi})')
        print(f"Available Period: {dataset['TimeInterval']}")
        display_image_link(get_doi_landing_page_url(doi), get_doi_badge_url(doi))
        display_link(get_doi_hdp_url(doi), 'HDP Description')
        display_link(dataset['Notes'], 'CDAWeb Notes')
        display(HTML(f'<b>Data Citation</b>: {cdas.get_citation(doi)}.  Accessed on {today}.'))
        print('='*100)
        print(' ')
Selected dataset: WI_H0_MFI (doi:10.48322/av38-wn55)
Available Period: {'Start': '1994-11-13T00:00:30.000Z', 'End': '2026-09-12T23:59:30.000Z'}
HDP Description
CDAWeb Notes
Data Citation: Koval, A., Lepping, R. P., & & Szabo, A. (2021). Wind Magnetic Field Investigation (MFI) Composite Data [Dataset]. Space Physics Data Facility. https://doi.org/10.48322/AV38-WN55. Accessed on 2026-September-23.
====================================================================================================
 

Selected dataset: WI_PM_3DP (doi:10.48322/s8e6-aw08)
Available Period: {'Start': '1994-11-15T12:53:43.000Z', 'End': '2026-09-01T23:59:58.000Z'}
HDP Description
CDAWeb Notes
Data Citation: Lin, R. P., Bale, S. D., & & Wilson III, L. B. (2021). Wind 3DP PESA Moments Data [Dataset]. Space Physics Data Facility; University of California, Berkeley. https://doi.org/10.48322/S8E6-AW08. Accessed on 2026-September-23.
====================================================================================================
 
In [9]:
for indx,mydoi in enumerate(mydois):
    print('for %s' %(mydataset[indx]))
    variables = cdas.get_variables(mydoi)
    var_names = []
    for index, variable in enumerate(variables):
        name = variable['Name']
        var_names.append(name)
        print("'%s'" %(variable['Name']),"->", variable['LongDescription'])
    #    print(f'{index}. {name}, {variable["LongDescription"]}')
    print('='*100)
    print(' ')
for WI_H0_MFI
'BF1' -> Magnetic field magnitude (1 min)
'BF1LOG' -> Magnetic field magnitude (1 min - log scaled)
'BRMSF1' -> RMS magnitude (1 min)
'BGSM' -> Magnetic field vector in GSM cartesian coordinates (1 min)
'BRMSGSM' -> RMS vector in GSM coordinates (1 min)
'BGSE' -> Magnetic field vector in GSE cartesian coordinates (1 min)
'BGSEa' -> Magnetic field vector in GSE angular coordinates (1 min)
'BRMSGSE' -> RMS vector in GSE coordinates (1 min)
'DIST' -> Distance from the center of the earth (Define Re = 6378km) (1 min)
'PGSM' -> Position vector in GSM coordinates (Define Re = 6378km) (1 min)
'PGSE' -> Position vector in GSE coordinates (Define Re = 6378km) (1 min)
'B3F1' -> Magnetic field magnitude (3 sec)
'B3F1LOG' -> Magnetic field magnitude (3 sec - log scaled)
'B3RMSF1' -> RMS magnitude (3 sec)
'B3GSM' -> Magnetic field vector in GSM cartesian coordinates (3 sec)
'B3RMSGSM' -> RMS vector in GSM coordinates (3 sec)
'B3GSE' -> Magnetic field vector in GSE cartesian coordinates (3 sec)
'B3GSEa' -> Magnetic field vector in GSE angular coordinates (3 sec)
'B3RMSGSE' -> RMS vector in GSE coordinates (3 sec)
'B1F1' -> Magnetic field magnitude (1 hour)
'B1F1LOG' -> Magnetic field magnitude (1 hour - log scaled)
'B1RMSF1' -> RMS magnitude (1 hour)
'B1GSM' -> Magnetic field vector in GSM cartesian coordinates (1 hour)
'B1RMSGSM' -> RMS vector in GSM coordinates (1 hour)
'B1GSE' -> Magnetic field vector in GSE cartesian coordinates (1 hour)
'B1GSEa' -> Magnetic field vector in GSE angular coordinates (1 hour)
'B1RMSGSE' -> RMS vector in GSE coordinates (1 hour)
'DIST1' -> Distance from the center of the earth (Define Re = 6378km) (1 hour)
'P1GSM' -> Position vector in GSM coordinates (Define Re = 6378km) (1 hour)
'P1GSE' -> Position vector in GSE coordinates (Define Re = 6378km) (1 hour)
'DISTV' -> Time axis label: Distance from the center of the earth (Define Re = 6378km) (1 min)
'PGSMV' -> Time axis label: Position vector in GSM coordinates (Define Re = 6378km) (1 min)
'PGSEV' -> Time axis label: Position vector in GSE coordinates (Define Re = 6378km) (1 min)
'DIST1V' -> Time axis label: Distance from the center of the earth (Define Re = 6378km) (1 hour)
'P1GSMV' -> Time axis label: Position vector in GSM coordinates (Define Re = 6378km) (1 hour)
'P1GSEV' -> Time axis label: Position vector in GSE coordinates (Define Re = 6378km) (1 hour)
====================================================================================================
 
for WI_PM_3DP
'P_DENS' -> Proton number density [values fill-noisy 5/19/2009-5/11/2010; 3/8-5/15/2012] 
'P_VELS' -> ---> Proton velocity vector (GSE)
'P_TENS' -> ---> Residual Variance in Proton Velocity (6 components in instrument coords)
'P_TEMP' -> ---> Proton temperature
'A_DENS' -> Alpha number density [values fill-noisy 5/19/2009-5/11/2010; 3/8-5/15/2012]
'A_VELS' -> ---> Alpha velocity vector (GSE)
'A_TENS' -> ---> Residual Variance in Alpha Velocity (6 components in instrument coords)
'A_TEMP' -> ---> Alpha temperature
'E_RANGE' -> Energy range of moments computation
'GAP' -> Gap flag (0=no gap, 1=gap)
'VALID' -> Data quality flag (1=good, 0=bad)
'TIME' -> Unix Time (since 1970/01/01)
====================================================================================================
 
In [10]:
print(mydataset)
['WI_H0_MFI', 'WI_PM_3DP']
In [11]:
# assign parameteprs
#dataset_id = 'AC_H0_SWE'
myvariables  = {}
mystart_time = {}
myend_time   = {}

### user-specified ###
myvariables[mydataset[0]]=['B3F1','B3GSE']
myvariables[mydataset[1]]=['P_DENS', 'P_VELS']
mystart_time[mydataset[0]] = '2020-04-20T01:00:00Z'
mystart_time[mydataset[1]] = '2020-04-20T01:00:00Z'
myend_time[mydataset[0]]   = '2020-04-20T02:00:00Z'
myend_time[mydataset[1]]   = '2020-04-20T02:00:00Z'
#######################


# request the data representation as Spacepy
data={}
for dataset in mydataset:
    print(dataset)
    status, data[dataset] = cdas.get_data(dataset, myvariables[dataset], mystart_time[dataset], myend_time[dataset], dataRepresentation = dr.XARRAY)
    if status['http']['status_code'] == 200:
        print('Donwload Success!')
    else:
        print(f"Error! HTTP Status Code: {status}")
WI_H0_MFI
Donwload Success!
WI_PM_3DP
Donwload Success!
In [12]:
for dataset in mydataset:
    keys=list(data[dataset].indexes.keys())
    data[dataset] = data[dataset].rename({keys[0]: "time"})
In [13]:
for dataset in mydataset:
    print('For %s' %(dataset))
    print(data[dataset].keys())
    print('='*100)
    print(' ')
For WI_H0_MFI
KeysView(<xarray.Dataset>
Dimensions:    (time: 1200, cartesian: 3)
Coordinates:
  * time       (time) datetime64[ns] 2020-04-20T01:00:01.500000 ... 2020-04-2...
  * cartesian  (cartesian) <U11 'x-component' 'y-component' 'z-component'
    metavar0   (cartesian) <U8 'Bx (GSE)' 'By (GSE)' 'Bz (GSE)'
Data variables:
    B3F1       (time) float32 2.709 2.7 2.69 2.704 ... 6.943 6.906 6.909 7.017
    B3GSE      (time, cartesian) float32 -1.294 2.025 -1.248 ... 6.642 -1.791
Attributes: (12/35)
    Project:                     ['ISTP>International Solar-Terrestrial Physi...
    Discipline:                  ['Space Physics>Heliospheric Science']
    Source_name:                 ['WIND>Wind Interplanetary Plasma Laboratory']
    Software_version:            ['V05.00']
    Data_type:                   ['H0>3 sec, 1 min, and hourly Definitive Data']
    Descriptor:                  ['MFI>Magnetic Fields Investigation']
    ...                          ...
    Mission_group:               ['Wind', '!___Interplanetary Data near 1 AU']
    Web_sites:                   ['http://wind.nasa.gov']
    spase_DatasetResourceID:     ['spase://NASA/NumericalData/Wind/MFI/PT03S']
    DOI:                         ['https://doi.org/10.48322/av38-wn55']
    CDAWEB_PARENTS:              ['wi_h0_mfi_00000000_v01', 'wi_h0_mfi_202004...
    PARENTS:                     ['wi_h0_mfi_00000000_v01', 'wi_h0_mfi_202004...)
====================================================================================================
 
For WI_PM_3DP
KeysView(<xarray.Dataset>
Dimensions:   (time: 1160, dim0: 3)
Coordinates:
  * time      (time) datetime64[ns] 2020-04-20T01:00:02.681000 ... 2020-04-20...
Dimensions without coordinates: dim0
Data variables:
    P_DENS    (time) float32 3.079 3.071 3.092 3.083 ... 7.392 7.741 8.153 7.769
    P_VELS    (time, dim0) float32 -297.4 15.06 -4.164 ... -342.3 10.64 13.4
    metavar0  (dim0) <U15 'VXGSE_Protn_s/c' 'VYGSE_Protn_s/c' 'VZGSE_Protn_s/c'
Attributes: (12/24)
    Data_type:                   ['PM>PESA (On-Board) Ion Moments @ Spin Reso...
    Discipline:                  ['Space Physics>Interplanetary Studies']
    Source_name:                 ['WIND>Wind Interplanetary Plasma Laboratory']
    Logical_source_description:  ['DERIVED FROM: Ion moments (computed on-boa...
    Project:                     ['ISTP>International Solar-Terrestrial Physi...
    TEXT:                        ['CDAWeb interface derived data on Wed Sep 2...
    ...                          ...
    Logical_file_id:             ['wi_pms_3dp_20200420010002_20200420015957_c...
    Alt_logical_source:          ['Wind_3DP_Ion-Moments-Onboard-PM_3sec_cdf']
    spase_DatasetResourceID:     ['spase://NASA/NumericalData/Wind/3DP/PM/PT0...
    DOI:                         ['https://doi.org/10.48322/s8e6-aw08']
    CDAWEB_PARENTS:              ['wi_pm_3dp_00000000_v01', 'wi_pm_3dp_202004...
    PARENTS:                     ['wi_pm_3dp_00000000_v01', 'wi_pm_3dp_202004...)
====================================================================================================
 
In [14]:
plt.figure(figsize=(20,5))
plt.plot(data['WI_PM_3DP']['time'],data['WI_PM_3DP']['P_DENS'])
plt.ylabel('proton density [cm$^{-3}$]')
#plt.xlim('1998-02-04T00:00:00Z','1998-02-10T00:00:00Z')
plt.ylim(0,10)
plt.show()

plt.figure(figsize=(20,5))
plt.plot(data['WI_PM_3DP']['time'],data['WI_PM_3DP']['P_VELS'][:,0])
plt.plot(data['WI_PM_3DP']['time'],data['WI_PM_3DP']['P_VELS'][:,1])
plt.plot(data['WI_PM_3DP']['time'],data['WI_PM_3DP']['P_VELS'][:,2])
plt.ylabel('solar wind speed [km/s]')
#plt.xlim('1998-02-04T00:00:00Z','1998-02-10T00:00:00Z')
plt.ylim(-400,100)
plt.show()

plt.figure(figsize=(20,5))
plt.plot(data['WI_H0_MFI']['time'],data['WI_H0_MFI']['B3GSE'][:,0])
plt.plot(data['WI_H0_MFI']['time'],data['WI_H0_MFI']['B3GSE'][:,1])
plt.plot(data['WI_H0_MFI']['time'],data['WI_H0_MFI']['B3GSE'][:,2])
plt.ylabel('magnetic fields [nT]')
#plt.xlim('1998-02-04T00:00:00Z','1998-02-10T00:00:00Z')
plt.ylim(-5,8)
plt.show()
plt.show()

How to measure the shock normal¶

First method¶

$${{\mathbf{\hat n}}_{MC}} = \pm \frac{{\left( {{{\mathbf{B}}_d} \times {{\mathbf{B}}_u}} \right) \times \Delta {\mathbf{B}}}}{{\left| {\left( {{{\mathbf{B}}_d} \times {{\mathbf{B}}_u}} \right) \times \Delta {\mathbf{B}}} \right|}}$$$$\Delta {\mathbf{B}} \equiv {{\mathbf{B}}_d} - {{\mathbf{B}}_u}$$
In [15]:
start1 = datetime(2020, 4, 20, 1,15, 0)
end1   = datetime(2020, 4, 20, 1,30, 0)

start2 = datetime(2020, 4, 20, 1,35, 0)
end2   = datetime(2020, 4, 20, 1,50, 0)
In [16]:
bu=np.zeros(3)
bd=np.zeros(3)

bu[0]=data['WI_H0_MFI']['B3GSE'][:,0].sel(time=slice(start1, end1)).mean()
bu[1]=data['WI_H0_MFI']['B3GSE'][:,1].sel(time=slice(start1, end1)).mean()
bu[2]=data['WI_H0_MFI']['B3GSE'][:,2].sel(time=slice(start1, end1)).mean()

bd[0]=data['WI_H0_MFI']['B3GSE'][:,0].sel(time=slice(start2, end2)).mean()
bd[1]=data['WI_H0_MFI']['B3GSE'][:,1].sel(time=slice(start2, end2)).mean()
bd[2]=data['WI_H0_MFI']['B3GSE'][:,2].sel(time=slice(start2, end2)).mean()

db=bd-bu

print(bu)
print(bd)

bdu  =np.cross(bd,bu)

nMC=np.cross(bdu,db)/np.linalg.norm(np.cross(bdu,db))
thMC=np.arccos(np.dot(nMC,bu)/np.linalg.norm(bu))

print(r'n_MC=',nMC)
print('theta_Bn=',thMC/np.pi*180,'[deg]')
[-1.43323278  2.20050669 -1.30589521]
[-2.04123449  5.2160573  -2.97722292]
n_MC= [-0.98181959 -0.1891503   0.01588897]
theta_Bn= 70.68254542019766 [deg]

Second method¶

$${{\mathbf{\hat n}}_{VC}} = \pm \frac{{{\mathbf{V}}_d^{arb} - {\mathbf{V}}_u^{arb}}}{{\left| {{\mathbf{V}}_d^{arb} - {\mathbf{V}}_u^{arb}} \right|}}$$
In [17]:
vu=np.zeros(3)
vd=np.zeros(3)

vu[0]=data['WI_PM_3DP']['P_VELS'][:,0].sel(time=slice(start1, end1)).mean()
vu[1]=data['WI_PM_3DP']['P_VELS'][:,1].sel(time=slice(start1, end1)).mean()
vu[2]=data['WI_PM_3DP']['P_VELS'][:,2].sel(time=slice(start1, end1)).mean()

vd[0]=data['WI_PM_3DP']['P_VELS'][:,0].sel(time=slice(start2, end2)).mean()
vd[1]=data['WI_PM_3DP']['P_VELS'][:,1].sel(time=slice(start2, end2)).mean()
vd[2]=data['WI_PM_3DP']['P_VELS'][:,2].sel(time=slice(start2, end2)).mean()

print(vu)
print(vd)

dv=vd-vu

nVC=dv/np.linalg.norm(dv)

thVC=np.arccos(np.dot(nVC,bu)/np.linalg.norm(bu))
print('n_VC=',nVC)
print('theta_Bn=',thVC/np.pi*180,'[deg]')
[-300.08987427   13.55319977  -11.16703892]
[-345.18002319   11.86909676    9.50288296]
n_VC= [-0.90851381 -0.03393271  0.41647477]
theta_Bn= 76.52200957409623 [deg]

Third Method¶

\begin{gathered} {{{\mathbf{\hat n}}}_{MX1}} = \pm \frac{{\left( {{{\mathbf{B}}_u} \times \Delta {{\mathbf{V}}^{arb}}} \right) \times \Delta {\mathbf{B}}}}{{\left| {\left( {{{\mathbf{B}}_u} \times \Delta {{\mathbf{V}}^{arb}}} \right) \times \Delta {\mathbf{B}}} \right|}}; \hfill \\ {{{\mathbf{\hat n}}}_{MX2}} = \pm \frac{{\left( {{{\mathbf{B}}_d} \times \Delta {{\mathbf{V}}^{arb}}} \right) \times \Delta {\mathbf{B}}}}{{\left| {\left( {{{\mathbf{B}}_d} \times \Delta {{\mathbf{V}}^{arb}}} \right) \times \Delta {\mathbf{B}}} \right|}}; \hfill \\ {{{\mathbf{\hat n}}}_{MX3}} = \pm \frac{{\left( {\Delta {\mathbf{B}} \times \Delta {{\mathbf{V}}^{arb}}} \right) \times \Delta {\mathbf{B}}}}{{\left| {\left( {\Delta {\mathbf{B}} \times \Delta {{\mathbf{V}}^{arb}}} \right) \times \Delta {\mathbf{B}}} \right|}} \hfill \\ \end{gathered}
In [18]:
x=np.cross(bu,dv)
nMX1=np.cross(x,db)/np.linalg.norm(np.cross(x,db))
thMX1=np.arccos(np.dot(nMX1,bu)/np.linalg.norm(bu))

print('n_MX1=',nMX1)
print('theta_Bn=',thMX1/np.pi*180,'[deg]')
n_MX1= [-0.92643929  0.02150761  0.37582931]
theta_Bn= 72.45073076740518 [deg]
In [19]:
x=np.cross(bd,dv)
nMX2=np.cross(x,db)/np.linalg.norm(np.cross(x,db))
thMX2=np.arccos(np.dot(nMX2,bu)/np.linalg.norm(bu))

print('n_MX2=',nMX2)
print('theta_Bn=',thMX2/np.pi*180,'[deg]')
n_MX2= [-0.92454879  0.02435794  0.3802844 ]
theta_Bn= 72.49693265510633 [deg]
In [20]:
x=np.cross(db,dv)
nMX3=np.cross(x,db)/np.linalg.norm(np.cross(x,db))
thMX3=np.arccos(np.dot(nMX3,bu)/np.linalg.norm(bu))

print('n_MX3=',nMX3)
print('theta_Bn=',thMX3/np.pi*180,'[deg]')
n_MX3= [-0.92299933  0.02666139  0.38387681]
theta_Bn= 72.53468690293361 [deg]

How to measure a shock speed¶

$$V_{sh}=\frac{\Delta(\rho \bf{V}\cdot\bf{n}_{sh})}{\Delta (\rho)}$$


$\bf{n}_{sh}$ is the shock normal.

In [21]:
npu=data['WI_PM_3DP']['P_DENS'][()].sel(time=slice(start1, end1)).mean().item()
npd=data['WI_PM_3DP']['P_DENS'][()].sel(time=slice(start2, end2)).mean().item()


Vun=np.dot(nMX1,vu)
Vdn=np.dot(nMX1,vd)

Vsh=(npd*Vdn-npu*Vun)/(npd-npu)

print('N_up=',npu, '[cc]')
print('N_dn=',npd, '[cc]')
print('V_up\cdot n_MX1=',Vun, '[km/s]')
print('V_dn\cdot n_MX1=',Vdn, '[km/s]')

print('Shock Speed=', Vsh, '[km/s]')
N_up= 3.0445451736450195 [cc]
N_dn= 7.695343017578125 [cc]
V_up\cdot n_MX1= 274.1096450067491 [km/s]
V_dn\cdot n_MX1= 323.6150718897779 [km/s]
Shock Speed= 356.02273903501305 [km/s]
In [ ]: