irfpy.cena.plot.axis_timeseries
¶
Module to return an axis that has energy-time diagram for CENA.
- irfpy.cena.plot.axis_timeseries.axis_time_spectra(xaxis, yaxis, data, rect=None, vmin=None, vmax=None, vscale='linear', voffset=0, colorbar=False, kwds_axes=None, **kwds)[source]¶
Draw time-something image to the current figure.
- Parameters
xaxis – Array-like for the time. Time should be matplotlib time.
datetime.datetime
should be processed prior bydate2num()
function.yaxis – Array-like for y-axis.
data (
numpy.array
ornumpy.ma.masked_array
) – The data to be plotted. len(xaxis) x len(yaxis). Masked array is also supported.rect – A rectangle to be given to axes. [xmin, ymin, width, height]. If you want to make several axes in one figure, this values look to be used for identification. See pylab.axes for details.
kwds_axes – A dictionaly of the keyword to be given to
plt.axes()
. For example, kwds_axes = {“axisbg”:”k”} will change the background color.dateformat – A format for the x_axis.
vscale – A scale of the colorbar. ‘linear’ or ‘log’.
- Returns
The axis produced.
- irfpy.cena.plot.axis_timeseries.insert_datagap(xlist, datalist, gap=1)[source]¶
Insert a datagap into the datalist.
- Parameters
xlist – List of
float
. It should be monotonically increasing.datalist – List of the data. Should be
ndarray
ormasked_array
. datalist[:, …] should be the same size asdatetime_list
. Use transpose() to make the target axis to the first.
- Returns
Gap enbedded data as tuple of array and masked_array.
- Return type
tuple of (array, masked_array)
>>> from datetime import datetime >>> from datetime import timedelta
xlist has 11 elements. 5 is missing.
>>> x = [0., 1, 2, 3, 4, 6, 7, 8, 9, 10, 11]
Data is defined here. I assume 11 x 3 x 8 x 7 array (4-D). Note the time list has length of 11.
>>> dat = np.arange(11*3*8*7).reshape(11, 3, 8, 7) >>> dat.shape (11, 3, 8, 7)
Now, the data gap will be inserted
Before:
Index: 0 1 2 3 4 5 6 7 8 9 10 X: 0 1 2 3 4 6 7 8 9 10 11 Data: D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 D10
After:
Index: 0 1 2 3 4 5 6 7 8 9 10 11 X: 0 1 2 3 4 5 6 7 8 9 10 11 Data: D0 D1 D2 D3 D4 M D5 D6 D7 D8 D9 D10
>>> x2, dat2 = insert_datagap(x, dat) >>> print(len(x2)) 12 >>> print(dat2.shape) (12, 3, 8, 7) >>> print(x2[5]) 5 >>> print(dat2.mask[0, 2, 1, 4]) # mask[0, :, :, :] is False False >>> print(dat2.mask[5, 1, 7, 2]) # mask[5, :, :, :] is True True >>> print(dat2[3, 2, 5, 1] == dat[3, 2, 5, 1]) True >>> print(dat2[9, 1, 3, 6] == dat[8, 1, 3, 6]) True