NPD data access¶
The data access to NPD follows the irfpy data center approach.
The irfpy data center supports common methods to get space instrument data coherently.
See also the data center tutorial and data center API for more details.
First step¶
The first step is to create VEX/NPD data center. Simpley type as follows.
>>> from irfpy.vnpd import vnpddata
>>> dc1 = vnpddata.DataCenterRawMode(1) # 1 is for NPD1
>>> dc2 = vnpddata.DataCenterRawMode(2) # 2 is for NPD2
How to read a specific time data¶
You can use the nearest
method.
>>> import datetime
>>> t0 = datetime.datetime(2009, 10, 5, 14, 20)
>>> tobs, data = dc1.nearest(t0)
tobs
is the actual time that was measured.
>>> print(tobs)
2009-10-05 14:19:59.714300
data
is the data obtained. It is an object of the irfpy.npdcommon.npdpacket.NpdRawPacket
.
For example, the attirbute event_tof
will give you a 512 entry of TOF data in the NPD packet. Other attributes are
described in the document here irfpy.vnpd.npdpacket.NpdRawPacket
.
>>> print(data.event_tof)
[ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1603 0 0 0 0 0 0
0 0 0 0 259 0 0 0 0 0 0 0 0 0 0
...
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0]
Reading timeseries data¶
You can use get_array
method in the data center to get the time series of data.
>>> t0 = datetime.datetime(2009, 10, 5, 14, 20)
>>> t1 = datetime.datetime(2009, 10, 5, 14, 23)
>>> tobs, data = dc1.get_range(t0, t1)
Then, tobs
is a list of the observed time, and data
is a list of
the irfpy.vnpd.npdpacket.NpdRawPacket
object.
For loop¶
For loop is also supported.
>>> for tobs, data in dc1.iter(t0, t1):
... print(tobs, data)
2009-10-05 14:20:00.714300 <NpdRawPacket: 2009-10-05T14:20:00 cnts=2157 1208 4178 4943 59 9886>
2009-10-05 14:20:01.174320 <NpdRawPacket: 2009-10-05T14:20:01 cnts=2218 1224 4218 4986 53 9968>
...
2009-10-05 14:22:58.314500 <NpdRawPacket: 2009-10-05T14:22:58 cnts=2133 1336 4194 4679 59 9731>
2009-10-05 14:22:59.314500 <NpdRawPacket: 2009-10-05T14:22:59 cnts=2059 1255 4105 5055 45 9915>