Time reductionΒΆ

[1]:
%matplotlib inline
# for figures in notebook

# import & initialize epygram
import epygram
epygram.init_env()

# path to file
import os
INPUTS_DIR = os.path.join('..', 'inputs')
[2]:
paths = [os.path.join(INPUTS_DIR, 'grid.arome-forecast.guyane0025+00{:02}:00.grib'.format(i))
         for i in (0, 12, 24)]
r = epygram.resources.meta_resource(paths, 'r', 'MV')  # MV = Multi-Validities
[3]:
f = r.readfield('shortName:2r')
[4]:
print(f.data.shape)
print(f.validity)
print(f.validity[2])
print(f.data[:,0,0])
(3, 317, 419)
<List of FieldValidity which date/time are:
2020-11-02 00:00:00
2020-11-02 12:00:00
2020-11-03 00:00:00
>
FieldValidity containing:
    _basis: 2020-11-02 00:00:00
    _date_time: 2020-11-03 00:00:00
    _cumulativeduration: None
    _statistical_process_on_duration: None
    _statistical_time_increment: None
[95.85521266 90.31512517 95.977125  ]
[5]:
f.time_reduce()
[6]:
print(f.data.shape)
print(f.validity[0])  # Validity is now the cumulated statistical process on the window
print(f.data[0,0])
(317, 419)
FieldValidity containing:
    _basis: 2020-11-02 00:00:00
    _date_time: 2020-11-03 00:00:00
    _cumulativeduration: 1 day, 0:00:00
    _statistical_process_on_duration: mean
    _statistical_time_increment: None
94.04915427547299
[ ]: