Skip to content

Commit

Permalink
alternative fix for .nc exo extract init signature issues
Browse files Browse the repository at this point in the history
  • Loading branch information
grantbuster committed Feb 2, 2024
1 parent 89f248f commit dec9ca0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
34 changes: 17 additions & 17 deletions sup3r/preprocessing/data_handling/exo_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@ def __init__(self,
self.shape = shape
self.res_kwargs = res_kwargs

# for subclasses
self._source_handler = None

if input_handler is None:
in_type = get_source_type(file_paths)
if in_type == 'nc':
Expand Down Expand Up @@ -569,20 +566,23 @@ def get_cache_file(self, feature, s_enhance, t_enhance, t_agg_factor):
class TopoExtractNC(TopoExtractH5):
"""TopoExtract for netCDF files"""

@property
def source_handler(self):
"""Get the DataHandlerNC object that handles the .nc source topography
data file."""
if self._source_handler is None:
logger.info('Getting topography for full domain from '
f'{self._exo_source}')
self._source_handler = DataHandlerNC(
self._exo_source,
features=['topography'],
worker_kwargs={'ti_workers': self.ti_workers},
val_split=0.0,
)
return self._source_handler
def __init__(self, *args, **kwargs):
"""Parameters
----------
args : list
Same positional arguments as TopoExtract
kwargs : dict
Same keyword arguments as TopoExtract
"""
super().__init__(*args, **kwargs)
logger.info('Getting topography for full domain from '
f'{self._exo_source}')
self.source_handler = DataHandlerNC(
self._exo_source,
features=['topography'],
worker_kwargs={'ti_workers': self.ti_workers},
val_split=0.0,
)

@property
def source_data(self):
Expand Down
2 changes: 0 additions & 2 deletions sup3r/preprocessing/data_handling/exogenous_data_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,6 @@ def get_exo_data(self, feature, s_enhance, t_enhance, s_agg_factor,
cache_data=self.cache_data,
cache_dir=self.cache_dir,
res_kwargs=self.res_kwargs)
sig = signature(exo_handler)
kwargs = {k: v for k, v in kwargs.items() if k in sig.parameters}
data = exo_handler(**kwargs).data
return data

Expand Down

0 comments on commit dec9ca0

Please sign in to comment.