irfpy.mels.scidata

MEX/ELS data accessor

Note

As the VEX/ELS modules are highly dedicated, I gave up to spend time on refactoring and making coordinated class between MEX & VEX.

Though, I am trying to make the interface as similar as possible.

Preparation

Download the tree structure of elsdata from spaghetti.irf.se. Then, specify the downloaded path in ~/.irfpyrc or ./.irfpyrc by the entry of elsmatbase under the section [mels].

Access

The following two functions are the easy accessor for users.

  • getobstime() will give you the actual start time list of each ELS data (energy/direction spectra, usually 4s data) for the given time range.

  • gettimeseries() will return the time series of the ELS count rate dataset in ElsCountTimeSeries for the given time range.

Other notes

In this module, the simplest way of ELS data analysis is employed. This means that we do not refer to the HV monitor level, but only the count data. The energy and g-factor will be calculated from the static table.

As of the end of 2013, the energy table and g-factor is constant (presumably). I referred to PDS, and this is the case.

The hyerarchy of dataset in this module is

  • Single time data of counts. Full mode is 128 energy step & 16 directions every 4 s. This is implemented as ElsCountData class.

  • A series of single time data, implemented as ElsCountTimeSeries.

  • A file, in Matlab form, implemented as ElsCountFile. Both data and HV information is there.

  • A collection of file (data file structure), implemented as ElsCountFileDB.

class irfpy.mels.scidata.ElsCountData(t, counts)[source]

Bases: object

Container of ELS count data. Base class.

class irfpy.mels.scidata.ElsCountDataBurst(t, counts)[source]

Bases: irfpy.mels.scidata.ElsCountData

Container of ELS count data. (128, 16) array.

ELS count data container. The object contains only two attributes.

  • :attr t:The time

  • attr counts

    Count matrix (128, 16) shaped np.ma.array.

Usually the users do not need to create this object.

>>> # Prepare the matrix and time for dummy data
>>> t = datetime.datetime(2014, 10, 18, 13, 15, 27, 123456)
>>> matx = np.arange(128 * 16).reshape([128, 16])
>>> els_data = ElsCountDataBurst(t, matx)
>>> print(els_data)
<ElsCountDataBurst: 2014-10-18T13:15:27.123456 Max=2047 Min=0>
>>> print(els_data.counts.shape)
(128, 16)
>>> print(els_data[3, 12])
60
>>> print(els_data[3, 12:16])
[60 61 62 63]
class irfpy.mels.scidata.ElsCountTimeSeries[source]

Bases: irfpy.util.tdict.TimeDict

Time series of ElsCountData (and its derivable) object.

The object stores the ELS count data. Usually produced by gettimeseries(), and to make the array form, use toarray128().

>>> t0 = datetime.datetime(2014, 10, 19, 18, 30)
>>> t1 = datetime.datetime(2014, 10, 19, 18, 32)    # 2 minutes
>>> timeser = gettimeseries(t0, t1)   # You get ElsCountTimeSeries object
>>> print(len(timeser))
27
>>> tlist, arr = timeser.toarray128()    # You get time information together with matrix form of counts.
>>> print(len(tlist))
27
>>> print(arr.shape)
(128, 16, 27)
toarray128()[source]

Return the np.array expression of count data

class irfpy.mels.scidata.ElsCountFile(filename)[source]

Bases: object

A container of ELS matlab file. Represents a single file contents.

Usually, the object is made via calling, els_count_file_factory().

>>> els_count_file = els_count_file_factory("/Volumes/scidata/data/mars/elsdata/201410/20141019180000.mat")    
getobstime()[source]
get_timeseries()[source]

Return the time series of the count data.

Returns

Time series of the count data

Return type

ElsCountTimeSeries

class irfpy.mels.scidata.ElsCountFileDB[source]

Bases: object

Represent the database of ELS counts file in Matlab form.

One have to download the Matlab file from spaghetti.irf.se to start with. Then, one has to setup ~/.irfpyrc or ./.irfpyrc as follows.

::

[mels] elsmatbase = /path/to/els/matlab/file

For usual use, you may want to get a file name where the specific observation is obtained.

>>> elsdb = ElsCountFileDB()
>>> t = datetime.datetime(2014, 10, 19, 18, 30)   # Specify the time
>>> datafile = elsdb.get(t)     # Obtain the filename that included the data at t.
>>> print(os.path.basename(datafile))
20141019180000.mat
>>> t1 = datetime.datetime(2014, 10, 19, 20, 25)
>>> files = elsdb.getfiles(t, t1)   # Obtain the list of filenames
>>> print(len(files))
3
>>> print(os.path.basename(files[1]))
20141019190000.mat
get(t)[source]

Return the filename.

Parameters

t – Time of observation

Returns

The file name where the data is included.

getfiles(t0, t1)[source]

Return the filename list for the given time range.

Parameters
  • t0 – Start of inquiry

  • t1 – End of inquiry

Returns

The file names.

irfpy.mels.scidata.gettimeseries(t0, t1)[source]

Return the time series for each energy spectra

Parameters
  • t0 – Start of inquiry

  • t1 – Stop of inquiry

Returns

Time series of ELS count data

Return type

ElsCountTimeSeries

>>> t0 = datetime.datetime(2014, 10, 19, 17, 55)
>>> t1 = datetime.datetime(2014, 10, 19, 19, 8)
>>> tseries = gettimeseries(t0, t1)
>>> print(len(tseries))
954
>>> t0r, dat0 = tseries[0]   # The first data
>>> print(t0r, dat0)
2014-10-19 17:54:55.271000 <ElsCountData: 2014-10-19T17:54:55.271000 Max=20 Min=0>
>>> t1r, dat1 = tseries[-1]  # The last data
>>> print(t1r, dat1)
2014-10-19 19:07:56.202000 <ElsCountData: 2014-10-19T19:07:56.202000 Max=76 Min=0>
irfpy.mels.scidata.getobstime(t0, t1)[source]

Return the list of observation time.

Parameters
  • t0 – Start of inquiry

  • t1 – Stop of inquiry

Returns

List of observation time

>>> t0 = datetime.datetime(2014, 10, 19, 17, 55)
>>> t1 = datetime.datetime(2014, 10, 19, 19, 8)
>>> obstime = getobstime(t0, t1)
>>> print(len(obstime))
954
>>> print(obstime[0])
2014-10-19 17:54:55.271000
>>> print(obstime[-1])
2014-10-19 19:07:56.202000
irfpy.mels.scidata.get_counts(t0, t1)[source]

Return the numpy array of the ELS counts.

Parameters
  • t0 – Start of inquiry

  • t1 – Stop of inquiry

Returns

A tuple with length of two. (obstime, counts) where obstime is the list of the observation time and counts is the array of the counts.

>>> t0 = datetime.datetime(2014, 10, 19, 17, 55)
>>> t1 = datetime.datetime(2014, 10, 19, 19, 8)
>>> obstime, counts = get_counts(t0, t1)
>>> print(len(obstime))
954
>>> print(obstime[0])
2014-10-19 17:54:55.271000
>>> print(obstime[-1])
2014-10-19 19:07:56.202000
>>> print(counts.shape)
(128, 16, 954)
>>> print(counts.max())
432.0
irfpy.mels.scidata.get_cps(t0, t1)[source]
irfpy.mels.scidata.get_dnf(t0, t1)[source]
irfpy.mels.scidata.get_def(t0, t1)[source]