Get CENA data

To get the CENA count rate data at a specific time, there are several implementations.

Iterate the CENA mass data matrix

You can iterate the 4-s CENA data (matrix).

First, create the data center (Data center, a new coherent way to access data) of CENA packet.

>>> from irfpy.cena import cena_data
>>> dc = cena_data.DataCenterCenaMassCount()
>>> print(dc)
irfpy DataCenter (Name: 'Unnamed DataCenter'): 514 data files combined

Then, specify the time range to look at. For example, let’s see the data from 08:00 to 08:05 on April 3, 2009.

>>> import datetime
>>> t0 = datetime.datetime(2009, 4, 3, 8, 0)
>>> t1 = datetime.datetime(2009, 4, 3, 8, 5)

Iterate the CENA data over the time specified. The following for-loop is usually used. The variable t here is the time, and the variable d is the data as matrix.

>>> for t, d in dc.iter(t0, t1):
...     print(t, d.shape)   # Or other processings here
2009-04-03 08:00:01.053000 (16, 7, 128)
2009-04-03 08:00:05.053000 (16, 7, 128)
2009-04-03 08:00:09.051000 (16, 7, 128)
2009-04-03 08:00:13.051000 (16, 7, 128)
...
2009-04-03 08:04:53.070000 (16, 7, 128)
2009-04-03 08:04:57.068000 (16, 7, 128)

Not only iteration, you can get a time series of data as matrix, or at a specific time.

>>> tlist, dlist = dc.get_array(t0, t1)
>>> dc.nearest(t0)
(datetime.datetime(2009, 4, 3, 8, 0, 1, 53000), masked_array(
   data=[[[--, --, --, ..., --, --, --],
          [--, --, --, ..., --, --, --],
          [--, --, --, ..., --, --, --],
          ...,

Iterate the CENA packet

You can iterate the CENA data packet by packet (4s-data for each).

It is very similar to what was done as above, but use another data center, irfpy.cena.cena_data.DataCenterCenaPacket.

>>> from irfpy.cena import cena_data
>>> dc = cena_data.DataCenterCenaPacket()
>>> print(dc)
irfpy DataCenter (Name: 'Unnamed DataCenter'): 514 data files combined

Again, specify the time range to look at. For example, let’s see the data from 08:00 to 08:05 on April 3, 2009.

>>> import datetime
>>> t0 = datetime.datetime(2009, 4, 3, 8, 0)
>>> t1 = datetime.datetime(2009, 4, 3, 8, 5)

Then, iterate data, or get data as array, or as a single data.

>>> for t, d in dc.iter(t0, t1):
...     print(t, d)   # Or other processings here
2009-04-03 08:00:01.053000 <Sadppac.CenaPacket; proxy of <Swig Object of type 'IrfPac::SaraPac::CenaPacket *' at ...
2009-04-03 08:00:05.053000 <Sadppac.CenaPacket; proxy of <Swig Object of type 'IrfPac::SaraPac::CenaPacket *' at ...
2009-04-03 08:00:09.051000 <Sadppac.CenaPacket; proxy of <Swig Object of type 'IrfPac::SaraPac::CenaPacket *' at ...
2009-04-03 08:00:13.051000 <Sadppac.CenaPacket; proxy of <Swig Object of type 'IrfPac::SaraPac::CenaPacket *' at ...
2009-04-03 08:04:53.070000 <Sadppac.CenaPacket; proxy of <Swig Object of type 'IrfPac::SaraPac::CenaPacket *' at ...
2009-04-03 08:04:57.068000 <Sadppac.CenaPacket; proxy of <Swig Object of type 'IrfPac::SaraPac::CenaPacket *' at ...
>>> tlist, dlist = dc.get_array(t0, t1)
>>> dc.nearest(t0)
(datetime.datetime(2009, 4, 3, 8, 0, 1, 53000),
<Sadppac.CenaPacket; proxy of <Swig Object of type 'IrfPac::SaraPac::CenaPacket *' at 0x7fedd4080750> >)

Get the CENA data (traditional way)

>>> from irfpy.cena import cena_mass2 as cem
>>> import datetime
>>> t = datetime.datetime(2009, 2, 6, 7, 0, 0)
>>> data = cem.getdataE16(t)
>>> print(data.getDatetime())
2009-02-06 06:59:59.294015

Here, the returned data is in the irfpy.util.julday.JdObject object.

Note

irfpy.util.julday.JdObject is an old-fashioned class… We should update this.

The actual count rate data (matrix) is retrieved as

>>> matrix = data.getData()
>>> print(matrix.shape)
(16, 7, 128)

Here the shape (16, 7, 128) is the order of energy, direction, and mass bin.

Note that CENA covers 16 energy steps, while an instantaneous data covers only for 8 steps. Thus, the missing data is masked.

>>> print(matrix[:, 3, 30])
[-- -- -- -- 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -- -- -- --]

Get the energy setting of CENA

>>> from irfpy.cena import energy as cene
>>> etbl = cene.getEnergyE16()
>>> print(etbl)
[   7.   11.   17.   25.   38.   57.   86.  129.  193.  290.  435.  652.
  978. 1467. 2200. 3300.]

Get the time series of CENA count data (Traditional way)

>>> import datetime
>>> t0 = datetime.datetime(2009, 2, 6, 7, 0, 0)
>>> t1 = datetime.datetime(2009, 2, 6, 7, 10, 0)
>>> from irfpy.cena import cena_mass_time as cemt
>>> tlist, datlist = cemt.getfulldata(t0, t1)
>>> print(tlist[0])    # jdlist is a list of datetime
2009-02-06 07:00:03.294000
>>> print(len(tlist))
150
>>> print(datlist.shape)    # datlist is a numpy array
(16, 7, 128, 150)

The order of the datalist dimension is energy, direction, mass, and time.

Get the time series of CENA differential flux

Note

As of v4.4.10, DataCenter-support is not yet implemented.

>>> import datetime
>>> t0 = datetime.datetime(2009, 2, 6, 7, 0, 0)
>>> t1 = datetime.datetime(2009, 2, 6, 7, 10, 0)
>>> from irfpy.cena import cena_mass_time as cemt
>>> tlist, datlist = cemt.getfullHdeflux(t0, t1)
>>> print(tlist[0])    # jdlist is a list of datetime
2009-02-06 07:00:03.294000
>>> print(len(tlist))
150
>>> print(datlist.shape)
(16, 7, 150)
>>> print(datlist.min())
0.0
>>> print(datlist.max())
205174.554877

The order of the data is energy, direction, and time.

Get times of CENA spectrum

Note

As of v4.4.10, DataCenter-support is not yet implemented.

>>> from irfpy.cena import cena_mass2 as cem
>>> tlist = cem.getobstime(orbit=1082)
>>> print(tlist[0], tlist[-1])
2009-02-06 06:50:54.125000 2009-02-06 08:48:56.370000
>>> print(len(tlist))
1770