KCollins / magplots

A python library to pull data and make plots from ground magnetometers. Emphasis on plots for comparing magnetometers at conjugate points.
MIT License
0 stars 1 forks source link

BUG: Verify dynamic pressure code #23

Open KCollins opened 6 months ago

KCollins commented 6 months ago

Validate dynamic pressure calculations.

should be: inst_val - inst_val/(min_before + min_after)

KCollins commented 4 months ago

Relevant code snippet - got this from Xueling:

            mom_vars = pyspedas.mms.mom(probe=[spacecraft_id.lower()], trange=[start.timestamp(), end.timestamp()],
            # mom_vars = pyspedas.mms.mom(probe=[spacecraft_id.lower()], trange=[epoch.timestamp()-5*60, epoch.timestamp()+5*60],
                                   notplot=True,no_update=False,time_clip=True)

            thx_density = mom_vars['th'+spacecraft_id.lower()+'_peem_density']
            thx_density_time = thx_density['x']
            thx_density_data = thx_density['y']

            #calculate dynamic pressure
            thx_peim_velocity = mom_vars['th'+spacecraft_id.lower()+'_peim_velocity_gse']
            thx_velocity_data = thx_peim_velocity['y']

            thx_velocity_Vx = thx_velocity_data[:,0]
            thx_velocity_Vy = thx_velocity_data[:,1]
            thx_velocity_Vz = thx_velocity_data[:,2]

            print("Computing dynamic pressure for event ", event, " out of ", len(mms_events), ".")
            thx_pdy = thx_density_data*(thx_velocity_Vx**2+thx_velocity_Vy**2+thx_velocity_Vz**2)*1.67*(10**(-6))*0.5 # should return nPa

            dyp = thx_pdy[~pd.isnull(thx_pdy)] # dynamic pressure vector without NaNs

            mms_events.loc[epoch, 'Dynamic Pressure (nPa)'] = dyp.max()
            mms_events.loc[epoch, 'Electron density'] = thx_density_data[np.argmax(dyp)]        
            mms_events.loc[epoch, 'Vx'] = thx_velocity_Vx[np.argmax(dyp)]
            mms_events.loc[epoch, 'Vy'] = thx_velocity_Vy[np.argmax(dyp)]
            mms_events.loc[epoch, 'Vz'] = thx_velocity_Vz[np.argmax(dyp)]
KCollins commented 4 months ago

THEMIS computations: https://doi.org/10.5281/zenodo.10531587

KCollins commented 4 months ago

Sanity check: Dynamic pressure should be on the order of 1-10 nPa, but could peak much higher - 100 might be reasonable. Review survey plots with Mike to confirm that the resulting estimates are in the right ballpark. Check Wang paper, Hietala, etc. as well for points of comparison.

KCollins commented 4 months ago

Reference: Try comparing to Fig 2 of https://angeo.copernicus.org/articles/38/287/2020/#&gid=1&pid=1