Input

Input-data readers: NetCDF time-series forcing files and interpolation utilities used to drive the model from observed or reanalysis data.

Input handling modules.

Observation input — translation of input.F90.

Reads time-series and profile observations from text files and interpolates them linearly to the current simulation time. Two input modes are supported:

  • method_constant (0) — constant value supplied at configuration time.

  • method_file (2) — ASCII text file with one or more time-stamped records; values are linearly interpolated between bracketing records.

The Fortran constant method_unsupported = huge(1) is mapped to method_unsupported = math.inf.

Fortran types are mapped to Python classes:

Public interface: init_input(), do_input(), close_input(), register_input(), register_scalar_input(), register_profile_input(), read_obs(), read_profiles(), InputManager, ScalarInput, ProfileInput.

Original FORTRAN authors: Jorn Bruggeman.

class pygotm.input.input.InputManager(nlev=None, scalar_inputs=<factory>, profile_inputs=<factory>, _profile_files=<factory>, _timeseries_files=<factory>)[source]

Bases: object

Stateful translation of the GOTM input module.

Parameters:
nlev: int | None = None
scalar_inputs: list[ScalarInput]
profile_inputs: list[ProfileInput]
register_profile_input(input_)[source]
Return type:

None

Parameters:

input_ (ProfileInput)

register_scalar_input(input_)[source]
Return type:

None

Parameters:

input_ (ScalarInput)

do_input(jul, secs, nlev=None, z=None)[source]
Return type:

None

Parameters:
close()[source]
Return type:

None

class pygotm.input.input.ProfileInput(name='', method=0, scale_factor=1.0, path='', index=1, add_offset=0.0, constant_value=0.0, minimum=-inf, maximum=inf, method_off=inf, method_constant=0, method_file=2, data=None)[source]

Bases: InputBase

Parameters:
data: ndarray | None = None
class pygotm.input.input.ScalarInput(name='', method=0, scale_factor=1.0, path='', index=1, add_offset=0.0, constant_value=0.0, minimum=-inf, maximum=inf, method_off=inf, method_constant=0, method_file=2, value=0.0)[source]

Bases: InputBase

Parameters:
value: float = 0.0
pygotm.input.input.close_input()[source]
Return type:

None

pygotm.input.input.do_input(jul, secs, nlev=None, z=None)[source]
Return type:

None

Parameters:
pygotm.input.input.init_input(n=None)[source]

Initialise the module-level input manager.

Return type:

None

Parameters:

n (int | None)

pygotm.input.input.read_obs(stream, n, *, line_number=0)[source]

Read a non-profile observation row from stream.

Return type:

tuple[tuple[int, int, int, int, int, int], ndarray, int]

Parameters:
pygotm.input.input.read_profiles(stream, nlev, cols, z, *, line_number=0)[source]

Read and vertically interpolate a profile block from stream.

Return type:

tuple[tuple[int, int, int, int, int, int], ndarray, int]

Parameters:
pygotm.input.input.register_input(input_)[source]
Return type:

None

Parameters:

input_ (ScalarInput | ProfileInput)

pygotm.input.input.register_profile_input(input_)[source]
Return type:

None

Parameters:

input_ (ProfileInput)

pygotm.input.input.register_scalar_input(input_)[source]
Return type:

None

Parameters:

input_ (ScalarInput)

NetCDF restart input — translation of input_netcdf.F90.

Opens, validates, and reads GOTM restart (NetCDF) files. Verifies that the restart file’s time metadata matches the requested simulation start time, then reads scalar or 1-D profile variables into NumPy arrays.

Depends on pygotm.util.time for read_time_string() and write_time_string() (Fortran: use time, only: read_time_string, write_time_string).

Public interface: open_restart(), close_restart(), check_restart_time(), read_restart_data().

Original FORTRAN authors: Karsten Bolding, Jorn Bruggeman.

pygotm.input.input_netcdf.check_restart_time(var_name, *, expected_julian, expected_seconds)[source]

Verify that the restart file time metadata matches the requested start.

Return type:

None

Parameters:
  • var_name (str)

  • expected_julian (int)

  • expected_seconds (int)

pygotm.input.input_netcdf.close_restart()[source]

Close the active restart NetCDF file.

Return type:

None

pygotm.input.input_netcdf.open_restart(fn)[source]

Open a restart NetCDF file.

Return type:

None

Parameters:

fn (str | Path)

pygotm.input.input_netcdf.read_restart_data(var_name, allow_missing_variable, *, data_0d=None, data_1d=None)[source]

Read restart data into an optional destination or return a copy.

Return type:

float | ndarray | None

Parameters: