Skip to content

Commit

Permalink
extende debugging and saving X array to file too when doing projections
Browse files Browse the repository at this point in the history
  • Loading branch information
JannisHoch committed Nov 13, 2020
1 parent a916f21 commit 56aa3dd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
14 changes: 12 additions & 2 deletions copro/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,19 @@ def create_XY(config, polygon_gdf, conflict_gdf):

def create_X(config, polygon_gdf, conflict_gdf=None):

X = data.initiate_X_data(config)
if config.get('pre_calc', 'XY') is '':

X = data.initiate_X_data(config)

X = data.fill_XY(X, config, conflict_gdf, polygon_gdf)

print('INFO: saving X data by default to file {}'.format(os.path.abspath(os.path.join(config.get('general', 'output_dir'), 'X.npy'))))
np.save(os.path.join(config.get('general', 'output_dir'),'X'), X)

else:

X = data.fill_XY(X, config, conflict_gdf, polygon_gdf)
print('INFO: loading XY data from file {}'.format(os.path.abspath(config.get('pre_calc', 'X'))))
X = np.load(os.path.abspath(config.get('pre_calc', 'X')), allow_pickle=True)

return X

Expand Down
4 changes: 4 additions & 0 deletions copro/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def nc_with_float_timestamp(extent_gdf, config, var_name, sim_year, stat_func='m
for i in range(len(extent_gdf)):
prov = extent_gdf.iloc[i]
zonal_stats = rstats.zonal_stats(prov.geometry, nc_arr_vals, affine=affine, stats=stat_func)
if (zonal_stats[0][stat_func] == None) and (config.getboolean('general', 'verbose')):
print('WARNING: NaN computed!')
list_out.append(zonal_stats[0][stat_func])

if config.getboolean('general', 'verbose'): print('DEBUG: ... done.')
Expand Down Expand Up @@ -126,6 +128,8 @@ def nc_with_continous_datetime_timestamp(extent_gdf, config, var_name, sim_year,
for i in range(len(extent_gdf)):
prov = extent_gdf.iloc[i]
zonal_stats = rstats.zonal_stats(prov.geometry, nc_arr_vals, affine=affine, stats=stat_func)
if (zonal_stats[0][stat_func] == None) and (config.getboolean('general', 'verbose')):
print('WARNING: NaN computed!')
list_out.append(zonal_stats[0][stat_func])

if config.getboolean('general', 'verbose'): print('DEBUG: ... done.')
Expand Down
2 changes: 0 additions & 2 deletions scripts/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ def main(cfg, projection_settings=[], verbose=False):
if verbose:
config.set('general', 'verbose', str(verbose))

if config.getboolean('general', 'verbose'): warnings.filterwarnings("default")

click.echo(click.style('\nINFO: reference run started\n', fg='cyan'))

#- selecting conflicts and getting area-of-interest and aggregation level
Expand Down

0 comments on commit 56aa3dd

Please sign in to comment.