=============== 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 :meth:`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 :class:`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 :class:`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 :class:`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 2009-10-05 14:20:01.174320 ... 2009-10-05 14:22:58.314500 2009-10-05 14:22:59.314500