Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

NSRDB resource is called with mode in some nsrdb tests. Adding this… #146

Merged
merged 2 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions rex/renewable_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, 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
Expand All @@ -196,7 +199,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)
Expand Down
8 changes: 4 additions & 4 deletions rex/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down