irfpy.vima.scidata_util

IMA science data utility.

See also How to handle IMA science data.

irfpy.vima.scidata_util.getarray2d(t0, t1, emulate_full=False)[source]

Return the irfpy.imacommon.TimeSeriesCntMatrix2D object.

Return the dataset of VEX/IMA counts as irfpy.imacommon.TimeSeriesCntMatrix2D object. corresponding to the time range t0 and t1.

>>> import datetime
>>> t0 = datetime.datetime(2012, 10, 5, 0, 1, 23)
>>> t1 = datetime.datetime(2012, 10, 5, 0, 10, 41)
>>> dataset = getarray2d(t0, t1)
>>> print(dataset)
<TimeSeriesCntMatrix2D:len=48 from 2012-10-05 00:01:16.398080 to 2012-10-05 00:10:40.491880>
irfpy.vima.scidata_util.getarray3d(t0, t1, emulate_full=False)[source]

Get the time series of 3D array (irfpy.imacommon.TimeSeriesCntMatrix) for IMA data.

Parameters
  • t0 – Start of the time.

  • t1 – Stop of the time.

  • emulate_full – Emulates M24, the full mode, if True.

Returns

irfpy.imacommon.TimeSeriesCntMatrix object.

You can get time series of 3D data as:

>>> import datetime
>>> t0 = datetime.datetime(2012, 10, 5, 0 , 0, 23)
>>> t1 = datetime.datetime(2012, 10, 5, 0, 10, 41)
>>> dataset = getarray3d(t0, t1)
>>> print(dataset)
<TimeSeriesCntMatrix:len=4 from 2012-10-05 00:00:16.429320 to 2012-10-05 00:07:40.491860>
>>> t2, d2 = dataset[2]   # Obtain the 2nd 3-D data.
>>> print(t2)
2012-10-05 00:04:28.523100
>>> print(d2.matrix.max())  # Max of the counts
168.0

Here d2 is the irfpy.imacommon.TimeSeriesCntMatrix object.

Note that the first and last 3d data is NOT necessarily bounded. This means that a part of elevation scans for those dataset could be masked. Therefore, it is a user’s responsibility to check the completeness of 3D data. Below is the example. You may realize the first 11 elevation is masked. The time obtained is the time of the returned data: in this case the time at elevation index 11.

>>> t0, d0 = dataset[0]
>>> print(t0)
2012-10-05 00:00:16.429320
>>> print(d0.matrix[31, 15, 95, :])   # M=31, A=15, E=95, and all P is printed.
[-- -- -- -- -- -- -- -- -- -- -- 0.0 0.0 0.0 0.0 0.0]
irfpy.vima.scidata_util.get3d(t, emulate_full=False)[source]

Get the 3-D data at the time of t0.

Parameters
  • t – Time of observation

  • emulate_full – Emulate M24, the full mode, if True

Returns

A tuple, (time_start, VEX/IMA_data), where time_start is the datetime object and VEX/IMA_Data is an object of irf.imacommon.imascipac.CntMatrix.

>>> t = datetime.datetime(2012, 10, 5, 3, 0, 0)
>>> tstart, data = get3d(t)
>>> print(tstart)
2012-10-05 02:57:17.930260
>>> print(data)
<<class 'irfpy.imacommon.imascipac.CntMatrix'>(VEX/IMA)@2012-10-05T02:57:17.930260:MOD=24 >>24<<:CNTmax=248>

The emulate_full option will emulate the collapsed data (mode not 24) to the full matrix data.

>>> t = datetime.datetime(2008, 1, 9, 14, 30, 0)
>>> tstart, data = get3d(t)
>>> print(data)
<<class 'irfpy.imacommon.imascipac.CntMatrix'>(VEX/IMA)@2008-01-09T14:26:51.844060:MOD=25 >>25<<:CNTmax=672>
>>> tstart, data = get3d(t, emulate_full=True)    # Mode 24 emulation is enabled.
>>> print(data)
<<class 'irfpy.imacommon.imascipac.CntMatrix'>(VEX/IMA)@2008-01-09T14:26:51.844060:MOD=24 >>25<<:CNTmax=336>

