From cbb3dc57acd3b370f38c996ec7e483d3895ea0f6 Mon Sep 17 00:00:00 2001 From: "Hammond, Rob" <13874373+RHammond2@users.noreply.github.com> Date: Thu, 6 Nov 2025 14:22:22 -0800 Subject: [PATCH 1/3] slit save_layout to individual creation and save methods --- ORBIT/phases/design/array_system_design.py | 64 +++++++++++++--------- 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/ORBIT/phases/design/array_system_design.py b/ORBIT/phases/design/array_system_design.py index f1f65055..009c340f 100644 --- a/ORBIT/phases/design/array_system_design.py +++ b/ORBIT/phases/design/array_system_design.py @@ -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 - /cables/.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 + /cables/.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: /cables/{save_name}.csv" # noqa: E501 ) From 697239a01150a70736e3198d0bdfaf978b0690c3 Mon Sep 17 00:00:00 2001 From: "Hammond, Rob" <13874373+RHammond2@users.noreply.github.com> Date: Thu, 6 Nov 2025 14:22:37 -0800 Subject: [PATCH 2/3] update changelog --- docs/source/changelog.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 5cee1899..d8906742 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -9,6 +9,9 @@ Unreleased configuration input. - Move the matplotlib import from the import section of ``/ORBIT/phases/design/array_system_design.py`` to the ``CustomArraySystemDesign.plot_array_system`` for missing module error handling. +- Adds a general layout ``DataFrame`` creation method as ``ArraySystemDesign.create_layout_df()`` that + is called by the ``save_layout`` method to maintain backwards compatibility, but opens up the ability + gather the layout without saving it to a file. 1.2.4 ----- From 14cfa4b62e107b66e2c6f6310dccd800849a6d51 Mon Sep 17 00:00:00 2001 From: "Hammond, Rob" <13874373+RHammond2@users.noreply.github.com> Date: Fri, 21 Nov 2025 09:31:26 -0800 Subject: [PATCH 3/3] more useful save log --- ORBIT/phases/design/array_system_design.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ORBIT/phases/design/array_system_design.py b/ORBIT/phases/design/array_system_design.py index 009c340f..0e401bab 100644 --- a/ORBIT/phases/design/array_system_design.py +++ b/ORBIT/phases/design/array_system_design.py @@ -474,7 +474,7 @@ def save_layout(self, save_name, return_df=False, folder="cables"): layout_df = self.create_layout_df() data = [layout_df.columns] + layout_df.to_numpy().tolist() print( - f"Saving custom array CSV to: /cables/{save_name}.csv" # noqa: E501 + f"Saving custom array CSV to: /{folder}/{save_name}.csv" # noqa: E501 ) export_library_specs(folder, save_name, data, file_ext="csv") if return_df: