Skip to content

Commit

Permalink
Align order of calls to _set_param_output_attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvothecoder committed Mar 19, 2024
1 parent 0247f05 commit 2257085
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
7 changes: 3 additions & 4 deletions e3sm_diags/driver/cosp_histogram_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ def run_diag(parameter: CoreParameter) -> CoreParameter:
ds_test_region = _subset_on_region(ds_test, var_key, region)
ds_ref_region = _subset_on_region(ds_ref, var_key, region)

parameter._set_param_output_attrs(
var_key, season, region, ref_name, ilev=None
)

# Make a copy of the regional datasets to overwrite the existing
# variable with its spatial average.
ds_test_avg = ds_test.copy()
Expand All @@ -83,6 +79,9 @@ def run_diag(parameter: CoreParameter) -> CoreParameter:
)
ds_diff_avg = _get_diff_of_avg(var_key, ds_test_avg, ds_ref_avg)

parameter._set_param_output_attrs(
var_key, season, region, ref_name, ilev=None
)
_save_data_metrics_and_plots(
parameter,
plot_func,
Expand Down
3 changes: 1 addition & 2 deletions e3sm_diags/driver/lat_lon_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ def _run_diags_2d(
The reference name.
"""
for region in regions:
parameter._set_param_output_attrs(var_key, season, region, ref_name, ilev=None)

(
ds_test_region,
ds_test_region_regrid,
Expand All @@ -171,6 +169,7 @@ def _run_diags_2d(
ds_diff_region,
)

parameter._set_param_output_attrs(var_key, season, region, ref_name, ilev=None)
_save_data_metrics_and_plots(
parameter,
plot_func,
Expand Down
3 changes: 1 addition & 2 deletions e3sm_diags/driver/polar_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ def _run_diags_2d(
The reference name.
"""
for region in regions:
parameter._set_param_output_attrs(var_key, season, region, ref_name, ilev=None)

(
ds_test_region,
ds_test_region_regrid,
Expand All @@ -145,6 +143,7 @@ def _run_diags_2d(
ds_diff_region,
)

parameter._set_param_output_attrs(var_key, season, region, ref_name, ilev=None)
_save_data_metrics_and_plots(
parameter,
plot_func,
Expand Down
6 changes: 3 additions & 3 deletions e3sm_diags/driver/zonal_mean_2d_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ def _run_diags_3d(
)

# Set parameter attributes for output files.
parameter.var_region = "global"
parameter.output_file = "-".join([ref_name, var_key, season, parameter.regions[0]])
parameter.main_title = str(" ".join([var_key, season]))
parameter._set_param_output_attrs(
var_key, season, parameter.regions[0], ref_name, ilev=None
)

_save_data_metrics_and_plots(
parameter,
Expand Down
6 changes: 2 additions & 4 deletions e3sm_diags/driver/zonal_mean_xy_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,10 @@ def _run_diags_2d(
for region in regions:
logger.info(f"Selected region: {region}")

parameter._set_param_output_attrs(var_key, season, region, ref_name, ilev=None)

da_test_1d, da_ref_1d = _calc_zonal_mean(ds_test, ds_ref, var_key)
da_diff_1d = _get_diff_of_zonal_means(da_test_1d, da_ref_1d)

parameter._set_param_output_attrs(var_key, season, region, ref_name, ilev=None)
_save_data_metrics_and_plots(
parameter,
plot_func,
Expand Down Expand Up @@ -208,11 +207,10 @@ def _run_diags_3d(
for region in regions:
logger.info(f"Selected region: {region}")

parameter._set_param_output_attrs(var_key, season, region, ref_name, ilev)

da_test_1d, da_ref_1d = _calc_zonal_mean(ds_test_ilev, ds_ref_ilev, var_key)
da_diff_1d = _get_diff_of_zonal_means(da_test_1d, da_ref_1d)

parameter._set_param_output_attrs(var_key, season, region, ref_name, ilev)
_save_data_metrics_and_plots(
parameter,
plot_func,
Expand Down

0 comments on commit 2257085

Please sign in to comment.