eumap.gapfiller.TMWM¶
- class TMWM(fn_files=None, data=None, season_size=None, time_win_size=9, cpu_max_workers=2, engine='CPU', gpu_tile_size=250, outlier_remover=None, std_win=3, std_env=2, perc_env=[2, 98], n_jobs_io=4, verbose=True)[source]¶
Bases:
eumap.gapfiller.ImageGapfill
Temporal Moving Window Median able to gapfill the missing pixels using the temporal neighborhood by a moving window to calculate several median possibilities. The approach prioritizes values derived for 1–the same day/month/season, 2–neighboring days/months/seasons, and 3–all the year.
For example, in the best case scenario a missing pixel on Jan-2005 is filled using a median value derived from January of other years, and in the worst case scenario it uses a value derived of all the months and available years. If a pixel remains with a missing value, it is because there is no valid data on the entire time series.
- Parameters
fn_files (
Optional
[List
]) – Raster file paths to be read and gapfilled.data (
Optional
[array
]) – 3D array where the last dimension is the time.season_size – Season size of a year (for monthly time series it is equal
12
).time_win_size (
int
) – Size of the temporal window used to calculate the median value possibilities.cpu_max_workers (
int
) – Number of CPU cores to be used in parallel.engine – Execute in
CPU
[1] orGPU
[2].gpu_tile_size (
int
) – Tile size used to split the processing in the GPU.outlier_remover (
Optional
[OutlierRemover
]) – Strategy to remove outliers.std_win (
int
) – Temporal window size used to calculate a local median and std.std_env (
int
) – Number of std used to define a local envelope around the median. Values outside of this envelope are removed.perc_env (
list
) – A list containing the lower and upper percentiles used to defined a global envelope for the time series. Values outside of this envelope are removed.n_jobs_io – Number of parallel jobs to read/write raster files.
verbose – Use
True
to print the progress of the gapfilled.
References
[2] CuPY nanmedian
Examples
>>> from eumap import gapfiller >>> >>> # For a 4-season time series >>> tmwm = gapfiller.TMWM(fn_files=fn_rasters, season_size=4, time_win_size=4) >>> data_tmwm = tmwm.run() >>> >>> fn_rasters_tmwm = tmwm.save_rasters('./gapfilled_tmwm')
Methods
fill_image
Execute the gapfilling approach.
Save the result in raster files maintaining the same filenames of the read rasters.
- run()¶
Execute the gapfilling approach.
- save_rasters(out_dir, dtype=None, out_mantain_subdirs=True, root_dir_name='eumap_data', fn_files=None, nodata=None, spatial_win=None, save_flag=True)¶
Save the result in raster files maintaining the same filenames of the read rasters.
- Parameters
out_dir – Folder path to save the files.
dtype (
Optional
[str
]) – Convert the rasters for the specified Numpydtype
before save. This argument overwrite the values retrieved offn_files
out_mantain_subdirs (
bool
) – Keep the full folder hierarchy of the read raster in theout_dir
.root_dir_name (
str
) – Keep the relative folder hierarchy of the read raster in theout_dir
considering of the sub folders ofroot_dir_name
.fn_files (
Optional
[List
]) – Raster file paths to retrieve the filenames and folders. Use this parameter in situations where thedata
parameter is informed in the class constructor. The pixel size, crs, extent, image size and nodata for the gapfilled rasters are retrieved from the first valid raster offn_files
nodata –
Nodata
value used for the the gapfilled rasters. This argument overwrite the values retrieved offn_files
. This argument doesn’t affect the flag rasters (gapfill summary), which havenodata=0
.spatial_win (
Optional
[Window
]) – Save the gapfilled rasters considering the specified spatial window.save_flag – Save the flag rasters (gapfill summary).