Skip to content

Commit

Permalink
Merge pull request #222 from NREL/gb/bug_bc_import
Browse files Browse the repository at this point in the history
fixed bias calc class import path
  • Loading branch information
grantbuster committed Jul 1, 2024
2 parents 5dda178 + 505bc00 commit a5f582f
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
3 changes: 2 additions & 1 deletion sup3r/bias/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .bias_transforms import (global_linear_bc, local_linear_bc,
local_qdm_bc, monthly_local_linear_bc)
from .bias_calc import (LinearCorrection, MonthlyLinearCorrection,
SkillAssessment)
MonthlyScalarCorrection, SkillAssessment)
from .qdm import QuantileDeltaMappingCorrection

__all__ = [
Expand All @@ -13,6 +13,7 @@
"monthly_local_linear_bc",
"LinearCorrection",
"MonthlyLinearCorrection",
"MonthlyScalarCorrection",
"QuantileDeltaMappingCorrection",
"SkillAssessment",
]
2 changes: 1 addition & 1 deletion sup3r/bias/bias_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def get_node_cmd(cls, config):
import_str = 'import time;\n'
import_str += 'from gaps import Status;\n'
import_str += 'from rex import init_logger;\n'
import_str += f'from sup3r.bias.bias_calc import {cls.__name__};\n'
import_str += f'from sup3r.bias import {cls.__name__};\n'

if not hasattr(cls, 'run'):
msg = ('I can only get you a node command for subclasses of '
Expand Down
2 changes: 1 addition & 1 deletion sup3r/bias/bias_calc_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def from_config(ctx, config_file, verbose=False, pipeline_step=None):
exec_kwargs = config.get('execution_control', {})
hardware_option = exec_kwargs.pop('option', 'local')
calc_class_name = config['bias_calc_class']
BiasCalcClass = getattr(sup3r.bias.bias_calc, calc_class_name)
BiasCalcClass = getattr(sup3r.bias, calc_class_name)
basename = config['job_name']
log_pattern = config.get('log_pattern', None)

Expand Down
14 changes: 7 additions & 7 deletions sup3r/bias/bias_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def get_spatial_bc_quantiles(lat_lon: np.array,
Recover the parameters that describe the statistical distribution
previously estimated with
:class:`~sup3r.bias.bias_calc.QuantileDeltaMappingCorrection` for three
:class:`~sup3r.bias.qdm.QuantileDeltaMappingCorrection` for three
datasets: ``base`` (historical reference), ``bias`` (historical biased
reference), and ``bias_fut`` (the future biased dataset, usually the data
to correct).
Expand Down Expand Up @@ -119,27 +119,27 @@ def get_spatial_bc_quantiles(lat_lon: np.array,
the ``base_dset``. It has a shape of (I, J, P), where (I, J) are the
same first two dimensions of the given `lat_lon` and P is the number
of parameters and depends on the type of distribution. See
:class:`~sup3r.bias.bias_calc.QuantileDeltaMappingCorrection` for more
:class:`~sup3r.bias.qdm.QuantileDeltaMappingCorrection` for more
details.
bias : np.array
Parameters used to define the statistical distribution estimated for
(historical) ``feature_name``. It has a shape of (I, J, P), where
(I, J) are the same first two dimensions of the given `lat_lon` and P
is the number of parameters and depends on the type of distribution.
See :class:`~sup3r.bias.bias_calc.QuantileDeltaMappingCorrection` for
See :class:`~sup3r.bias.qdm.QuantileDeltaMappingCorrection` for
more details.
bias_fut : np.array
Parameters used to define the statistical distribution estimated for
(future) ``feature_name``. It has a shape of (I, J, P), where (I, J)
are the same first two dimensions of the given `lat_lon` and P is the
number of parameters used and depends on the type of distribution. See
:class:`~sup3r.bias.bias_calc.QuantileDeltaMappingCorrection` for more
:class:`~sup3r.bias.qdm.QuantileDeltaMappingCorrection` for more
details.
cfg : dict
Metadata used to guide how to use of the previous parameters on
reconstructing the statistical distributions. For instance,
`cfg['dist']` defines the type of distribution. See
:class:`~sup3r.bias.bias_calc.QuantileDeltaMappingCorrection` for more
:class:`~sup3r.bias.qdm.QuantileDeltaMappingCorrection` for more
details, including which metadata is saved.
Warnings
Expand All @@ -150,7 +150,7 @@ def get_spatial_bc_quantiles(lat_lon: np.array,
See Also
--------
sup3r.bias.bias_calc.QuantileDeltaMappingCorrection
sup3r.bias.qdm.QuantileDeltaMappingCorrection
Estimate the statistical distributions loaded here.
Examples
Expand Down Expand Up @@ -458,7 +458,7 @@ def local_qdm_bc(data: np.array,
See Also
--------
sup3r.bias.bias_calc.QuantileDeltaMappingCorrection :
sup3r.bias.qdm.QuantileDeltaMappingCorrection :
Estimate probability distributions required by QDM method
Notes
Expand Down
2 changes: 1 addition & 1 deletion sup3r/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def bias_calc(ctx, verbose):
arguments required to call the
The config has high level ``bias_calc_class`` and ``jobs`` keys. The
``bias_calc_class`` is a class name from the :mod:`sup3r.bias.bias_calc`
``bias_calc_class`` is a class name from the :mod:`sup3r.bias`
module, and the ``jobs`` argument is a list of kwargs required to
initialize the ``bias_calc_class`` and run the ``bias_calc_class.run()``
method (for example, see
Expand Down
2 changes: 1 addition & 1 deletion sup3r/preprocessing/data_handling/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,7 @@ def qdm_bc(self,
Bias correct this DataHandler's data with Quantile Delta Mapping. The
required statistical distributions should be pre-calculated using
:class:`sup3r.bias.bias_calc.QuantileDeltaMappingCorrection`.
:class:`sup3r.bias.qdm.QuantileDeltaMappingCorrection`.
Warning: There is no guarantee that the coefficients from ``bc_files``
match the resource processed here. Be careful choosing ``bc_files``.
Expand Down

0 comments on commit a5f582f

Please sign in to comment.