irfpy.imacommon.imaextra2

Common functionality and data structures for IMA extra datasets.

IMA extra is a file that Andrei prepared. This module provides classes of the netcdf formatted IMA extra datasets (gzipped). This replaces irfpy.imacommon.imaextra module.

This module provides low-level functionality and data structures commonly used for ASPERA-3 and -4 IMA extra. The users do not need to use this module directly.

For developer

This module contains several classes, but most of them do not need to be used by user. The classes in this module are extended at mima.imaextra or vima.imaextra modules.

Nevertheless, it is worthwhile to create a list of class with a bit high-level explanation.

(END for developer)

class irfpy.imacommon.imaextra2.ImaDdNcFileCommon(filename, gunzip=True)[source]

Bases: object

A common functionality of IMA DD/NC file.

This will be extened to classes irfpy.mima.imaextra.ImaExtraFile, irfpy.vima.imaextra.ImaExtraFile, etc.

It has a member variable dim and var, which respectively have informationon dimensions and variables.

Open the file and read the data.

logger = <Logger irfpy.imacommon.imaextra2.ImaDdNcFileCommon (DEBUG)>
getobstime()[source]

Return the array of the observation time as datetime.datetime instance.

t0()[source]

Return the start time.

t1()[source]

Return the stop time.

class irfpy.imacommon.imaextra2.ImaExtraFileCommon(*args, **kwds)[source]

Bases: irfpy.imacommon.imaextra2.ImaDdNcFileCommon

IMAEXTRA file

Open the file and read the data.

class irfpy.imacommon.imaextra2.ImaDdTimeSeries(data_key_list)[source]

Bases: object

Represents a time series of DD data.

initialize()[source]
tabulate()[source]
append(other)[source]
trim(t0, t1)[source]
class irfpy.imacommon.imaextra2.ImaParamCommon(key_list)[source]

Bases: irfpy.imacommon.imaextra2.ImaDdTimeSeries

IMA parameter data class.

A common algorithm tha handles IMA parameter data. It is used for both MEX and VEX.

tabulate(fp=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)[source]
append(other)[source]
trim(t0, t1)[source]

You may trim the dataset to the specified time interval (inclusive).

class irfpy.imacommon.imaextra2.ImaExtraCommon(key_list)[source]

Bases: irfpy.imacommon.imaextra2.ImaDdTimeSeries

IMA extra data class.

A common algorithm tha handles IMA extra data. It is used for both MEX and VEX.

getHpSpec()[source]

Return the proton spectra. Counts. Order is AEPT (irfpy standard)

Returns

Proton spectra, in the shape of (A16, E96, P16, Time). Counts.

getHeavySpec()[source]

Return the heavy ion spectra. Counts. Order is AEPT (irfpy standard)

Returns

Heavy ion spectra, in the shape of (A16, E96, P16, Time). Counts.

getRestRm()[source]

Return the rest matrix. Counts. Order is MAEPT (irfpy standard)

Returns

Rest matrix, in the shape of (M32, A16, E96, P16, Time). Counts.

getobstime()[source]

Return the tuple of time.

Returns

Tuple of time.

tabulate(fp=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)[source]
append(other)[source]
trim(t0, t1)[source]
trim_none()[source]
class irfpy.imacommon.imaextra2.ImaParamFileCommon(*args, **kwds)[source]

Bases: irfpy.imacommon.imaextra2.ImaDdNcFileCommon

Open the file and read the data.

class irfpy.imacommon.imaextra2.ImaDdNcFileFactory(template_class, cachesize=5)[source]

Bases: object

A factory class for IMA extra dataset.

Instead of creating ImaExtraFile or ImaParamFile instance directly, the class returns the instance with using a RingCache.

iexfact = ImaDdNcFileFactory.createFactory()
iexfact.getImaExtraFile('imaextra20123640214.nc.gz')
getDdNcFile(filename, gunzip=True)[source]
class irfpy.imacommon.imaextra2.ImaDdNcDatabase(database, prefix_name, ddncfactory, verbose=False)[source]

Bases: object

IMA DD/NC database

The IMA DD/NC data base stores the filename and the start time guessed from the file name. By using this database, one can easily get the file name with a key of the observation time.

Create the database.

Use createDatabase() class method for creating database.

Parameters
  • database – Database directory path. If None, the [vima]-imaextrabase entry from irfpyrc is read.

  • prefix_name – The filename should be imaXXXXX20103091457.nc.gz. The prefix, imaXXXXX should be specified to identify the start of the time expression.

  • ddncfactory – Factory object that create the object of the file contents. It should be an object of the class that extends ImaDdNcFileFactory. For example, ImaExtraFileFactory can be given.

  • verbose – The keyword is outdated. Do nothing. Use logging to display a log with the name of irfpy.imacommon.imaextra2.ImaDdNcDatabase.

logger = <Logger irfpy.imacommon.imaextra2.ImaDdNcDatabase (DEBUG)>
nextof(filename)[source]

Return the next file

previousof(filename)[source]

Return the previous file

get_filename_from_db(t)[source]

Return the filename from database.

get_timerange(filename)[source]

Return the time range (exact) from filename

get_filename(t, nodata='exception')[source]

Return the filename from data file.

Users are recommended to use this method.

Parameters
  • t – Time.

  • nodata – Set behaviour if the specified time falls into the data gap. ‘before’ returns the file name that has the previous data to t. ‘after’ return the file name that has the next data of t. Otherwise, raise an irfpy.util.timeseriesdb.DataNotInDbError.

get_filenames(t0, t1)[source]

Return the list of filename