modis.smooth
ModisSmoothH5
Warning
only implemented for MOD/MYD 11/13 products!
Class representing HDF5 file containing smoothed MODIS data.
A smooth HDF5 file is directly linked to it's raw HDF5 counterpart. When running the Whittaker smoother, data is read from the raw HDF5 file, smoothed and gapfilled (and if requested a temporal interpolation is performed), the resulting data is then written to the smooth HDF5 file.
__init__(self, rawfile, targetdir, startdate=None, tempint=None)
special
Initialize instance of ModisSmoothH5
class.
To create an instance of ModisSmoothH5
, a full path to
a ModisRawH5
HDF5 file needs to be specified.
If the HDF5 file for the ModisSmoothH5
already exists in the targetdir
,
the file will be updated, otherwise created.
To perform temporal interpolation, a desired timestep
for a temporal grid has to be specified with tempint
.
If tempint
is 5 or 10, the grid is set to a specific default.
Otherwise, startdate
can be used to define a default grid in
conjunction with tempint
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rawfile |
str |
Full path to raw HDF5 file. |
required |
targetdir |
str |
Target directory for smooth HDF5 file. |
required |
startdate |
str |
Start date for temporal interpolation (as julian date YYYYDDD). |
None |
tempint |
int |
timesteps for temporal interpolation. |
None |
Exceptions:
Type | Description |
---|---|
AssertionError |
If specified raw HDF5 file does not exist. |
create(self)
Creates HDF5 file.
If the corresponding HDF5 is not found in the target directory, it's created.
Exceptions:
Type | Description |
---|---|
HDF5CreationError |
If creation of HDF5 file fails. |
smooth(self, svalue=None, p=None, soptimize=None, srange=None, nsmooth=0, nupdate=0)
Applies Whittaker smoother to the data.
This method reads raw data from the raw HDF5 and applies the Whittaker filter according to the parameters supplied. The resulting filtered data is then stored in the smooth HDF5 file.
The parameters relevant for derermining which Whittaker
variant is supplied, are svalue
, soptimize
and p
:
If the soptimize
flag is True
, the V-curve optimization is performed.
If in addition a p
value is supplied, the assymmetric V-curve optimization is performed instead.
In both cases, the range of S values to optimize in can be supplied with srange
.
If soptimize
is False
and a svalue
is passed, smoothing using that fixed value (needs to be log10
of S)
for each pixel is performed. If a p
value is passed, asymmetric smoothing with the fixed value is performed instead.
If none of svalue
and soptimize
is specified, a previosuly initialized S value for each pixel
will be read from grid and used for the smoothing.
Using nsmooth
and nupdate
, the number or raw timesteps used for smoothing, and the number
of filtered timesteps updated in the smooth HDF5 target file, can be adjusted.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
svalue |
float |
Log10 value of smoothing parameter S (for fixed smoothing). |
None |
p |
float |
P value for asymmetric smoothing. |
None |
soptimize |
bool |
Flag for V-curve optimization. |
None |
srange |
ndarray |
S-range for V-curve optimization. |
None |
nsmooth |
int |
Number of raw timesteps for smoothing. |
0 |
nupdate |
int |
Number of smooth timesteps updated in file. |
0 |
Exceptions:
Type | Description |
---|---|
AssertionError |
If smooth HDF5 file does not exist ( |
ValueError |
If |
ValueError |
If |
HDF5WriteError |
If write to HDF5 file fails. |