Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Bug Fix: Asset table operations #282

Merged
merged 1 commit into from
Mar 7, 2024
Merged
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 openoa/plant.py
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,9 @@ def calculate_asset_distance_matrix(self) -> pd.DataFrame:

# Maintain v2 compatibility of np.inf for the diagonal
distance = distance + distance.values.T - np.diag(np.diag(distance.values))
np.fill_diagonal(distance.values, np.inf)
distance_array = distance.values
np.fill_diagonal(distance_array, np.inf)
distance.loc[:, :] = distance_array
self.asset_distance_matrix = distance

def turbine_distance_matrix(self, turbine_id: str = None) -> pd.DataFrame:
Expand Down Expand Up @@ -1330,7 +1332,9 @@ def calculate_asset_direction_matrix(self) -> pd.DataFrame:
+ np.triu((direction.values - 180.0) % 360.0, 1).T
- np.diag(np.diag(direction.values))
)
np.fill_diagonal(direction.values, np.inf)
direction_array = direction.values
np.fill_diagonal(direction_array, np.inf)
direction.loc[:, :] = direction_array
self.asset_direction_matrix = direction

def turbine_direction_matrix(self, turbine_id: str = None) -> pd.DataFrame:
Expand Down Expand Up @@ -1443,7 +1447,7 @@ def get_freestream_turbines(
'Invalid freestream method. Currently, "sector" and "IEC" are supported.'
)

return list(self.asset.index[freestream_indices])
return list(self.asset.loc[self.asset["type"] == "turbine"].index[freestream_indices])

@logged_method_call
def calculate_nearest_neighbor(
Expand Down
Loading