pyrfu.pyrf#
Generic routines to build, transform and analyse space plasma time series: time series construction, time conversions, coordinate systems, signal processing, wave analysis, multi-spacecraft methods and plasma parameters.
from pyrfu import pyrf
Time series construction#
Create a time series containing a 0th order tensor |
|
Create a time series containing a 1st order tensor. |
|
Create a time series containing a 2nd order tensor. |
|
Create a time series containing a spectrum |
|
Creates a skymap of the distribution function. |
|
Creates time line in DataArray. |
|
Concatenate two time series along the time axis. |
|
Concatenate two distribution skymaps along the time axis. |
Time series utilities#
Time clip the input (if time interval is TSeries clip between start and stop). |
|
Resample inp to the time line of ref. |
|
Evaluates the input time series at the target time. |
|
Gives the first time of the time series. |
|
Gives the last time of the time series in unix format. |
|
Extends time interval. |
|
Compute time step of the input time series. |
|
Computes the sampling frequency of the input time series. |
|
Finds pairs that are closest to each other in two time series. |
|
Remove repeated elements in DataArray, Dataset or structure data. |
|
Creates a string corresponding to time interval for output plot naming. |
Time format conversions#
Converts CDF epochs to numpy.datetime64 with nanosecond precision. |
|
Transforms datetime to TT2000 string format. |
|
Convert datetime64 in ns units to ISO 8601 time format . |
|
Converts datetime64 to epoch_tt2000 (nanoseconds since J2000). |
|
Converts datetime64 in ns units to unix time. |
|
Convert ISO 8601 time to datetime. |
|
Convert ISO8601 time format to datetime64 in ns units. |
|
Convert ISO 8601 time string into time vector. |
|
Converts time in iso format to unix |
|
Convert time vector into ISO 8601 format YYYY-MM-DDThh:mm:ss.mmmuuunnn. |
|
Convert time in epoch_tt2000 (nanoseconds since J2000) to datetime64 in ns units. |
|
Converts unix time to datetime64 in ns units. |
Vector and tensor operations#
Compute dot product of two fields. |
|
Compute cross product of two fields. |
|
Computes the magnitude of the input field. |
|
Normalizes the input field. |
|
Computes trace of the time series of 2nd order tensors. |
|
Decomposes a vector into par/perp to B components. |
|
Cartesian to spherical coordinate transform. |
|
Computes magnitude, theta and phi angle from column vector xyz (first column is x ....) theta is 0 at equator. |
|
Transform spherical to cartesian coordinates |
|
Calculates the solid angle of three vectors making up a triangle in a unit sphere with the sign taken into account. |
Coordinate systems#
Coordinate transformation GE0/GEI/GSE/GSM/SM/MAG as described in [R93910b019a51-1] |
|
Converts GSE to GSM. |
|
Transform to a field-aligned coordinate (FAC) system. |
|
Transform the input field to the new frame. |
|
Compute the minimum variance frame. |
|
GUI to interactively perform minimum variance analysis (MVA) on time series data by selecting the time interval to apply MVA on. |
|
Put inp into mean field coordinates defined by position vector r and magnetic field b if earth magnetic dipole axis z is given then uses another algorithm (good for auroral passages). |
|
Find E and B in MP system given B and MP normal vector. |
|
Compute spacecraft position L Shell for a dipole magnetic field according to IGRF. |
Filtering and signal processing#
Filters input quantity. |
|
Filter the data through low or highpass filter with max frequency f_cut and subtract from the original. |
|
Applies a median filter over npts points to inp. |
|
Computes running average of the inp over window_size points. |
|
Estimate the mean and wave fields. |
|
Compute the convolution of a time series of N-dimensional data with a N-dimensional kernel. |
|
Integrate time series. |
|
Computes time derivative of the input variable. |
|
Compute the sliding time derivative of a time series using central differences. |
|
Compute the autocorrelation function. |
|
Correlate the derivatives of two time series |
Spectral and wave analysis#
Estimate power spectral density using Welch's method. |
|
Short-Time Fourier Transform. |
|
Computes wavelet spectrogram based on fast FFT algorithm. |
|
Compress the wavelet transform averaging over blocks of nc time steps. |
|
Calculates wavelet spectra of E&B and Poynting flux using wavelets (Morlet wavelet). |
|
Analysis the polarization of magnetic wave using "means" method |
|
Estimates Poynting flux at electric field sampling as |
|
Get propagation direction by matching dBpar and "phi". |
|
Get propagation velocity by matching dBpar and phi. |
Turbulence and intermittency#
Returns the increments of a time series. |
|
Returns the structure function of a time series |
|
Returns the Partial Variance of Increments (PVI) of a time series. |
Multi-spacecraft methods#
Computes the input quantity at the center of mass of the MMS tetrahedron. |
|
Average data from 4 spacecrafts while ignoring NaN values. |
|
Calculates reciprocal vectors in barycentric coordinates. |
|
Calculate gradient of physical field using 4 spacecraft technique in [Ra4e11c05c7b9-2] [Ra4e11c05c7b9-3]. |
|
Calculate the current density using the four spacecraft technique. |
|
Calculates velocity or time shift of discontinuity as in [Rb7b35f387832-6]. |
|
Computes velocity of the structure using spatio-temporal derivative method [Rfdd5e57aa6d8-13] [Rfdd5e57aa6d8-14] as |
|
Compute Pi-D term using definition of [R8b551134d697-1] as : |
|
Compute the Partial Variance of Increments (PVI) using the definition in [R64a80c2671ce-1] as |
Plasma parameters#
Computes plasma parameters including characteristic length and time scales. |
|
Interactive function to calcute plasma paramters. |
|
Computes plasma beta at magnetic field sampling |
|
Computes dynamic pressure. |
|
Computes the convection electric field \(V\times B\) (default) or the \(E\times B/|B|^{2}\) drift velocity (flag="exb"). |
|
Compute Ez under assumption \(\mathbf{E}.\mathbf{B}=0\) or \(\mathbf{E}.\mathbf{B} \approx 0\) |
|
Estimate velocity of the De Hoffman-Teller frame from the velocity estimate the electric field eht=-vht x b |
|
Estimate values for some everyday stuff. |
Pressure tensor, anisotropy and agyrotropy#
Compute pressure anisotropy factor: |
|
Compute the thresholds for temperature anisotropy instabilities based on plasma species and growth rate. |
|
Compute Che's agyrotropy coefficient. |
|
Compute agyrotropy coefficient as |
|
Computes Aunai's agyrotropy coefficient. |
|
Computes agyrotropy coefficient as in [R397062005517-1] |
Velocity distribution functions#
Time averages the velocity distribution functions over n_pts in time. |
|
Integrate a spherical distribution function to a line/plane. |
Shocks and boundaries#
Calculates shock normals with different methods. |
|
Calculate shock related plasma parameters. |
|
Returns the location of magnetopause. |
Statistics and histograms#
Computes 1D histogram of the inp with bins bins |
|
Computes 2d histogram of inp2 vs inp1 with nbins number of bins. |
|
Computes 2D histogram and PDF (Brazil plot style) for plasma data. |
|
Computes mean of values of y corresponding to bins of x. |
|
Computes median of values of y corresponding to bins of x |
|
Estimates the number of bins for 1d histogram that minimizes the risk function in [R10e5c351ffb9-1] , obtained by direct decomposition of the MISE following the method described in [R10e5c351ffb9-2] . |
|
Estimates the number of bins for 2d histogram that minimizes the risk function in [R0adc3d7e4a0c-1] , obtained by direct decomposition of the MISE following the method described in [R0adc3d7e4a0c-2] . |
|
Computes weighted average. |
Data files and external data#
Reads a .cdf file and returns a dictionary with the fields contained in the file. |
|
Downloads OMNI data. |