irfpy.mels.rawdata

MEX/ELS with the data center support.

A data access to MEX/ELS using the DataCenter approach.

How to read the data?

First, prepare the data center

>>> from irfpy.mels import rawdata
>>> dc = rawdata.DataCenterElsCounts()

Specify the time range

>>> import datetime
>>> t0 = datetime.datetime(2014, 10, 19, 17, 54, 55)
>>> t1 = datetime.datetime(2014, 10, 19, 19, 8)

Get the data as two arrays. First for the start time of the session, and the latter for the data.

>>> time_array, data_array = dc.get_array(t0, t1)
>>> print(len(data_array))
954
>>> print(time_array[0])
2014-10-19 17:54:55.271000
>>> print(data_array[0].shape)
(128, 16)
>>> print(data_array[0].max())
20

For practical use, you may create a new numpy array as follows:

>>> import numpy as np
>>> data_array = np.array(data_array)
>>> print(data_array.shape)
(954, 128, 16)
class irfpy.mels.rawdata.DataCenterElsCounts[source]

Bases: irfpy.util.datacenter.BaseDataCenter

MEX/ELS count rate data center.

The returned data is in numpy array with a shape of (E128, A16).

(TBC; What if other mode??)

>>> from irfpy.mels import rawdata
>>> import datetime
>>> t0 = datetime.datetime(2010, 10, 30, 23, 15)
>>> mels_datacenter = rawdata.DataCenterElsCounts()
>>> tobs, cnts = mels_datacenter.nearest(t0)
>>> print(tobs, cnts.shape, cnts.max())
2010-10-30 23:15:01.803000 (128, 16) 9

Initializer.

Parameters
  • cache_size – Size of the ring cache.

  • name – The name of the

  • copy – Boolean if the returned data is to be deep-copied (True) or reference (False). It is good to return the data after the copy, since then the data is always original. Returning reference is possibly faster, while there are side effect that the post-processing will destroy the original data. Therefore, it is recommended to set True always. The copy value can be overwritten by each method as necessity.

search_files()[source]

Search the data files, returning a list of data file.

This method searches the data files under the base_folder. This method should return a list / tuple of the data file name (usually a full path).

This method is called only once when __init__() was called.

Returns

A list / tuple of the data file. It should be full path (or relative path from the current path), and sorted from earlier data to later data.

read_file(filename)[source]

Read the file contents.

From a given file, electron data is read. The format is in the irfpy.vels.scidata.ElsCountData object.

approximate_starttime(filename)[source]

Start time should be guessed for each file.

A guessed start time should be returned. It is OK if it is very approximate, but the orders of the guessed-start and the exact-start should be identical. This method must be very fast, because it is called for all the files in the data base (i.e. all the files retuned by search_files() method).

A practical suggestion for implementation is to guess the time from the filename.

Parameters

filename – A string, filename.

Returns

An approximate, guessed start time of the file

Return type

datetime.datetime