diff --git a/easymore/easymore.py b/easymore/easymore.py index 0bdb348..14084c4 100644 --- a/easymore/easymore.py +++ b/easymore/easymore.py @@ -35,6 +35,7 @@ def __init__(self): self.remapped_var_lat = 'latitude' # name of the latitude variable in the new nc file; default 'latitude' self.remapped_var_lon = 'longitude' # name of the longitude variable in the new nc file; default 'longitude' self.remapped_dim_id = 'ID' # name of the ID dimension in the new nc file; default 'ID' + self.overwrite_existing_remap = True # Flag to automatically overwrite existing remapping files. If 'False', aborts the remapping procedure if a file is detected self.temp_dir = './temp/' # temp_dir self.output_dir = './output/' # output directory self.format_list = ['f8'] # float for the remapped values @@ -992,8 +993,13 @@ def __target_nc_creation(self): self.length_of_time = len(time_var) target_date_times = nc4.num2date(time_var,units = time_unit,calendar = time_cal) target_name = self.output_dir + self.case_name + '_remapped_' + target_date_times[0].strftime("%Y-%m-%d-%H-%M-%S")+'.nc' - if os.path.exists(target_name): # remove file if exists - os.remove(target_name) + if os.path.exists(target_name): + if self.overwrite_existing_remap: + print('Removing existing remapped .nc file.') + os.remove(target_name) + else: + print('Remapped .nc file already exists. Going to next file.') + continue # skip to next file for var in ncids.variables.values(): if var.name == self.var_time: time_dtype = str(var.dtype) diff --git a/setup.py b/setup.py index 12b4ce1..207e89b 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ 'shapely', 'pyshp', 'pysheds', - 'osgeo', + 'gdal', 'geovoronoi', 'json5', 'rasterio']