Skip to content

Commit

Permalink
Merge pull request #265 from tsjackson-noaa/hotfix
Browse files Browse the repository at this point in the history
Corrects bugs in GFDL CMIP6 DataSource classes which were introduced by PR NOAA-GFDL/MDTF-diagnostics/#161.
  • Loading branch information
tsjackson-noaa authored Aug 9, 2021
2 parents 0e27ddb + bb15e43 commit 4a634fd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
24 changes: 14 additions & 10 deletions sites/NOAA_GFDL/gfdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ def __init__(self, case_dict, parent):

@util.mdtf_dataclass
class GFDL_UDA_CMIP6DataSourceAttributes(data_sources.CMIP6DataSourceAttributes):
def __post_init__(self, model=None, experiment=None):
def __post_init__(self, log=_log, model=None, experiment=None):
self.CASE_ROOT_DIR = os.sep + os.path.join('uda', 'CMIP6')
super(GFDL_UDA_CMIP6DataSourceAttributes, self).__post_init__(model, experiment)
super(GFDL_UDA_CMIP6DataSourceAttributes, self).__post_init__(log, model, experiment)

class Gfdludacmip6DataManager(
data_sources.CMIP6ExperimentSelectionMixin,
Expand All @@ -247,15 +247,16 @@ class Gfdludacmip6DataManager(
_FileRegexClass = cmip6.CMIP6_DRSPath
_DirectoryRegex = cmip6.drs_directory_regex
_AttributesClass = GFDL_UDA_CMIP6DataSourceAttributes
_fetch_method = "cp" # copy locally instead of symlink due to NFS hanging
_convention = "CMIP" # hard-code naming convention
col_spec = data_sources.cmip6LocalFileDataSource_col_spec
_fetch_method = "cp" # copy locally instead of symlink due to NFS hanging


@util.mdtf_dataclass
class GFDL_archive_CMIP6DataSourceAttributes(data_sources.CMIP6DataSourceAttributes):
def __post_init__(self, model=None, experiment=None):
def __post_init__(self, log=_log, model=None, experiment=None):
self.CASE_ROOT_DIR = os.sep + os.path.join('archive','pcmdi','repo','CMIP6')
super(GFDL_archive_CMIP6DataSourceAttributes, self).__post_init__(model, experiment)
super(GFDL_archive_CMIP6DataSourceAttributes, self).__post_init__(log, model, experiment)

class Gfdlarchivecmip6DataManager(
data_sources.CMIP6ExperimentSelectionMixin,
Expand All @@ -267,15 +268,16 @@ class Gfdlarchivecmip6DataManager(
_FileRegexClass = cmip6.CMIP6_DRSPath
_DirectoryRegex = cmip6.drs_directory_regex
_AttributesClass = GFDL_archive_CMIP6DataSourceAttributes
_fetch_method = "gcp"
_convention = "CMIP" # hard-code naming convention
col_spec = data_sources.cmip6LocalFileDataSource_col_spec
_fetch_method = "gcp"


@util.mdtf_dataclass
class GFDL_data_CMIP6DataSourceAttributes(data_sources.CMIP6DataSourceAttributes):
def __post_init__(self, model=None, experiment=None):
def __post_init__(self, log=_log, model=None, experiment=None):
self.CASE_ROOT_DIR = os.sep + os.path.join('data_cmip6', 'CMIP6')
super(GFDL_data_CMIP6DataSourceAttributes, self).__post_init__(model, experiment)
super(GFDL_data_CMIP6DataSourceAttributes, self).__post_init__(log, model, experiment)

class Gfdldatacmip6DataManager(
data_sources.CMIP6ExperimentSelectionMixin,
Expand All @@ -286,6 +288,9 @@ class Gfdldatacmip6DataManager(
_FileRegexClass = cmip6.CMIP6_DRSPath
_DirectoryRegex = cmip6.drs_directory_regex
_AttributesClass = GFDL_data_CMIP6DataSourceAttributes
_convention = "CMIP" # hard-code naming convention
col_spec = data_sources.cmip6LocalFileDataSource_col_spec
_fetch_method = "gcp"

# RegexPattern that matches any string (path) that doesn't end with ".nc".
_ignore_non_nc_regex = util.RegexPattern(r".*(?<!\.nc)")
Expand Down Expand Up @@ -457,8 +462,7 @@ def CATALOG_DIR(self):
assert (hasattr(self, 'attrs') and hasattr(self.attrs, 'CASE_ROOT_DIR'))
return self.attrs.CASE_ROOT_DIR

@staticmethod
def _filter_column(df, col_name, func, obj_name):
def _filter_column(self, df, col_name, func, obj_name):
values = list(df[col_name].drop_duplicates())
if len(values) <= 1:
# unique value, no need to filter
Expand Down
2 changes: 1 addition & 1 deletion src/data_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ class CMIP6DataSourceAttributes(dm.DataSourceAttributesBase):
experiment: dataclasses.InitVar = "" # synonym for experiment_id
CATALOG_DIR: str = dataclasses.field(init=False)

def __post_init__(self, model=None, experiment=None, log=_log):
def __post_init__(self, log=_log, model=None, experiment=None):
super(CMIP6DataSourceAttributes, self).__post_init__(log=log)
config = core.ConfigManager()
cv = cmip6.CMIP6_CVs()
Expand Down

0 comments on commit 4a634fd

Please sign in to comment.