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_list –
np.array
of the time when the data is sampled. (N,) shape. Float ordatetime.datetime
object.value_matrix –
np.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 iftime_list
is float, butdatetime.timedelta
if time_list isdatetime.datetime
.
Usually, the observed data is given by the time and spectrum. For example,
>>> 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 is two problems:
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”
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]]