From f999eac5132aff172a558cbbe0acb9db02084267 Mon Sep 17 00:00:00 2001 From: MassimoCimmino Date: Thu, 28 Nov 2024 11:12:16 -0500 Subject: [PATCH] Save field to file --- pygfunction/borefield.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/pygfunction/borefield.py b/pygfunction/borefield.py index bcc69d1..79e2260 100644 --- a/pygfunction/borefield.py +++ b/pygfunction/borefield.py @@ -391,6 +391,31 @@ def to_boreholes(self) -> List[Borehole]: """ return [borehole for borehole in self] + def to_file(self, filename: str) -> List[Borehole]: + """ + Save the bore field into a text file. + + Parameters + ---------- + filename : str + The filename in which to save the bore field. + + """ + data = np.stack( + (self.x, + self.y, + self.H, + self.D, + self.r_b, + self.tilt, + self.orientation), + axis=-1) + np.savetxt( + filename, + data, + delimiter='\t', + header='x\ty\tH\tD\tr_b\ttilt\torientation') + @classmethod def rectangle_field( cls, N_1: int, N_2:int, B_1: float, B_2: float, H: float, D: float,