Skip to content

Commit

Permalink
elev stochastic downselect should return gid not index
Browse files Browse the repository at this point in the history
  • Loading branch information
tobin-ford committed Feb 12, 2025
1 parent b541398 commit 73b884c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
6 changes: 5 additions & 1 deletion docs/source/whatsnew/releases/v0.5.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ Now, either of the following options work.
def myfunc(...):
....
Bug Fixes
-------------
- fixed an issue where pvdeg.geospatial.elevation_stochastic_downselect would return metadata row indicies which were downselected instead of named gids.


Contributors
-----------
- Tobin Ford (:ghuser:`tobin-ford`)
- Tobin Ford (:ghuser:`tobin-ford`)
4 changes: 3 additions & 1 deletion pvdeg/geospatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,9 @@ def elevation_stochastic_downselect(
a=len(coords), p=normalized_weights / np.sum(normalized_weights), size=m
)

return np.unique(selected_indicies)
return meta_df.index.values[np.unique(selected_indicies)]
#return meta_df.iloc[np.unique(selected_indicies)].index.values
#return np.unique(selected_indicies)


def interpolate_analysis(
Expand Down
17 changes: 10 additions & 7 deletions pvdeg/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ def downselect_CONUS(
) -> None:
"""Downselect US to contiguous US geospatial data"""

geo_weather, geo_meta = self.geospatial_data()
geo_weather, geo_meta = self.get_geospatial_data()

geo_meta = geo_meta[geo_meta['state'] != "Alaska"]
geo_meta = geo_meta[geo_meta['state'] != "Hawaii"]
Expand Down Expand Up @@ -1497,7 +1497,7 @@ def classify_mountains_weights(
return

def classify_feature(
self,
self,
feature_name=None,
resolution="10m",
radius=None,
Expand Down Expand Up @@ -1594,7 +1594,7 @@ def downselect_elevation_stochastic(
normalization=normalization,
)

self.meta_data = self.meta_data.iloc[gids]
self.meta_data = self.meta_data.loc[gids]
return

def gid_downsample(self, downsample_factor: int) -> None:
Expand Down Expand Up @@ -1895,7 +1895,6 @@ def plot(self):
Not Usable in GeospatialScenario class instance, only in Scenario instance.
"""
# python has no way to hide a parent class method in the child, so this only exists to prevent access
#
raise AttributeError(
"The 'plot' method is not accessible in GeospatialScenario, only in Scenario"
)
Expand Down Expand Up @@ -1928,7 +1927,7 @@ def plot_coords(
the most extreme coordinates for the United States coastline information.
size : float
matplotlib scatter point size. Without any downsampling NSRDB
points will siginficantly overlap.
points will siginficantly overlap and plot may appear as a solid color.
Returns:
--------
Expand All @@ -1938,7 +1937,7 @@ def plot_coords(
fig = plt.figure(figsize=(15, 10))
ax = plt.axes(projection=ccrs.PlateCarree())

if (coord_1 and coord_2) or (coords != None):
if (coord_1 and coord_2) or (coords is not None):
utilities._plot_bbox_corners(
ax=ax, coord_1=coord_1, coord_2=coord_2, coords=coords
)
Expand Down Expand Up @@ -2151,7 +2150,7 @@ def _ipython_display_(self):
<p><strong>self.gids:</strong> {self.gids}</p>
<div>
<h3>self.results</h3>
{self.format_results() if self.results else None}
{self.format_results() if self.results else ''}
</div>
<div>
<h3>Geospatial Work</h3>
Expand All @@ -2169,6 +2168,10 @@ def _ipython_display_(self):
<h3>self.meta_data</h3>
{self.format_geo_meta()}
</div>
<div>
<h3>self.kdtree</h3>
{self.kdtree or ''}
</div>
<div>
<h3>self.dask_client</h3>
{self.format_dask_link()}
Expand Down
4 changes: 2 additions & 2 deletions pvdeg/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pandas as pd
import numpy as np
import dask.array as da
import zarr
#import zarr
import os

from pvdeg import METOROLOGICAL_DOWNLOAD_PATH
Expand Down Expand Up @@ -285,4 +285,4 @@ def _create_sample_sheet(fill_value, latitude: float=999, longitude: float=999,
dim = sheet_ds[var].dims
sheet_ds[var] = (dim, dummy_da)

return sheet_ds, meta_df
return sheet_ds, meta_df

0 comments on commit 73b884c

Please sign in to comment.