irfpy.cena.cena_data

A modern implementation of CENA data retriever

This CENA data retriever uses an approach of “irfpy data center”. Refer to https://irfpy.irf.se/projects/util/tutorial/tutorial_datacenter.html for general notes on the data center.

A path setting should be done via .irfpyrc setting.

[cena]
bmuopath = /path/to/data/bmu_orbit.v3.2
class irfpy.cena.cena_data.DataCenterCenaPacket[source]

Bases: irfpy.util.datacenter.BaseDataCenter

Data center for CENA Packet data.

This class provides data access of CENA. The returned data is for Cena Packet data, namely, Sadppac.CenaPacket.

>>> dc = DataCenterCenaPacket()
>>> print(dc.t0())
2008-12-09 11:10:06.306000
>>> print(dc.t1())
2009-08-01 04:21:25.270000
>>> import datetime
>>> t = datetime.datetime(2009, 4, 3, 6, 0, 13)
>>> print(dc.nearest(t))    
(datetime.datetime(2009, 4, 3, 6, 0, 13, 23000), <Sadppac.CenaPacket; proxy of <Swig Object of type 'IrfPac::SaraPac::CenaPacket *' at ...

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.

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

read_file(filename)[source]

The file is read, and return the contents as a tuple with size 2, (tlist, dlist).

This method is an abstract method, meaning that the developer of the data center should implement it. See SampleDataCenter for more details.

The implementation of this method should follow:

  • Returned value is a tuple with a size of 2. - The first element is a tuple/list specifying the time (with each element as datetime.datetime object) - The second element is a tuple/list specifying the data, with any format. - The length of both two elements should be the same.

If the given filename is corrupted or empty, a two empty tuple would be returned (i.e., return (), ()). In this case, return None for the exact_starttime() method.

Parameters

filename – File name

Returns

The contents of the data file

Return type

tuple

class irfpy.cena.cena_data.DataCenterCenaMassCount[source]

Bases: irfpy.util.datacenter.BaseDataCenter

A data center for CENA mass mode counts data access.

The data center provide (16, 7) shaped array containing the mass mode data.

>>> dc = DataCenterCenaMassCount()
>>> print(dc.t0())
2009-01-31 07:25:59.393000
>>> print(dc.t1())
2009-08-01 04:21:25.270000
>>> import datetime
>>> t = datetime.datetime(2009, 4, 3, 6, 25, 0)
>>> tobs, dat = dc.nearest(t)
>>> print(tobs)
2009-04-03 06:25:00.980000
>>> print(dat.sum())
17.0

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.

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

read_file(filename)[source]

The file is read, and return the contents as a tuple with size 2, (tlist, dlist).

This method is an abstract method, meaning that the developer of the data center should implement it. See SampleDataCenter for more details.

The implementation of this method should follow:

  • Returned value is a tuple with a size of 2. - The first element is a tuple/list specifying the time (with each element as datetime.datetime object) - The second element is a tuple/list specifying the data, with any format. - The length of both two elements should be the same.

If the given filename is corrupted or empty, a two empty tuple would be returned (i.e., return (), ()). In this case, return None for the exact_starttime() method.

Parameters

filename – File name

Returns

The contents of the data file

Return type

tuple