diff --git a/SEPTREFHUM.py b/SEPTREFHUM.py index 833f05531c803d1e751c6c89567d2d0b29fd0968..398c1217cc8ba7676f9260fba013dacd73288f17 100755 --- a/SEPTREFHUM.py +++ b/SEPTREFHUM.py @@ -253,7 +253,10 @@ for timestep in timesteps: # Merge the WARNING_STATUS and WHS variables into one GeoTIFF file with two bands. # The WARNING_STATUS should always be band #1 # We must delete the GeoTIFF file before merging - run_command(command=f'rm {result_tif_path}result_*{file_date}*.tif') + existing_result_files_for_date = f"{result_tif_path}result_*{file_date}*.tif" + files = glob.glob(existing_result_files_for_date) + if files: + run_command(command=f'rm {existing_result_files_for_date}') with open("/dev/null", "w") as devnull: run_command(command=f'gdal_translate -ot Int16 -of GTiff NETCDF:"{tmpfile_path}result_{file_date}.nc":WARNING_STATUS {tmpfile_path}result_WARNING_STATUS_{file_date}_lcc.tif', stdout=devnull) run_command(command=f'gdal_translate -ot Float32 -of GTiff NETCDF:"{tmpfile_path}result_{file_date}.nc":WHS {tmpfile_path}result_{file_date}_lcc.tif', stdout=devnull)