MEX/VEX NPI background data as proxy of SEP

MEX/VEX NPI bacground data is made routinely at

class irfpy.npicommon.background.DataCenterBackground(pathname, name='NPI bakground (generic)')[source]

Bases: irfpy.util.datacenter.BaseDataCenter

Data center for MEX/VEX NPI background


  • 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 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.


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.


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.


filename – A string, filename.


An approximate, guessed start time of the file

Return type



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.


filename – File name


The contents of the data file

Return type



From filename load the data and re-format it.

class irfpy.npicommon.background.Database(datapath)[source]

Bases: object

A data base.

Assumes the files are downloaded locally.


datapath – Path to the data (locally downloaded)


Background level data.

This is a loaded and concatenated background level data, a irfpy.util.timeseries.ScalarSeries instance.

get_background_level(t0, t1)[source]

Return the background level.

load_background_files(t0, t1)[source]