Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fix for checking is_time_series() property based on data_type attr #881

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import os
from e3sm_diags.parameter.core_parameter import CoreParameter
from e3sm_diags.run import runner

param = CoreParameter()

param.reference_data_path = (
"/global/cfs/cdirs/e3sm/diagnostics/observations/Atm/time-series"
)
param.test_data_path = "/global/cfs/cdirs/e3sm/chengzhu/eamxx/post/data/rgr"
param.test_name = "eamxx_decadal"
param.seasons = ["ANN"]
# param.save_netcdf = True

param.ref_timeseries_input = True
# Years to slice the ref data, base this off the years in the filenames.
param.ref_start_yr = "1996"
param.ref_end_yr = "1996"

prefix = "/global/cfs/cdirs/e3sm/www/cdat-migration-fy24/877-attr-err"
param.results_dir = os.path.join(prefix, "eamxx_decadal_1996_1024_edv2")

runner.sets_to_run = [
"lat_lon",
# "zonal_mean_xy",
# "zonal_mean_2d",
# "zonal_mean_2d_stratosphere",
# "polar",
# "cosp_histogram",
# "meridional_mean_2d",
# "annual_cycle_zonal_mean",
]

runner.run_diags([param])
4 changes: 3 additions & 1 deletion e3sm_diags/driver/utils/dataset_xr.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ def __init__(

@property
def is_time_series(self):
if self.parameter.ref_timeseries_input or self.parameter.test_timeseries_input:
if (self.data_type == "ref" and self.parameter.ref_timeseries_input) or (
self.data_type == "test" and self.parameter.test_timeseries_input
):
return True
else:
return False
Comment on lines +166 to 171
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more explicit version of the main code below:

def is_timeseries(self):
"""
Return True if this dataset is for timeseries data.
"""
if self.ref:
return getattr(self.parameters, "ref_timeseries_input", False)
else:
return getattr(self.parameters, "test_timeseries_input", False)

Expand Down
Loading