|
15 | 15 | from gempy_engine.core.data.interpolation_input import InterpolationInput
|
16 | 16 | from gempy_engine.core.data.raw_arrays_solution import RawArraysSolution
|
17 | 17 | from gempy_engine.core.data.transforms import Transform, GlobalAnisotropy
|
| 18 | +from gempy_engine.modules.geophysics.gravity_gradient import calculate_gravity_gradient |
18 | 19 | from .encoders.converters import instantiate_if_necessary
|
19 | 20 | from .encoders.json_geomodel_encoder import encode_numpy_array
|
20 | 21 | from .grid import Grid
|
@@ -62,7 +63,7 @@ class GeoModel(BaseModel):
|
62 | 63 | # region GemPy engine data types
|
63 | 64 | _interpolation_options: InterpolationOptions #: The interpolation options provided by the user.
|
64 | 65 |
|
65 |
| - geophysics_input: GeophysicsInput = Field(default=None, exclude=True) #: The geophysics input of the geological model. |
| 66 | + geophysics_input: GeophysicsInput = Field(default=None, exclude=False) #: The geophysics input of the geological model. |
66 | 67 | input_transform: Transform = Field(default=None, exclude=False) #: The transformation used in the geological model for input points.
|
67 | 68 |
|
68 | 69 | interpolation_grid: EngineGrid = Field(default=None, exclude=True) #: ptional grid used for interpolation. Can be seen as a cache field.
|
@@ -303,16 +304,22 @@ def add_surface_points(self, X: Sequence[float], Y: Sequence[float], Z: Sequence
|
303 | 304 | @classmethod
|
304 | 305 | def deserialize_properties(cls, data: Union["GeoModel", dict], constructor: ModelWrapValidatorHandler["GeoModel"]) -> "GeoModel":
|
305 | 306 | match data:
|
306 |
| - case GeoModel(): |
| 307 | + case GeoModel(): |
307 | 308 | return data
|
308 |
| - case dict(): |
| 309 | + case dict(): # |
309 | 310 | instance: GeoModel = constructor(data)
|
310 | 311 | instantiate_if_necessary(
|
311 | 312 | data=data,
|
312 | 313 | key="_interpolation_options",
|
313 | 314 | type=InterpolationOptions
|
314 | 315 | )
|
315 | 316 | instance._interpolation_options = data.get("_interpolation_options")
|
| 317 | + |
| 318 | + # * Reset geophysics if necessary |
| 319 | + centered_grid = instance.grid.centered_grid |
| 320 | + if centered_grid is not None and instance.geophysics_input is not None: |
| 321 | + instance.geophysics_input.tz = calculate_gravity_gradient(centered_grid) |
| 322 | + |
316 | 323 | return instance
|
317 | 324 | case _:
|
318 | 325 | raise ValidationError
|
|
0 commit comments