Skip to content

Commit

Permalink
Merge pull request #93 from FlorianDeconinck/feature/minor/add_all_co…
Browse files Browse the repository at this point in the history
…s_sing_sg_to_griddata

Expose all SG metric terms in `GridData`
  • Loading branch information
FlorianDeconinck authored Dec 20, 2024
2 parents 38ee6a6 + ad19be3 commit 76f53c8
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 0 deletions.
60 changes: 60 additions & 0 deletions ndsl/grid/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,20 @@ class AngleGridData:
sin_sg2: Quantity
sin_sg3: Quantity
sin_sg4: Quantity
sin_sg5: Quantity
sin_sg6: Quantity
sin_sg7: Quantity
sin_sg8: Quantity
sin_sg9: Quantity
cos_sg1: Quantity
cos_sg2: Quantity
cos_sg3: Quantity
cos_sg4: Quantity
cos_sg5: Quantity
cos_sg6: Quantity
cos_sg7: Quantity
cos_sg8: Quantity
cos_sg9: Quantity

@classmethod
def new_from_metric_terms(cls, metric_terms: MetricTerms) -> "AngleGridData":
Expand All @@ -296,10 +306,20 @@ def new_from_metric_terms(cls, metric_terms: MetricTerms) -> "AngleGridData":
sin_sg2=metric_terms.sin_sg2,
sin_sg3=metric_terms.sin_sg3,
sin_sg4=metric_terms.sin_sg4,
sin_sg5=metric_terms.sin_sg5,
sin_sg6=metric_terms.sin_sg6,
sin_sg7=metric_terms.sin_sg7,
sin_sg8=metric_terms.sin_sg8,
sin_sg9=metric_terms.sin_sg9,
cos_sg1=metric_terms.cos_sg1,
cos_sg2=metric_terms.cos_sg2,
cos_sg3=metric_terms.cos_sg3,
cos_sg4=metric_terms.cos_sg4,
cos_sg5=metric_terms.cos_sg5,
cos_sg6=metric_terms.cos_sg6,
cos_sg7=metric_terms.cos_sg7,
cos_sg8=metric_terms.cos_sg8,
cos_sg9=metric_terms.cos_sg9,
)


Expand Down Expand Up @@ -618,6 +638,26 @@ def sin_sg3(self):
def sin_sg4(self):
return self._angle_data.sin_sg4

@property
def sin_sg5(self):
return self._angle_data.sin_sg5

@property
def sin_sg6(self):
return self._angle_data.sin_sg6

@property
def sin_sg7(self):
return self._angle_data.sin_sg7

@property
def sin_sg8(self):
return self._angle_data.sin_sg8

@property
def sin_sg9(self):
return self._angle_data.sin_sg9

@property
def cos_sg1(self):
return self._angle_data.cos_sg1
Expand All @@ -634,6 +674,26 @@ def cos_sg3(self):
def cos_sg4(self):
return self._angle_data.cos_sg4

@property
def cos_sg5(self):
return self._angle_data.cos_sg5

@property
def cos_sg6(self):
return self._angle_data.cos_sg6

@property
def cos_sg7(self):
return self._angle_data.cos_sg7

@property
def cos_sg8(self):
return self._angle_data.cos_sg8

@property
def cos_sg9(self):
return self._angle_data.cos_sg9


@dataclasses.dataclass(frozen=True)
class DriverGridData:
Expand Down
50 changes: 50 additions & 0 deletions ndsl/stencils/testing/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,31 @@ def grid_data(self) -> "GridData":
dims=GridDefinitions.sin_sg4.dims,
units=GridDefinitions.sin_sg4.units,
),
sin_sg5=self.quantity_factory.from_array(
data=self.sin_sg5,
dims=GridDefinitions.sin_sg5.dims,
units=GridDefinitions.sin_sg5.units,
),
sin_sg6=self.quantity_factory.from_array(
data=self.sin_sg6,
dims=GridDefinitions.sin_sg6.dims,
units=GridDefinitions.sin_sg6.units,
),
sin_sg7=self.quantity_factory.from_array(
data=self.sin_sg7,
dims=GridDefinitions.sin_sg7.dims,
units=GridDefinitions.sin_sg7.units,
),
sin_sg8=self.quantity_factory.from_array(
data=self.sin_sg8,
dims=GridDefinitions.sin_sg8.dims,
units=GridDefinitions.sin_sg8.units,
),
sin_sg9=self.quantity_factory.from_array(
data=self.sin_sg9,
dims=GridDefinitions.sin_sg9.dims,
units=GridDefinitions.sin_sg9.units,
),
cos_sg1=self.quantity_factory.from_array(
data=self.cos_sg1,
dims=GridDefinitions.cos_sg1.dims,
Expand All @@ -754,6 +779,31 @@ def grid_data(self) -> "GridData":
dims=GridDefinitions.cos_sg4.dims,
units=GridDefinitions.cos_sg4.units,
),
cos_sg5=self.quantity_factory.from_array(
data=self.cos_sg5,
dims=GridDefinitions.cos_sg5.dims,
units=GridDefinitions.cos_sg5.units,
),
cos_sg6=self.quantity_factory.from_array(
data=self.cos_sg6,
dims=GridDefinitions.cos_sg6.dims,
units=GridDefinitions.cos_sg6.units,
),
cos_sg7=self.quantity_factory.from_array(
data=self.cos_sg7,
dims=GridDefinitions.cos_sg7.dims,
units=GridDefinitions.cos_sg7.units,
),
cos_sg8=self.quantity_factory.from_array(
data=self.cos_sg8,
dims=GridDefinitions.cos_sg8.dims,
units=GridDefinitions.cos_sg8.units,
),
cos_sg9=self.quantity_factory.from_array(
data=self.cos_sg9,
dims=GridDefinitions.cos_sg9.dims,
units=GridDefinitions.cos_sg9.units,
),
)
self._grid_data = GridData(
horizontal_data=horizontal,
Expand Down

0 comments on commit 76f53c8

Please sign in to comment.