Skip to content

Commit

Permalink
remove duplicated initial condition fields classes
Browse files Browse the repository at this point in the history
  • Loading branch information
MAfarrag committed Nov 20, 2024
1 parent 5fb2ce0 commit a41f591
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 68 deletions.
74 changes: 6 additions & 68 deletions hydrolib/core/dflowfm/ext/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
make_list_validator,
validate_location_specification,
)
from hydrolib.core.dflowfm.inifield.models import InterpolationMethod, AveragingType, DataFileType
from hydrolib.core.dflowfm.polyfile.models import PolyFile
from hydrolib.core.dflowfm.tim.models import TimModel
from hydrolib.core.utils import str_is_empty_or_none
Expand Down Expand Up @@ -361,68 +362,6 @@ def _filename(cls) -> str:
return "bnd"


class InitialCondInterpolationMethod(StrEnum):
"""
Enum class containing the valid values for the interpolationMethod
attribute in InitialCondition class.
args:
constant: only if the dataFileType is "polygon"
triangulation:
average: grid cell averaging
"""
constant = "constant"
triangulation = "triangulation"
averaging = "averaging"
allowedvaluestext = "Possible values: const (only with dataFileType = polygon)."


class InitialCondFileType(StrEnum):
"""
Enum class containing the valid values for the forcingFileType
attribute in Meteo class.
args:
arcinfo: ESRI ArcInfo interchange file (E00) format (uses basic ascii representation)
geotiff: GeoTIFF format (.tif)
sample: Sample format
1dField: 1D field format (INI file)
polygon: Polygon format (.poli)
"""
arcinfo = "arcinfo"
geotiff = "GeoTIFF"
sample = "sample"
d1fiels = "1dField"
polygon = "polygon"
allowedvaluestext = "Possible values: arcinfo, GeoTIFF, sample, 1dField, polygon."


class AveragingTypeMethod(StrEnum):
"""
Enum class containing the valid values for the averaging type
attribute in InitialCondition class.
args:
mean: mean value
nearestNb: nearest neighbour
max: maximum value
min: minimum value
invDist: inverse distance weighting (1/distance)
minAbs: minimum absolute value
median: median value
"""
mean = "mean"
nearestNB = "nearestNb"
max = "max"
min = "min"
invDist = "invDist"
minAbs = "minAbs"
median = "median"
allowedvaluestext = "Possible values: mean, nearestNb, max, min, invDist, minAbs, median."


class InitialConditions(INIBasedModel):
"""
A `[Initial Condition]` block for use inside an external forcings file,
Expand All @@ -434,21 +373,20 @@ class InitialConditions(INIBasedModel):
_header: Literal["Initial"] = "Initial"
quantity: str = Field(alias="QUANTITY")
datafile: Union[TimModel, ForcingModel, DiskOnlyFileModel] = Field(alias="dataFile")
datafiletype: InitialCondFileType = Field(alias="dataFileType")
interpolationmethod: Optional[InitialCondInterpolationMethod] = Field(alias="interpolationMethod")
datafiletype: DataFileType = Field(alias="dataFileType")
interpolationmethod: Optional[InterpolationMethod] = Field(alias="interpolationMethod")
operand: Optional[Operand] = Field(Operand.override.value, alias="operand")
extrapolationAllowed: Optional[bool] = Field(alias="extrapolationAllowed")
extrapolationSearchRadius: Optional[float] = Field(
alias="extrapolationSearchRadius"
)
averagingtype: Optional[AveragingTypeMethod] = Field(alias="averagingType")
averagingtype: Optional[AveragingType] = Field(alias="averagingType")
averagingnummin: Optional[int] = Field(default=1, alias="averagingNumMin")
averagingpercentile: Optional[float] = Field(default=0, alias="averagingPercentile")


datafiletype_validator = get_enum_validator(
"datafiletype", enum=InitialCondFileType
"datafiletype", enum=DataFileType
)
interpolationmethod_validator = get_enum_validator(
"interpolationmethod", enum=InitialCondInterpolationMethod
"interpolationmethod", enum=InterpolationMethod
)
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ addopts = """
--deselect=tests/test_model.py::test_dimr_model
--deselect=tests/test_model.py::test_dimr_mode_save
--deselect=tests/test_model.py::test_read_ext_missing_boundary_field_raises_correct_error
--deselect=tests/tools/test_main_converter.py::TestExtOldToNew::test_wind_combi_uniform_curvi
"""

[build-system]
Expand Down

0 comments on commit a41f591

Please sign in to comment.