From 8b11c289c00a619b96bc0c605c4665c85f54df17 Mon Sep 17 00:00:00 2001 From: bnb32 Date: Thu, 16 Feb 2023 06:55:43 -0700 Subject: [PATCH 1/2] NSRDB resource is called with `mode` in some nsrdb tests. Adding this to AbstractInterpolatedResource.__init__ --- rex/renewable_resource.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rex/renewable_resource.py b/rex/renewable_resource.py index f9ba48da..e42d6977 100644 --- a/rex/renewable_resource.py +++ b/rex/renewable_resource.py @@ -165,7 +165,7 @@ class AbstractInterpolatedResource(BaseResource): """Air Temperature and Pressure lapse rate in C/km and Pa/km""" def __init__(self, h5_file, unscale=True, str_decode=True, group=None, - use_lapse_rate=True, hsds=False, hsds_kwargs=None): + use_lapse_rate=True, mode='r', hsds=False, hsds_kwargs=None): """ Parameters ---------- @@ -186,6 +186,8 @@ def __init__(self, h5_file, unscale=True, str_decode=True, group=None, `False`, the value of these variables at the single available hub-height will be returned for *all* requested heights. This option has no effect if data is available at multiple hub-heights. + mode : str, optional + Mode to instantiate h5py.File instance, by default 'r' hsds : bool, optional Boolean flag to use h5pyd to handle .h5 'files' hosted on AWS behind HSDS, by default False @@ -196,7 +198,8 @@ def __init__(self, h5_file, unscale=True, str_decode=True, group=None, self._interp_var = None self._use_lapse = use_lapse_rate super().__init__(h5_file, unscale=unscale, str_decode=str_decode, - group=group, hsds=hsds, hsds_kwargs=hsds_kwargs) + group=group, hsds=hsds, mode=mode, + hsds_kwargs=hsds_kwargs) # this is where self.heights or self.depths gets set self._interpolation_variable = self._parse_interp_var(self.datasets) From b9b13d0d9ff6ebf8914b262a26ed21058a9a5fd0 Mon Sep 17 00:00:00 2001 From: bnb32 Date: Thu, 16 Feb 2023 08:54:34 -0700 Subject: [PATCH 2/2] Changed kwarg order so mode is second. --- rex/renewable_resource.py | 9 +++++---- rex/resource.py | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/rex/renewable_resource.py b/rex/renewable_resource.py index e42d6977..02d75b85 100644 --- a/rex/renewable_resource.py +++ b/rex/renewable_resource.py @@ -164,13 +164,16 @@ class AbstractInterpolatedResource(BaseResource): LAPSE_RATES = {'temperature': 6.56, 'pressure': 11_109} """Air Temperature and Pressure lapse rate in C/km and Pa/km""" - def __init__(self, h5_file, unscale=True, str_decode=True, group=None, - use_lapse_rate=True, mode='r', hsds=False, hsds_kwargs=None): + def __init__(self, h5_file, mode='r', unscale=True, str_decode=True, + group=None, use_lapse_rate=True, hsds=False, + hsds_kwargs=None): """ Parameters ---------- h5_file : str Path to .h5 resource file + mode : str, optional + Mode to instantiate h5py.File instance, by default 'r' unscale : bool Boolean flag to automatically unscale variables on extraction str_decode : bool @@ -186,8 +189,6 @@ def __init__(self, h5_file, unscale=True, str_decode=True, group=None, `False`, the value of these variables at the single available hub-height will be returned for *all* requested heights. This option has no effect if data is available at multiple hub-heights. - mode : str, optional - Mode to instantiate h5py.File instance, by default 'r' hsds : bool, optional Boolean flag to use h5pyd to handle .h5 'files' hosted on AWS behind HSDS, by default False diff --git a/rex/resource.py b/rex/resource.py index 3b6169f4..7dea17d0 100644 --- a/rex/resource.py +++ b/rex/resource.py @@ -576,13 +576,15 @@ class BaseResource(ABC): ADD_ATTR = 'add_offset' UNIT_ATTR = 'units' - def __init__(self, h5_file, unscale=True, str_decode=True, - group=None, mode='r', hsds=False, hsds_kwargs=None): + def __init__(self, h5_file, mode='r', unscale=True, str_decode=True, + group=None, hsds=False, hsds_kwargs=None): """ Parameters ---------- h5_file : str Path to .h5 resource file + mode : str, optional + Mode to instantiate h5py.File instance, by default 'r' unscale : bool, optional Boolean flag to automatically unscale variables on extraction, by default True @@ -592,8 +594,6 @@ def __init__(self, h5_file, unscale=True, str_decode=True, by default True group : str, optional Group within .h5 resource file to open, by default None - mode : str, optional - Mode to instantiate h5py.File instance, by default 'r' hsds : bool, optional Boolean flag to use h5pyd to handle .h5 'files' hosted on AWS behind HSDS, by default False