irfpy.mels.flux
¶
A module of MEX/ELS flux.
The flux is dumped from CL, and located at thor:/irf/data/aspera3/els/mat.
Note
I am not sure the CL really implement the ELS calibration properly. So using this module should be careful and your own risk.
- irfpy.mels.flux.get_uribase_path()[source]¶
Return the database path.
Database of ElS flux can be specified by [mels]/fluxmaturibase in irfpyrc. If no path is found,
irfpy.asperacommon.excepts.DbPathNotFoundError
is raised.The path may include the 4-digit subdirectories expressing the year.
- class irfpy.mels.flux.ElsFluxDatabase(dbpath=None)[source]¶
Bases:
irfpy.util.timeseriesdb.DB
The ELS flux database folder.
The data base of the ELS flux. First, it searches through the file name ‘elecYYYYMMDDHH.mat’ under the given dbpath. Then, the start time is calculated from the file name, and registered into this database.
- Parameters
dbpath – Path of the database. Default is read by
get_uribase_path()
.
# First, instance it.
>>> samplepath = os.path.join(os.path.dirname(__file__), 'sample', 'elsflux') >>> db = ElsFluxDatabase(dbpath=samplepath)
# Then, you can check the size of the data base. In the sample/elsflux folder, seven files can be found.
>>> print(len(db)) 7
# To get the file name of the data, you can use
get()
method.>>> file = db.get(datetime.datetime(2005, 1, 2, 15, 0, 0)) >>> print(os.path.basename(file)) elec2005010200.mat
# In case you want to load the file one before, you can use
previousof()
method.>>> file_prev = db.previousof(file) >>> print(os.path.basename(file_prev)) elec2005010100.mat
Initialize the database.
- class irfpy.mels.flux.ElsFluxFile(uri)[source]¶
Bases:
object
Load the matlab flux file
- Parameters
uri – The URI or filename of the file.
- getobstime()[source]¶
Return the observation time as array of
datetime.datetime
>>> sample = ElsFluxFile.get_sample_filename() >>> s = ElsFluxFile(sample) >>> otime = s.getobstime() >>> print(len(otime)) 784
- gettimerange()[source]¶
Return the time range stored in this file.
The start time is the time of the first packet. The end time is the time of the last packet. This means that the end time does not agree with the end of the observation time. The end of the observation time is the end time plus data acquisition time (typically 4 sec).
>>> sample = ElsFluxFile.get_sample_filename() >>> s = ElsFluxFile(sample) >>> print(s.gettimerange()) [datetime.datetime(2010, 6, 3, 18, 0, 4), datetime.datetime(2010, 6, 3, 18, 59, 57)]
- get_data(t_c)[source]¶
Return the flux data obtained at t_c.
Note that the time of the returned data, t_r, is generally different from t_c. t_r sastisfies t_r < t_c and (t_r - t_c) is minimum. Sometimes the t_r is very far from t_c, as no error check or data gap check is done. It is the user’s responsible to check whether t_r is acceptable or not. Thus, it is recommended that the t_c is taken from the returned value of
getobstime()
.- Parameters
t_c (
datetime.datetime
) – The time of the observation.- Returns
A tuple, (t_r, flux). flux should have 16x128 shaped ndarray.
>>> sample = ElsFluxFile.get_sample_filename() >>> s = ElsFluxFile(sample) >>> t_c = s.getobstime()[300] >>> t_r, flux = s.get_data(t_c) >>> t_r == t_c True >>> print('%.5e' % flux.max()) 2.45800e+10