Manipulating KP Data

Resample

pydivide.resample(kp, time, sc_only=False)[source]

Modifies KP structure index to user specified time via interpolation.

Parameters:
  • kp – struct KP insitu data structure read from file(s).
  • time – list Specifies subset of insitu KP data for resampling. time must be expressed in the format ‘YYYY-MM-DD HH:MM:SS’.

Examples

>>> # Resample insitu time to 2016-06-20 coarse survey 3D file time.
>>> swi_cdf = cdflib.CDF('<dir_path>/mvn_swi_l2_coarsesvy3d_20160620_v01_r00.cdf')
>>> newtime = swi_cdf.varget('time_unix')
>>> insitu_resampled = pydivide.resample(insitu, newtime)
>>> # Resamples an entire day of data to just 3 points
>>> import pytplot
>>>insitu, iuvs = pydivide.read(input_time=['2016-02-18', '2016-02-19'])
>>> x = pydivide.resample(insitu, [pytplot.tplot_utilities.str_to_int('2016-02-18T05:00:00'),
>>>                      pytplot.tplot_utilities.str_to_int('2016-02-18T10:00:00'),
>>>                      pytplot.tplot_utilities.str_to_int('2016-02-18T15:00:00')])

Bin

pydivide.bin(kp, parameter=None, bin_by=None, mins=None, maxs=None, binsize=None, std=False, avg=False, density=False, median=False, unittest=False)[source]

Bins insitu Key Parameters by up to 8 different parameters, specified within the data structure. Necessary that at least one of avg, std, median, or density be specified.

Parameters:
  • kp – struct KP insitu data structure read from file(s).
  • parameter – str Key Parameter to be binned. Only one may be binned at a time.
  • bin_by – int, str Parameters (index or name) by which to bin the specified Key Parameter.
  • binsize – int, list
  • size for each binning dimension. Number of elements must be equal to those in bin_by. (Bin) –
  • mins – int, list Minimum value(s) for each binning scheme. Number of elements must be equal to those in bin_by.
  • maxs – int, list 7 Maximum value(s) for each binning scheme. Number of elements must be equal to those in bin_by.
  • avg – bool Calculate average per bin.
  • std – bool Calculate standard deviation per bin.
  • density – bool Returns number of items in each bin.
  • median – bool Calculate median per bin.
Returns:

This procedures outputs up to 4 arrays to user-defined variables, corresponding to avg, std, median, and density.

Examples: >>> # Bin STATIC O+ characteristic energy by spacecraft latitude (1° resolution) and longitude (2° resolution). >>> output_avg = pydivide.bin(insitu, parameter=’static.oplus_char_energy’, bin_by=[‘spacecraft.geo_latitude’, ‘spacecraft.geo_longitude’], avg=True,binsize=[2,1])

>>> # Bin SWIA H+ density by spacecraft altitude (10km resolution), return average value and standard deviation for each bin.
>>> output_avg,output_std = pydivide.bin(insitu, parameter='swia.hplus_density', bin_by='spacecraft.altitude', binsize=10,avg=True,std=True)