-
Notifications
You must be signed in to change notification settings - Fork 21
Feature: Split the array design save_layout into separate creation and save methods
#203
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -361,36 +361,15 @@ def run(self): | |
| self._create_wind_farm_layout() | ||
| self._create_cable_section_lengths() | ||
|
|
||
| def save_layout(self, save_name, return_df=False, folder="cables"): | ||
| """Outputs a csv of the substation and turbine positional and cable | ||
| related components. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| save_name : str | ||
| The name of the file without an extension to be saved to | ||
| <library_path>/cables/<save_name>.csv. | ||
| return_df : bool, optional | ||
| If true, returns layout_df, a pandas.DataFrame of the cabling | ||
| layout, by default False. | ||
| folder : str, optional | ||
| If "cables", then the layout will saved to the "cables" folder, and | ||
| if "plant", then the layout will be saved to the "project/plant" | ||
| folder. | ||
| def create_layout_df(self) -> pd.DataFrame: | ||
| """Creates a Pandas DataFrame layout. | ||
|
|
||
| Returns | ||
| ------- | ||
| pd.DataFrame | ||
| The DataFrame with the layout data. | ||
|
|
||
| Raises | ||
| ------ | ||
| ValueError | ||
| Raised if ``folder`` is not one of "cables" or "plant". | ||
| Wind farm layout compatible with the ``CustomArrayDesignLayout`` or | ||
| for use with external models. | ||
| """ | ||
| if folder not in ("cables", "plant"): | ||
| raise ValueError("`folder` must be one of: 'cables' or plant'.") | ||
|
|
||
| num_turbines = self.system.num_turbines | ||
| columns = [ | ||
| "id", | ||
|
|
@@ -460,7 +439,40 @@ def save_layout(self, save_name, return_df=False, folder="cables"): | |
| layout_df.cable_length = [""] + self.sections_cable_lengths.flatten()[ | ||
| :num_turbines | ||
| ].tolist() | ||
| data = [columns] + layout_df.to_numpy().tolist() | ||
| return layout_df | ||
|
|
||
| def save_layout(self, save_name, return_df=False, folder="cables"): | ||
| """Outputs a csv of the substation and turbine positional and cable | ||
| related components. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| save_name : str | ||
| The name of the file without an extension to be saved to | ||
| <library_path>/cables/<save_name>.csv. | ||
| return_df : bool, optional | ||
| If true, returns layout_df, a pandas.DataFrame of the cabling | ||
| layout, by default False. | ||
| folder : str, optional | ||
| If "cables", then the layout will saved to the "cables" folder, and | ||
| if "plant", then the layout will be saved to the "project/plant" | ||
| folder. | ||
|
|
||
| Returns | ||
| ------- | ||
| pd.DataFrame | ||
| The DataFrame with the layout data. | ||
|
|
||
| Raises | ||
| ------ | ||
| ValueError | ||
| Raised if ``folder`` is not one of "cables" or "plant". | ||
| """ | ||
| if folder not in ("cables", "plant"): | ||
| raise ValueError("`folder` must be one of: 'cables' or plant'.") | ||
|
|
||
| layout_df = self.create_layout_df() | ||
| data = [layout_df.columns] + layout_df.to_numpy().tolist() | ||
| print( | ||
| f"Saving custom array CSV to: <library_path>/cables/{save_name}.csv" # noqa: E501 | ||
|
||
| ) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be folder.lower()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only if
folderwill be converted to lower case first, otherwise it would break later usage with ORBIT. If that's desired, then I can update it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not the most pressing. It seems like the user would be familiar with the folder names prior to saving anyways...