The returned data is the 3-D data that was obtained at the time right before the given time. It may sometimes really long time back.

>>> t = datetime.datetime(2012, 10, 5, 7, 0, 0)
>>> tstart, data = get3d(t)
>>> print(tstart)
2012-10-05 03:45:06.336740
>>> print(data)
<<class 'irfpy.imacommon.imascipac.CntMatrix'>(VEX/IMA)@2012-10-05T03:45:06.336740:MOD=24 >>24<<:CNTmax=0>
class irfpy.vima.scidata_util.iter3d(t0, t1, emulate_full=False)[source]

Bases: object

An iteration over 3D data for a given time range.

To analyze longer data in one session, it may be a good idea to iterate over the time without loading too much data at once. Memory needed will be so large, first, and it takes much time before starting analysis.

Here comes the use of iter3d functionality.

Below to show an example

>>> t0 = datetime.datetime(2007, 10, 30, 18)
>>> t1 = datetime.datetime(2007, 10, 31, 1)
>>> for dat in iter3d(t0, t1):      # Iteration over t0 and t1   
...     print(dat.t)       # You may put any processing on ``dat`` each by each
2007-10-30 18:00:15.977120
2007-10-30 18:03:27.977140
2007-10-30 18:06:40.070920
...
2007-10-31 00:54:27.480320
2007-10-31 00:57:39.574080
>>> datlist = list(iter3d(t0, t1))     # This is a similar syntax as ``getarray3d``, while you get a list of 3D data.
>>> print(len(datlist))
61
glue = datetime.timedelta(seconds=1)
loadfile(filename)[source]

Return the obstime for the given filename

irfpy.vima.scidata_util.get2d(t, emulate_full=False)[source]

Get the 2-D data at a specific time.

Parameters
  • t – Time of observation

  • emulate_full – Emulate M24 if True.

Returns

A tuple, (time_start, VEX/IMA 2D data). The IMA 2D data is an object of irfpy.imacommon.imascipac.CntMatrix2D.

>>> t, data = get2d(datetime.datetime(2008, 1, 9, 14, 30))
>>> print(t)
2008-01-09 14:29:39.844060
>>> print(data)
<<class 'irfpy.imacommon.imascipac.CntMatrix2D'>(VEX/IMA)@2008-01-09T14:29:39.844060:MOD=25 >>25<<:POL=14/15:CNTmax=4>
class irfpy.vima.scidata_util.iter2d(t0, t1, emulate_full=False)[source]

Bases: object

Iteration over 2-D data.

>>> t0 = datetime.datetime(2011, 11, 5, 22, 34)
>>> t1 = datetime.datetime(2011, 11, 5, 23, 15)
>>> for dat in iter2d(t0, t1):    
...     print(dat)
<<class 'irfpy.imacommon.imascipac.CntMatrix2D'>(VEX/IMA)@2011-11-05T22:34:08.548000:MOD=24 >>24<<:POL=11/11:CNTmax=14>
<<class 'irfpy.imacommon.imascipac.CntMatrix2D'>(VEX/IMA)@2011-11-05T22:34:20.548000:MOD=24 >>24<<:POL=12/12:CNTmax=23>
<<class 'irfpy.imacommon.imascipac.CntMatrix2D'>(VEX/IMA)@2011-11-05T22:34:32.548000:MOD=24 >>24<<:POL=13/13:CNTmax=11>
...
<<class 'irfpy.imacommon.imascipac.CntMatrix2D'>(VEX/IMA)@2011-11-05T23:14:44.860660:MOD=24 >>24<<:POL=06/06:CNTmax=10>
<<class 'irfpy.imacommon.imascipac.CntMatrix2D'>(VEX/IMA)@2011-11-05T23:14:56.860640:MOD=24 >>24<<:POL=07/07:CNTmax=11>
glue = datetime.timedelta(seconds=1)
loadfile(filename)[source]