Skip to content

Commit

Permalink
Merge pull request #20 from ShervanGharari/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ShervanGharari authored May 31, 2021
2 parents 08b4792 + b376f85 commit 6100f4c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions easymore/easymore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
'shapely',
'pyshp',
'pysheds',
'osgeo',
'gdal',
'geovoronoi',
'json5',
'rasterio']
Expand Down

0 comments on commit 6100f4c

Please sign in to comment.