Clock#

class fridom.framework.clock.Clock(start_date: datetime64 | None = None, start_time: float | None = None)[source]#

Bases: object

A clock to keep track of the model time.

Parameters#

start_datenp.datetime64, optional

The start date of the model run.

start_timefloat, optional

The start time of the model run in seconds.

Raises#

ValueError

If both start_date and start_time are provided.

__init__(start_date: datetime64 | None = None, start_time: float | None = None) None[source]#

Methods

__init__([start_date, start_time])

get_total_time([passed_time])

Get the total time of the model run.

reset()

Reset the passed time to zero.

set_start(time)

Set the start time of the model run.

tick(time_step)

Increase the passed time by the time step + increase the iteration step.

Attributes

it

The current iteration step of the model.

passed_time

Get the passed time in seconds.

start_date

Get the start date.

start_time

Get the start time in seconds.

time

Get the model time in seconds.

reset() None[source]#

Reset the passed time to zero.

tick(time_step: float | timedelta64) None[source]#

Increase the passed time by the time step + increase the iteration step.

Parameters#

time_stepfloat

The time step in seconds.

get_total_time(passed_time: float | None = None) datetime64 | float[source]#

Get the total time of the model run.

Parameters#

passed_timefloat | None (optional)

The passed time in seconds. If not provided, the current passed time of the model will be used

Returns#

np.datetime64 or float

The total time of the model run. Either a datetime object corresponding to the date or a float corresponding to the time in seconds.

set_start(time: datetime64 | float) None[source]#

Set the start time of the model run.

Parameters#

timenp.datetime64 or float

The start time of the model run.

property start_time: float#

Get the start time in seconds.

property start_date: datetime64 | None#

Get the start date.

property passed_time: float#

Get the passed time in seconds.

property time: float#

Get the model time in seconds.

property it: int#

The current iteration step of the model.