Source code for irfpy.mima.mode
''' IMA mode.
See also :mod:`irfpy.imacommon.imamode`.
'''
import irfpy.mexop.imastatus as istat
from irfpy.imacommon.imamode import *
[docs]def get(t):
''' Return the mode at t as int from the operation file
.. warning::
This function relies on the operation file,
while operation module is not continuously maintained nowadays (2020-09-02).
For usual data analysis, IMA mode can be obtained from the data itself.
Example follows.
>>> from irfpy.mima import rawdata
>>> dc = rawdata.DataCenterCount3d()
>>> import datetime
>>> t = datetime.datetime(2004, 1, 22, 22, 40)
>>> tdata, imadata = dc.nearest(t) # This is a nominal way of getting data.
>>> print(imadata.mode_data) # mode_data refer to the mode of the original data.
<IMA:Mode-24 (Exm-0) M32/A16/E96/P16>
:returns: The mode used for IMA operation
If unknown or invalid, -999 is returned.
>>> import datetime
>>> import irfpy.mexop.imastatus
>>> if not irfpy.mexop.imastatus.isdb():
... print("No data source is found.") # doctest: +SKIP
... else:
... print(get(datetime.datetime(2004, 1, 22, 22, 40)))
24
... print get(datetime.datetime(2004, 1, 22))
8
... print get(datetime.datetime(1988, 3, 15))
-999
'''
state = istat.get_status(t)
mode = state.mode
try:
return int(mode)
except:
return -999