Skip to content

Commit

Permalink
Removed the preload stuff in favor of using chunks=None in bias and b…
Browse files Browse the repository at this point in the history
…ase handler kwargs.
  • Loading branch information
bnb32 committed Oct 17, 2024
1 parent 532eb4d commit 4c8bada
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 45 deletions.
25 changes: 1 addition & 24 deletions sup3r/bias/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ def __init__(
base_handler_kwargs=None,
bias_handler_kwargs=None,
decimals=None,
match_zero_rate=False,
pre_load=True,
match_zero_rate=False
):
"""
Parameters
Expand Down Expand Up @@ -101,10 +100,6 @@ class is used, all data will be loaded in this class'
will not be mean-centered. This helps resolve the issue where
global climate models produce too many days with small
precipitation totals e.g., the "drizzle problem" [Polade2014]_.
pre_load : bool
Flag to preload all data needed for bias correction. This is
currently recommended to improve performance with the new sup3r
data handler access patterns
References
----------
Expand Down Expand Up @@ -182,29 +177,11 @@ class is used, all data will be loaded in this class'
distance_upper_bound=self.distance_upper_bound,
)

if pre_load:
self.pre_load()

self.out = None
self._init_out()

logger.info('Finished initializing DataRetrievalBase.')

def pre_load(self):
"""Preload all data needed for bias correction. This is currently
recommended to improve performance with the new sup3r data handler
access patterns"""

if hasattr(self.base_dh, 'compute'):
logger.info('Pre loading baseline unbiased data into memory...')
self.base_dh.data.compute()
logger.info('Finished pre loading baseline unbiased data.')

if hasattr(self.bias_dh, 'compute'):
logger.info('Pre loading historical biased data into memory...')
self.bias_dh.data.compute()
logger.info('Finished pre loading historical biased data.')

@abstractmethod
def _init_out(self):
"""Initialize output arrays"""
Expand Down
23 changes: 2 additions & 21 deletions sup3r/bias/qdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ def __init__(self,
sampling='linear',
log_base=10,
n_time_steps=24,
window_size=120,
pre_load=True,
window_size=120
):
"""
Parameters
Expand Down Expand Up @@ -156,10 +155,6 @@ class to be retrieved from the rex/sup3r library. If a
Total time window period in days to be considered for each time QDM
is calculated. For instance, `window_size=30` with
`n_time_steps=12` would result in approximately monthly estimates.
pre_load : bool
Flag to preload all data needed for bias correction. This is
currently recommended to improve performance with the new sup3r
data handler access patterns
See Also
--------
Expand Down Expand Up @@ -211,8 +206,7 @@ class to be retrieved from the rex/sup3r library. If a
base_handler_kwargs=base_handler_kwargs,
bias_handler_kwargs=bias_handler_kwargs,
decimals=decimals,
match_zero_rate=match_zero_rate,
pre_load=False,
match_zero_rate=match_zero_rate
)

self.bias_fut_fps = bias_fut_fps
Expand All @@ -224,19 +218,6 @@ class to be retrieved from the rex/sup3r library. If a
shape=self.shape,
**self.bias_handler_kwargs)

if pre_load:
self.pre_load()

def pre_load(self):
"""Preload all data needed for bias correction. This is currently
recommended to improve performance with the new sup3r data handler
access patterns"""
super().pre_load()
if hasattr(self.bias_fut_dh, 'compute'):
logger.info('Pre loading future biased data into memory...')
self.bias_fut_dh.data.compute()
logger.info('Finished pre loading future biased data.')

def _init_out(self):
"""Initialize output arrays `self.out`
Expand Down

0 comments on commit 4c8bada

Please sign in to comment.