Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update config generation for new supported BMI modules #25

Open
hellkite500 opened this issue Oct 13, 2022 · 6 comments
Open

Update config generation for new supported BMI modules #25

hellkite500 opened this issue Oct 13, 2022 · 6 comments
Assignees

Comments

@hellkite500
Copy link
Member

Some new BMI configs needs to be added to the ngen config generator, these are the ones that need to be added:

  1. soil freeze thaw
  2. sloth
  3. pet

CFE needs to be updated/versioned for the latest version as well.

@aaraney
Copy link
Member

aaraney commented Nov 21, 2023

pydantic models for sloth and pet have been added.

@aaraney
Copy link
Member

aaraney commented Nov 21, 2023

@aaraney
Copy link
Member

aaraney commented Dec 20, 2023

Put in a PR to update the soil freeze thaw config readme. My progress on that module is blocked until I hear back from them.

@aaraney
Copy link
Member

aaraney commented Mar 8, 2024

In review #97

@aaraney
Copy link
Member

aaraney commented Mar 8, 2024

In review #96

@aaraney
Copy link
Member

aaraney commented Aug 23, 2024

SoilFreezeThaw work in progress
from __future__ import annotations

from dataclasses import dataclass, field
from typing import TYPE_CHECKING

from ngen.config.init_config.soil_freeze_thaw import SoilFreezeThaw

if TYPE_CHECKING:
    from typing import Any

    from pydantic import BaseModel

    from ngen.config_gen.hook_providers import HookProvider


@dataclass
class SoilFreezeThawHooks:
    data: dict[str, Any] = field(default_factory=dict)

    def _default(self) -> None:
        self.data["verbosity"] = "none"
        # NOTE: it is okay to have either Schaake[] or _just_ Schaake
        # NOTE: as of NOAA-OWP/SoilFreezeThaw@84b7d12621aa53619d2843c8fcdbbe01ae4925aa Schaake[] or Schaake work
        self.data["ice_fraction_scheme"] = "Schaake[]"

        self.data["quartz"] = "0.4[]"

        self.data["soil_z"] = (
            "0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0[m]"
        )
        self.data["soil_temperature"] = (
            "280.15,280.15,280.15,280.15,280.15,280.15,280.15,280.15,280.15,280.15,280.15,280.15,280.15,280.15,280.15,280.15,280.15,280.15,280.15,280.15[K]"
        )
        self.data["dt"] = (
            "1.0[h]"  # Union[ValueUnitPair[int, time_unit], ValueUnitPair[float, time_unit]]
        )

        self.data["soil_moisture_bmi"] = True
        # required if `soil_moisture_bmi=False` 
        # self.data["soil_moisture_content"] # Optional[ListUnitPair[float, empty]] = None
        # self.data["soil_liquid_content"]   # Optional[ListUnitPair[float, empty]] = None
        # self.data["bottom_boundary_temp"]  # Optional[ListUnitPair[float, k]] = None
        # self.data["top_boundary_temp"]     # Optional[ListUnitPair[float, k]] = None

    def hydrofabric_linked_data_hook(
        self, version: str, divide_id: str, data: dict[str, Any]
    ) -> None:
        self.data["smcmax"] = data[
            "smcmax_soil_layers_stag=1"
        ]  #  FloatUnitPair[m_per_m]
        self.data["b"] = data["bexp_soil_layers_stag=1"]  #  FloatUnitPair[empty]
        self.data["satpsi"] = data["psisat_soil_layers_stag=1"]  #  FloatUnitPair[m]


        # TODO: can we ignore this
        self.data[
            "end_time"
        ]  # Union[ValueUnitPair[int, time_unit], ValueUnitPair[float, time_unit]]

    def visit(self, hook_provider: HookProvider) -> None:
        hook_provider.provide_hydrofabric_linked_data(self)

    def build(self) -> BaseModel:
        return SoilFreezeThaw(**self.data)

@aaraney aaraney pinned this issue Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants