# irfpy.util.time_panel¶

Utility for time series panels, such as E-t diagram

Code author: Yoshifumi Futaana

The function reform() will create a new matrix considering the data gap.

irfpy.util.time_panel.reform(time_list, value_matrix, sampling_time)[source]

Time series data is reformed considering the sampling time.

Parameters:
• time_listnp.array of the time when the data is sampled. (N,) shape. Float or datetime.datetime object.

• value_matrixnp.array of the data with (N, S) shape. S is the number of the spectrum data.

• sampling_time – Intrinsic sampling time. Float with a unit of day if time_list is float, but datetime.timedelta if time_list is datetime.datetime.

Usually, the observed data is given by the time and spectrum. For example,

>>> import numpy as np
>>> time_list = np.array([735000, 735001, 735002, 735004, 735005, 735006])
>>> img = np.array([[1, 1, 2,], [1, 2, 2,],
...        [2, 2, 1,], [0, 2, 3,],
...        [1, 3, 2,], [2, 1, 0,]])


A simple way to show this data is using meshcolor function.

# Note: the second argument is "4", not "3".
plt.meshcolor(t, np.arange(4), img.T)


Then, you may get:

-        2     1
-        v     v
3|
-| 2 2 1 1 3 2
2|
-| 1 2 2 2 2 3
1|
-| 1 1 2 2 0 1
0+-------------
0|1|2|3|4|5|6 +7.35e5


Here are two problems:

1. No data is shown for 735006. This is because the “end” time of the data is not specified. Most likely you want to plot the last (2, 1, 0) data between 735006 and “735007”

2. The data at 735003 is (likely) missing, because of some reasons. However, the program does not know it, so that the data (2, 2, 1) at 735002 is plotted until 735004.

Both problems can be solved if you know the “sampling time”. In this sample case, 1 day could be the most reasonable sampling time.

>>> time_list2, value_matrix2 = reform(time_list, img, 1)


will give you a reformed time list and value matrix (np.ma.array).

>>> print(time_list2)
[735000 735001 735002 735003 735004 735005 735006 735007]
>>> print(value_matrix2)
[[1.0 1.0 2.0]
[1.0 2.0 2.0]
[2.0 2.0 1.0]
[-- -- --]
[0.0 2.0 3.0]
[1.0 3.0 2.0]
[2.0 1.0 0.0]]


Use reform2() if the time resolution changes.

irfpy.util.time_panel.reform2(time_list, value_matrix, sampling_time_list)[source]

Same functionality as reform, but different sampling time.

Parameters:
• time_listnp.array of the time when the data is sampled. (N,) shape. Float or datetime.datetime object.

• value_matrixnp.array of the data with (N, S) shape. S is the number of the spectrum data.

• sampling_time_list – List of sampling time. (N,) shape. Numpy array of Float with a unit of day if time_list is float, but numpy array of datetime.timedelta if time_list is datetime.datetime.

>>> import numpy as np
>>> time_list = np.array([7350, 7351, 7352, 7354, 7355, 7356])
>>> img = np.array([[1, 1, 2,], [1, 2, 2,],
...                 [2, 2, 1,], [0, 2, 3,],
...                 [1, 3, 2,], [2, 1, 0,]])

>>> timeresolution = np.array([1, 1.5, 1, 0.5, 0.8, 2])
>>> time_list3, value_matrix3 = reform2(time_list, img, timeresolution)
>>> print(time_list3)
[7350.  7351.  7352.  7353.  7354.  7354.5 7355.  7355.8 7356.  7358. ]

>>> print(value_matrix3)
[[1.0 1.0 2.0]
[1.0 2.0 2.0]
[2.0 2.0 1.0]
[-- -- --]
[0.0 2.0 3.0]
[-- -- --]
[1.0 3.0 2.0]
[-- -- --]
[2.0 1.0 0.0]]