Fix "Unable to delete temporary file" issues on Windows

Issue #21 resolved
bert.coerver created an issue

For several products pywapor is unable to delete temporary/intermediate files when running on Windows. An (incomplete?) overview:

VIIRS

2024-07-03 22:20:44,316      INFO:             --> (1/15) Processing 'VNP02IMG.A2023077.1048.002.2023077174023.nc'.
2024-07-03 22:20:44,317      INFO:                 --> Downloading `VNP03IMG.A2023077.1048.002.2023077172326.nc`.
2024-07-03 22:21:42,239      INFO:                 --> Determining indices of AOI inside scene.
2024-07-03 22:21:45,642      INFO:                     --> Found 72,324 pixels inside AOI.
2024-07-03 22:21:45,648      INFO:                 --> Saving latitudes.
2024-07-03 22:21:47,980      INFO:                     > peak-memory-usage: 682.2KB, execution-time: 0:00:02.332347.
2024-07-03 22:21:47,980      INFO:                     > chunksize|dimsize: [number_of_lines: 294|294, number_of_pixels: 246|246], crs: None
2024-07-03 22:21:47,980      INFO:                 --> Saving longitudes.
2024-07-03 22:21:50,133      INFO:                     > peak-memory-usage: 687.0KB, execution-time: 0:00:02.152619.
2024-07-03 22:21:50,133      INFO:                     > chunksize|dimsize: [number_of_lines: 294|294, number_of_pixels: 246|246], crs: None
2024-07-03 22:21:50,133      INFO:                 --> Downloading `VNP02IMG.A2023077.1048.002.2023077174023.nc` for AOI.
2024-07-03 22:21:58,213      INFO:                 --> Downloading `CLDMSK_L2_VIIRS_SNPP.A2023077.1048.001.2023233192507.nc` for AOI.
2024-07-03 22:22:03,999      INFO:                 --> Combining data.
2024-07-03 22:22:06,133      INFO:                     > peak-memory-usage: 3.3MB, execution-time: 0:00:02.117935.
2024-07-03 22:22:06,133      INFO:                     > chunksize|dimsize: [number_of_lines: 294|294, number_of_pixels: 246|246], crs: None
2024-07-03 22:22:06,448      INFO:                 --> Unable to delete temporary file `C:\Users\bertc\Downloads\testcase_2\VIIRSL1\VNP03IMG.A2023077.1048.002.2023077172326.nc`.

COPERNICUS

2024-07-03 23:12:29,342      INFO:     --> Collecting `z` from `COPERNICUS.GLO90`.
2024-07-03 23:12:36,323      INFO:         --> Merging tiles.
2024-07-03 23:12:38,765      INFO:             > peak-memory-usage: 40.7MB, execution-time: 0:00:02.442501.
2024-07-03 23:12:38,782      INFO:             > chunksize|dimsize: [y: 961|961, x: 1201|1201], crs: EPSG:4326
2024-07-03 23:12:38,782      INFO:         --> Saving GLO90.nc
2024-07-03 23:12:41,217      INFO:             > peak-memory-usage: 35.2MB, execution-time: 0:00:02.434839.
2024-07-03 23:12:41,217      INFO:             > chunksize|dimsize: [y: 961|961, x: 1201|1201], crs: EPSG:4326
2024-07-03 23:12:41,298      INFO:         --> Unable to delete temporary file `C:\Users\bertc\Downloads\testcase_2\COPERNICUS\GLO90_stitched.nc`.

STATICS

2024-07-03 23:13:28,922      INFO:     --> Collecting `rn_offset`, `rn_slope`, `t_amp`, `t_opt`, `vpd_slope`, `lw_offset`, `lw_slope` from `STATICS.WaPOR3`.
2024-07-03 23:13:30,824      INFO:         --> Saving WaPOR3.nc.
2024-07-03 23:13:33,377      INFO:             > peak-memory-usage: 1.0MB, execution-time: 0:00:02.551531.
2024-07-03 23:13:33,380      INFO:             > chunksize|dimsize: [y: 7|7, x: 8|8], crs: EPSG:4326
2024-07-03 23:13:33,395      INFO:         --> Unable to delete temporary file `C:\Users\bertc\Downloads\testcase_2\STATICS\WaPOR3_temp.nc`.

SRTM

