Skip to content

Commit

Permalink
fixing asset table operations in plant module (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
ejsimley authored Mar 7, 2024
1 parent 94fd51f commit aa11436
Showing 1 changed file with 7 additions and 3 deletions.
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

0 comments on commit aa11436

Please sign in to comment.