Skip to content

Commit

Permalink
Merge PR #287 (Fix dictionary key error for non-parallel plotting)
Browse files Browse the repository at this point in the history
This merge brings PR # (Fix dictionary key error when benchmark plots are
generated sequentially, by @yantosca) into the GCPy 1.4.2 development stream.

This fixes an error where a dictionary was not being properly appended
into a list in the benchmark plotting code, when parallel plotting
was disabled.

Signed-off-by: Bob Yantosca <[email protected]>
  • Loading branch information
yantosca committed Jan 26, 2024
2 parents 1fb87e4 + 7a2c321 commit a8c8b7d
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 15 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Example script `create_test_plot.py`, which can be used to check that GCPy has been installed properly
- GitHub action `build-gcpy-environment` which tests installation of the mamba environment specified in in `docs/source/environment.yml`

### Fixed
- Prevent overwriting of the `results` variable when parallel plotting is deactivated (`n_cores: 1`)

## [1.4.1] - 2023-12-08
### Fixed
- Now use the proper default value for the `--weightsdir` argument to `gcpy/file_regrid.py`
Expand Down
18 changes: 12 additions & 6 deletions gcpy/benchmark/modules/run_1yr_fullchem_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,8 +694,9 @@ def gcc_vs_gcc_mass_table(mon):
for mon in range(bmk_n_months)
)
else:
results = []
for mon in range(bmk_n_months):
results = gcc_vs_gcc_mass_table(mon)
results.append(gcc_vs_gcc_mass_table(mon))

# ==================================================================
# GCC vs GCC operations budgets tables
Expand Down Expand Up @@ -741,8 +742,9 @@ def gcc_vs_gcc_ops_budg(mon):
for mon in range(bmk_n_months)
)
else:
results = []
for mon in range(bmk_n_months):
results = gcc_vs_gcc_ops_budg(mon)
results.append(gcc_vs_gcc_ops_budg(mon))

# ==================================================================
# GCC vs GCC aerosols budgets/burdens tables
Expand Down Expand Up @@ -1255,8 +1257,9 @@ def gchp_vs_gcc_mass_table(mon):
for mon in range(bmk_n_months)
)
else:
results = []
for mon in range(bmk_n_months):
results = gchp_vs_gcc_mass_table(mon)
results.append(gchp_vs_gcc_mass_table(mon))

# ==================================================================
# GCHP vs GCC operations budgets tables
Expand Down Expand Up @@ -1311,8 +1314,9 @@ def gchp_vs_gcc_ops_budg(mon):
for mon in range(bmk_n_months)
)
else:
results = []
for mon in range(bmk_n_months):
results = gchp_vs_gcc_ops_budg(mon)
results.append(gchp_vs_gcc_ops_budg(mon))

# ==================================================================
# GCHP vs GCC aerosol budgets and burdens tables
Expand Down Expand Up @@ -1863,8 +1867,9 @@ def gchp_vs_gchp_mass_table(mon):
for mon in range(bmk_n_months)
)
else:
results = []
for mon in range(bmk_n_months):
results = gchp_vs_gchp_mass_table(mon)
results.append(gchp_vs_gchp_mass_table(mon))

# ==================================================================
# GCHP vs GCHP operations budgets tables
Expand Down Expand Up @@ -1921,8 +1926,9 @@ def gchp_vs_gchp_ops_budg(mon):
for mon in range(bmk_n_months)
)
else:
results = []
for mon in range(bmk_n_months):
results = gchp_vs_gchp_ops_budg(mon)
results.append(gchp_vs_gchp_ops_budg(mon))

# ==================================================================
# GCHP vs GCHP aerosol budgets and burdens tables
Expand Down
9 changes: 6 additions & 3 deletions gcpy/benchmark/modules/run_1yr_tt_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,9 @@ def gcc_vs_gcc_mass_table(mon):
for mon in range(bmk_n_months)
)
else:
results = []
for mon in range(bmk_n_months):
results = gcc_vs_gcc_mass_table(mon)
results.append(gcc_vs_gcc_mass_table(mon))

# ==================================================================
# GCC vs GCC operations budgets tables
Expand Down Expand Up @@ -837,8 +838,9 @@ def gchp_vs_gcc_mass_table(mon):
for mon in range(bmk_n_months)
)
else:
results = []
for mon in range(bmk_n_months):
results = gchp_vs_gcc_mass_table(mon)
results.append(gchp_vs_gcc_mass_table(mon))

# ==================================================================
# GCHP vs GCC operations budgets tables
Expand Down Expand Up @@ -1149,8 +1151,9 @@ def gchp_vs_gchp_mass_table(mon):
for mon in range(bmk_n_months)
)
else:
results = []
for mon in range(bmk_n_months):
results = gchp_vs_gchp_mass_table(mon)
results.append(gchp_vs_gchp_mass_table(mon))

# ==================================================================
# GCHP vs GCHP operations budgets tables
Expand Down
14 changes: 10 additions & 4 deletions gcpy/benchmark_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1503,17 +1503,21 @@ def createplots(filecat):
for _, filecat in enumerate(catdict)
)
else:
results = []
for _, filecat in enumerate(catdict):
results = createplots(filecat)
results.append(createplots(filecat))
# --------------------------------------------

dict_sfc = {list(result.keys())[0]: result[list(
result.keys())[0]]['sfc'] for result in results}
dict_500 = {list(result.keys())[0]: result[list(
result.keys())[0]]['500'] for result in results}
dict_zm = {list(result.keys())[0]: result[list(
result.keys())[0]]['zm'] for result in results}

print("stop here")
quit()

# ==============================================================
# Write the list of species having significant differences,
# which we need to fill out the benchmark approval forms.
Expand Down Expand Up @@ -1868,8 +1872,9 @@ def createfile_hco_cat(c):
for c in emis_cats
)
else:
results = []
for c in emis_cats:
results = createfile_hco_cat(c)
results.append(createfile_hco_cat(c))
# ---------------------------------------

dict_emis = {list(result.keys())[0]: result[list(result.keys())[0]]
Expand Down Expand Up @@ -1981,8 +1986,9 @@ def createfile_bench_cat(filecat):
for _, filecat in enumerate(catdict)
)
else:
results = []
for _, filecat in enumerate(catdict):
results = createfile_bench_cat(filecat)
results.append(createfile_bench_cat(filecat))
#------------------------------------------------

allcatspc = [spc for result in results for spc in result]
Expand Down
3 changes: 2 additions & 1 deletion gcpy/plot/compare_single_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -1152,8 +1152,9 @@ def get_extent_for_colors(dset, minlon, maxlon, minlat, maxlat):
for i in range(n_var)
)
else:
results = []
for i in range(n_var):
results = createfig(i, temp_dir)
results.append(createfig(i, temp_dir))
# ---------------------------------------

# update sig diffs after parallel calls
Expand Down
3 changes: 2 additions & 1 deletion gcpy/plot/compare_zonal_mean.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,8 +1046,9 @@ def createfig(ivar, temp_dir=''):
for i in range(n_var)
)
else:
results = []
for i in range(n_var):
results = createfig(i, temp_dir)
results.append(createfig(i, temp_dir))
# ---------------------------------------

# update sig diffs after parallel calls
Expand Down

0 comments on commit a8c8b7d

Please sign in to comment.