Skip to content

Commit

Permalink
Merge pull request #192 from NREL/pp/reV-0.8.0_compat
Browse files Browse the repository at this point in the history
reV 0.8.0 compatibility
  • Loading branch information
ppinchuk committed Aug 15, 2023
2 parents 4bc4558 + d35fe59 commit e173d01
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion reVX/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
reVX version number
"""

__version__ = "0.3.52"
__version__ = "0.3.53"
18 changes: 9 additions & 9 deletions reVX/wind_dirs/mean_wind_dirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ class MeanWindDirections(Aggregation):
Then convert to equivalent sc_point_gid
"""

def __init__(self, res_h5_fpath, excl_fpath, wdir_dsets,
def __init__(self, excl_fpath, wdir_dsets,
tm_dset='techmap_wtk', excl_dict=None,
area_filter_kernel='queen', min_area=None,
resolution=128, excl_area=None):
"""
Parameters
----------
res_h5_fpath : str
Filepath to .h5 file containing wind direction data
excl_fpath : str
Filepath to exclusions h5 with techmap dataset.
wdir_dsets : str | list
Expand Down Expand Up @@ -65,7 +63,7 @@ def __init__(self, res_h5_fpath, excl_fpath, wdir_dsets,
logger.error(msg)
raise ValueError(msg)

super().__init__(excl_fpath, res_h5_fpath, tm_dset, *wdir_dsets,
super().__init__(excl_fpath, tm_dset, *wdir_dsets,
excl_dict=excl_dict,
area_filter_kernel=area_filter_kernel,
min_area=min_area,
Expand Down Expand Up @@ -180,12 +178,14 @@ def run_serial(cls, excl_fpath, h5_fpath, tm_dset, *wind_dir_dset,

return agg_out

def aggregate(self, max_workers=None, sites_per_worker=1000):
def aggregate(self, res_h5_fpath, max_workers=None, sites_per_worker=1000):
"""
Average wind directions to sc_points
Parameters
----------
res_h5_fpath : str
Filepath to .h5 file containing wind direction data
max_workers : int | None
Number of cores to run summary on. None is all
available cpus.
Expand All @@ -198,7 +198,7 @@ def aggregate(self, max_workers=None, sites_per_worker=1000):
agg : dict
Aggregated values for each aggregation dataset
"""
agg = super().aggregate(max_workers=max_workers,
agg = super().aggregate(res_h5_fpath, max_workers=max_workers,
sites_per_worker=sites_per_worker)

return agg
Expand Down Expand Up @@ -254,15 +254,15 @@ def run(cls, res_h5_fpath, excl_fpath, wdir_dsets,
agg : dict
Aggregated values for each aggregation dataset
"""
wdir = cls(res_h5_fpath, excl_fpath, wdir_dsets, tm_dset=tm_dset,
wdir = cls(excl_fpath, wdir_dsets, tm_dset=tm_dset,
excl_dict=excl_dict, area_filter_kernel=area_filter_kernel,
min_area=min_area, resolution=resolution,
excl_area=excl_area)

agg = wdir.aggregate(max_workers=max_workers,
agg = wdir.aggregate(res_h5_fpath, max_workers=max_workers,
sites_per_worker=sites_per_worker)

if out_fpath is not None:
wdir.save_agg_to_h5(out_fpath, agg)
wdir.save_agg_to_h5(res_h5_fpath, out_fpath, agg)

return agg
10 changes: 6 additions & 4 deletions reVX/wind_dirs/prominent_wind_dirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ def __init__(self, power_rose_h5_fpath, excl_fpath,
from the profile transform attribute in excl_fpath.
"""
log_versions(logger)
super().__init__(excl_fpath, power_rose_h5_fpath, tm_dset, agg_dset,
resolution=resolution, excl_area=excl_area)
self.power_rose_h5_fpath = power_rose_h5_fpath
super().__init__(excl_fpath, tm_dset, agg_dset, resolution=resolution,
excl_area=excl_area)

@classmethod
def _map_direction_pos(cls, power_rose_h5_fpath):
Expand Down Expand Up @@ -168,15 +169,16 @@ def prominent_directions(self, max_workers=None,
Update meta data table with neighboring supply curve point gids
and power-rose value at each cardinal direction
"""
agg_out = self.aggregate(max_workers=max_workers,
agg_out = self.aggregate(self.power_rose_h5_fpath,
max_workers=max_workers,
sites_per_worker=sites_per_worker)

meta = agg_out.pop('meta')
neighbor_gids = self._get_neighbors(self._excl_fpath,
meta['sc_point_gid'].values,
resolution=self._resolution)

dir_pos = self._map_direction_pos(self._h5_fpath)
dir_pos = self._map_direction_pos(self.power_rose_h5_fpath)
sc_pr = agg_out.pop('powerrose_100m')[dir_pos].T

columns = ['{}_pr'.format(d)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dask[array]>=2.8
fiona>=1.9.0
geopandas>=0.8
NREL-gaps>=0.3.3
NREL-reV>=0.7.3
NREL-reV>=0.8.0
NREL-rex>=0.2.80
psycopg2-binary>=2.8
pyproj>=3.0.1
Expand Down

0 comments on commit e173d01

Please sign in to comment.