@@ -79,6 +79,7 @@ class Grid(ABC, BaseClass):
79
79
n_wind_directions : int = field (init = False )
80
80
n_wind_speeds : int = field (init = False )
81
81
n_turbines : int = field (init = False )
82
+ grid_shape : tuple [int , int , int , int , int ] = field (init = False )
82
83
x_sorted : NDArrayFloat = field (init = False , validator = validate_5DArray_shape )
83
84
y_sorted : NDArrayFloat = field (init = False , validator = validate_5DArray_shape )
84
85
z_sorted : NDArrayFloat = field (init = False , validator = validate_5DArray_shape )
@@ -123,12 +124,16 @@ def grid_resolution_validator(self, instance: attrs.Attribute, value: int | Iter
123
124
isinstance (self , (TurbineGrid , TurbineCubatureGrid , PointsGrid )):
124
125
return
125
126
elif isinstance (value , Iterable ) and isinstance (self , FlowFieldPlanarGrid ):
126
- assert type (value [0 ]) is int
127
- assert type (value [1 ]) is int
127
+ if not (len (value ) == 2 and all (isinstance (v , int ) for v in value )):
128
+ raise TypeError (
129
+ "`FlowFieldPlanarGrid` must have `grid_resolution` as an iterable of 2 `int`s." ,
130
+ value
131
+ )
128
132
elif isinstance (value , Iterable ) and isinstance (self , FlowFieldGrid ):
129
- assert type (value [0 ]) is int
130
- assert type (value [1 ]) is int
131
- assert type (value [2 ]) is int
133
+ if len (value ) != 3 or all (isinstance (v , int ) for v in value ):
134
+ raise TypeError (
135
+ "'FlowFieldGrid` must have `grid_resolution` as an iterable of 3 `int`s." , value
136
+ )
132
137
else :
133
138
raise TypeError ("`grid_resolution` must be of type int or Iterable(int,)" )
134
139
@@ -244,6 +249,7 @@ def set_grid(self) -> None:
244
249
),
245
250
dtype = floris_float_type
246
251
)
252
+ self .grid_shape = template_grid .shape
247
253
# Calculate the radial distance from the center of the turbine rotor.
248
254
# If a grid resolution of 1 is selected, create a disc_grid of zeros, as
249
255
# np.linspace would just return the starting value of -1 * disc_area_radius
@@ -365,6 +371,7 @@ def set_grid(self) -> None:
365
371
),
366
372
dtype = floris_float_type
367
373
)
374
+ self .grid_shape = template_grid .shape
368
375
_x = x [:, :, :, None , None ] * template_grid
369
376
_y = y [:, :, :, None , None ] * template_grid
370
377
_z = z [:, :, :, None , None ] * template_grid
@@ -509,6 +516,7 @@ def set_grid(self) -> None:
509
516
First, sort the turbines so that we know the bounds in the correct orientation.
510
517
Then, create the grid based on this wind-from-left orientation
511
518
"""
519
+ self .grid_shape = (self .n_wind_directions , self .n_wind_speeds , * self .grid_resolution )
512
520
513
521
# These are the rotated coordinates of the wind turbines based on the wind direction
514
522
x , y , z , self .x_center_of_rotation , self .y_center_of_rotation = rotate_coordinates_rel_west (
@@ -605,6 +613,9 @@ def set_grid(self) -> None:
605
613
if self .x2_bounds is None :
606
614
self .x2_bounds = (np .min (y ) - 2 * max_diameter , np .max (y ) + 2 * max_diameter )
607
615
616
+ grid_resolution = (self .grid_resolution [0 ], self .grid_resolution [1 ], 3 )
617
+ self .grid_shape = (self .n_wind_directions , self .n_wind_speeds , * grid_resolution )
618
+
608
619
# TODO figure out proper z spacing for GCH, currently set to +/- 10.0
609
620
x_points , y_points , z_points = np .meshgrid (
610
621
np .linspace (self .x1_bounds [0 ], self .x1_bounds [1 ], int (self .grid_resolution [0 ])),
@@ -628,6 +639,9 @@ def set_grid(self) -> None:
628
639
if self .x2_bounds is None :
629
640
self .x2_bounds = (0.001 , 6 * np .max (z ))
630
641
642
+ grid_resolution = (1 , self .grid_resolution [0 ], self .grid_resolution [1 ])
643
+ self .grid_shape = (self .n_wind_directions , self .n_wind_speeds , * grid_resolution )
644
+
631
645
x_points , y_points , z_points = np .meshgrid (
632
646
np .array ([float (self .planar_coordinate )]),
633
647
np .linspace (self .x1_bounds [0 ], self .x1_bounds [1 ], int (self .grid_resolution [0 ])),
@@ -646,6 +660,9 @@ def set_grid(self) -> None:
646
660
if self .x2_bounds is None :
647
661
self .x2_bounds = (0.001 , 6 * np .max (z ))
648
662
663
+ grid_resolution = (self .grid_resolution [0 ], 1 , self .grid_resolution [1 ])
664
+ self .grid_shape = (self .n_wind_directions , self .n_wind_speeds , * grid_resolution )
665
+
649
666
x_points , y_points , z_points = np .meshgrid (
650
667
np .linspace (self .x1_bounds [0 ], self .x1_bounds [1 ], int (self .grid_resolution [0 ])),
651
668
np .array ([float (self .planar_coordinate )]),
@@ -714,6 +731,7 @@ def set_grid(self) -> None:
714
731
Set points for calculation based on a series of user-supplied coordinates.
715
732
"""
716
733
point_coordinates = np .array (list (zip (self .points_x , self .points_y , self .points_z )))
734
+ self .grid_shape = (self .n_wind_directions , self .n_wind_speeds , self .points_x .shape [0 ], 1 , 1 )
717
735
718
736
# These are the rotated coordinates of the wind turbines based on the wind direction
719
737
x , y , z , _ , _ = rotate_coordinates_rel_west (
0 commit comments