Skip to content

Commit

Permalink
rename functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jtmims committed Dec 17, 2024
1 parent 9d52d90 commit d5ee2d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/data_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def read_varlist(self, parent, append_vars: bool=False):
def set_date_range(self, startdate: str, enddate: str):
self.date_range = util.DateRange(start=startdate, end=enddate)

def set_query_base(self, var: varlist_util.VarlistEntry, path_regex: str):
def set_query(self, var: varlist_util.VarlistEntry, path_regex: str):
realm_regex = var.realm + '*'
date_range = var.T.range

Check warning

Code scanning / CodeQL

Variable defined multiple times Warning

This assignment to 'date_range' is unnecessary as it is
redefined
before this value is used.
This assignment to 'date_range' is unnecessary as it is
redefined
before this value is used.
var_id = var.name
Expand Down Expand Up @@ -126,7 +126,8 @@ class CMIPDataSource(DataSourceBase):
convention: str = "CMIP"

def set_query(self, var: varlist_util.VarlistEntry, path_regex: str):
self.set_query_base(var, path_regex)
super().set_query(var, path_regex)
return

@data_source.maker
class CESMDataSource(DataSourceBase):
Expand All @@ -139,7 +140,8 @@ class CESMDataSource(DataSourceBase):
convention: str = "CESM"

def set_query(self, var: varlist_util.VarlistEntry, path_regex: str):
self.set_query_base(var, path_regex)
super().set_query(var, path_regex)
return

@data_source.maker
class GFDLDataSource(DataSourceBase):
Expand All @@ -152,7 +154,8 @@ class GFDLDataSource(DataSourceBase):
convention: str = "GFDL"

def set_query(self, var: varlist_util.VarlistEntry, path_regex: str):
self.set_query_base(var, path_regex)
super().set_query(var, path_regex)
# this is hacky, but prevents the framework from grabbing from ice_1x1deg
if self.query['realm'] == 'seaIce*':
self.query['realm'] = 'ice'
return
4 changes: 2 additions & 2 deletions src/preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def execute(self, var: varlist_util.VarlistEntry,
pass


class PercentTo01Function(PreprocessorFunctionBase):
class PercentConversionFunction(PreprocessorFunctionBase):
"""A PreprocessorFunction which convers the dependent variable's units and values,
for the specific case of percentages. ``0-1`` are not defined in the UDUNITS-2
library. So, this function handles the case where we have to convert from
Expand Down Expand Up @@ -724,7 +724,7 @@ def _functions(self):
"""
# normal operation: run all functions
return [
AssociatedVariablesFunction, PercentTo01Function,
AssociatedVariablesFunction, PercentConversionFunction,
PrecipRateToFluxFunction, ConvertUnitsFunction,
ExtractLevelFunction, RenameVariablesFunction
]
Expand Down

0 comments on commit d5ee2d7

Please sign in to comment.