NEDAS.core.model module
- class NEDAS.core.model.Model(context: Context | None = None, io_mode: Literal['online', 'offline'] | None = None, config_file: str | None = None, parse_args: bool = False, **kwargs)[source]
Bases:
Generic[GridT],ABCClass for configuring and running a model
- grid: GridT
- z: dict[Annotated[int, 'z level index'], ndarray]
- mask: ndarray
- ens_init_dir: str | None
- truth_dir: str | None
- ens_run_strategy: Literal['scheduler', 'batch']
- nproc_per_run: int = 1
- nproc_per_util: int = 1
- walltime: int | None = None
- run_process = None
- run_status: str = 'pending'
- restart_dir: str
- forecast_period: int
- memory: dict
- io_mode: Literal['online', 'offline']
- model_name: str
- abstractmethod read_grid(**kwargs) None[source]
Read the grid information from the model output.
- Parameters:
**kwargs – Keyword arguments for reading the grid.
- read_var(**kwargs) ndarray[source]
Read a variable from the model output.
- Parameters:
**kwargs – Keyword arguments for reading the variable.
- Returns:
The read variable.
- Return type:
np.ndarray
- write_var(var, **kwargs) None[source]
Write a variable to the model output.
- Parameters:
var (np.ndarray) – The variable to write.
**kwargs – Keyword arguments for writing the variable.
- abstractmethod z_coords(**kwargs) ndarray[source]
Get the vertical coordinates of the model.
- Parameters:
**kwargs – Keyword arguments for getting the vertical coordinates.
- Returns:
The vertical coordinates.
- Return type:
np.ndarray
- abstractmethod preprocess(*args, **kwargs) None[source]
Preprocess the model data.
- Parameters:
**kwargs – Keyword arguments for preprocessing.
- abstractmethod postprocess(*args, **kwargs) None[source]
Postprocess the model data.
- Parameters:
**kwargs – Keyword arguments for postprocessing.
- abstractmethod run(*args, **kwargs) None[source]
Run the model forward in time.
- Parameters:
*args – Arguments
**kwargs – Keyword arguments
- Keyword Arguments:
time (datetime) – current time when forecast starts
restart_dir (str) – directory where restart files are located
forecast_period (int) – forecast period in hours
If self.ens_run_strategy == ‘batch’, the method will run all ensemble members in one go, expect additional kwargs[‘nens’] to be the ensemble size. If self.ens_run_strategy == ‘scheduler’, the method runs a single member indexed by kwargs[‘member’], and kwargs[‘worker_id’] is the pid assigned by the scheduler to run this method.