2024-07-04 00:16:06,522      INFO:     --> Collecting `z` from `SRTM.30M`.
2024-07-04 00:16:30,078      INFO:         --> Saving merged data.
2024-07-04 00:16:32,360      INFO:             > peak-memory-usage: 326.9MB, execution-time: 0:00:02.282802.
2024-07-04 00:16:32,360      INFO:             > chunksize|dimsize: [time: 1|1, y: 2883|2883, x: 3603|3603], crs: EPSG:4326
2024-07-04 00:16:32,365      INFO:         --> Unable to delete temporary file `C:\Users\bertc\Downloads\testcase_2\SRTM\30M_N28E030.nc`.
2024-07-04 00:16:32,385      INFO:         --> Unable to delete temporary file `C:\Users\bertc\Downloads\testcase_2\SRTM\30M_N28E031.nc`.
2024-07-04 00:16:32,390      INFO:         --> Unable to delete temporary file `C:\Users\bertc\Downloads\testcase_2\SRTM\30M_N29E030.nc`.
2024-07-04 00:16:32,390      INFO:         --> Unable to delete temporary file `C:\Users\bertc\Downloads\testcase_2\SRTM\30M_N29E031.nc`.
2024-07-04 00:16:32,390      INFO:             > timesize: 1 [2000-02-11T00:00, ..., 2000-02-11T00:00]

MODIS

2024-07-04 00:30:11,528      INFO:     --> Collecting `lst` from `MODIS.MYD11A1.061`.
2024-07-04 00:30:24,051      INFO:         --> Applying 'mask_bitwise_qa' to `lst`.
2024-07-04 00:30:24,306      INFO:         --> Applying 'expand_time_dim' to `lst`.
2024-07-04 00:30:24,307      INFO:         --> Saving merged data.
2024-07-04 00:30:26,543      INFO:             > peak-memory-usage: 5.5MB, execution-time: 0:00:02.236208.
2024-07-04 00:30:26,545      INFO:             > chunksize|dimsize: [time: 13|13, y: 104|104, x: 130|130], crs: EPSG:4326
2024-07-04 00:30:26,552      INFO:         --> Unable to delete temporary file `C:\Users\bertc\Downloads\testcase_2\MODIS\MYD11A1.061_h20v06.nc`.

TERRA

2024-07-04 00:57:24,473      INFO:             --> (2/6) Processing `PROBAV_S5_TOC_X21Y04_20200311_100M_V201`.
2024-07-04 00:57:24,473      INFO:                 --> (1/6) Downloading `NDVI`.
2024-07-04 00:57:36,053      INFO:                 --> (2/6) Downloading `SM`.
2024-07-04 00:57:47,056      INFO:                 --> (3/6) Downloading `BLUE`.
2024-07-04 00:57:58,333      INFO:                 --> (4/6) Downloading `NIR`.
2024-07-04 00:58:09,412      INFO:                 --> (5/6) Downloading `RED`.
2024-07-04 00:58:21,307      INFO:                 --> (6/6) Downloading `SWIR`.
2024-07-04 00:58:23,162      INFO:                 --> Applying 'mask_bitwise_qa' to `ndvi`.
2024-07-04 00:58:23,162      INFO:                 --> Applying 'calc_r0' to `r0`.
2024-07-04 00:58:23,276      INFO:                 --> Applying 'mask_bitwise_qa' to `r0`.
2024-07-04 00:58:23,277      INFO:                 --> Saving PROBAV_S5_TOC_X21Y04_20200311_100M_V201.nc.
2024-07-04 00:58:27,157      INFO:                     > peak-memory-usage: 89.8MB, execution-time: 0:00:03.879170.
2024-07-04 00:58:27,157      INFO:                     > chunksize|dimsize: [time: 1|1, y: 813|813, x: 1015|1015], crs: None
2024-07-04 00:58:27,173      INFO:                 --> Unable to delete temporary file `C:\Users\bertc\Downloads\testcase_2\TERRA\PROBAV_S5_TOC_X21Y04_20200311_100M_V201_NDVI_temp.nc`.
2024-07-04 00:58:27,189      INFO:                 --> Unable to delete temporary file `C:\Users\bertc\Downloads\testcase_2\TERRA\PROBAV_S5_TOC_X21Y04_20200311_100M_V201_SM_temp.nc`.
2024-07-04 00:58:27,189      INFO:                 --> Unable to delete temporary file `C:\Users\bertc\Downloads\testcase_2\TERRA\PROBAV_S5_TOC_X21Y04_20200311_100M_V201_BLUE_temp.nc`.
2024-07-04 00:58:27,189      INFO:                 --> Unable to delete temporary file `C:\Users\bertc\Downloads\testcase_2\TERRA\PROBAV_S5_TOC_X21Y04_20200311_100M_V201_NIR_temp.nc`.
2024-07-04 00:58:27,212      INFO:                 --> Unable to delete temporary file `C:\Users\bertc\Downloads\testcase_2\TERRA\PROBAV_S5_TOC_X21Y04_20200311_100M_V201_RED_temp.nc`.
2024-07-04 00:58:27,212      INFO:                 --> Unable to delete temporary file `C:\Users\bertc\Downloads\testcase_2\TERRA\PROBAV_S5_TOC_X21Y04_20200311_100M_V201_SWIR_temp.nc`.