Warm States and Cold States

Delft-FEWS stores model states in the native model format.

This page discusses the handling of warmStates.

State saving - <importStateActivity>

The <importStateActivity> is used to save a state. 
This is configured at the end of the General Adapter module, see 05GeneralAdapterModule-importStateActivity.

By convention, only 'UpdateStates' (or Historical) Workflows save states at the end of the run.
Forecasts Workflows do not save their state typically.

<importStateActivity>
	<stateFile>
		<importFile>%WORK_DIR%/ToFews/outstates.nc</importFile>
		<!-- Rename imported state file so that it can be used as input state for a future model run. -->
		<relativeExportFile>../FromFews/instates.nc</relativeExportFile>
	</stateFile>
</importStateActivity>

State branches

Warm states written by the same ModuleInstanceId are part of a branch.
When a warmState on a branch expires, this breaks the branch and warmStates with a T0 before the expired state are no longer accessible as a warmState.

Example of states on a branch

Example based on the SLEIP application in Australia, which has separate workflows for:

The AnnualUpdateState and HourlyUpdateState are identical,
except for their warmStateSearch period and T0.

  • The annual run
    • looks for a warmState 24 years ago, and
    • is run for T0 - 1 year.
  • The hourly run
    • looks for a warmState between 1 and 2 years ago, and
    • is run for T0 = currentSystemTime.
  • The Forecast run
    • looks for a warmState at T0.

Even though both UpdateStates run the same GA, they need to get a different moduleInstanceId. 
Otherwise, the annual warm state becomes invisible as soon as an hourly state expires.
This is because they exist on the same branch.

State selection - <exportStateActivity>

The <exportStateActivity> is used to start the model based on the initial conditions of a previous run (i.e. a warmState).
This is configured in the General Adapter module, see 05GeneralAdapterModule-exportStateActivity

The exportStateActivity can be used for any model Workflow (both UpdateStates and Forecasting) 

<exportStateActivity>
	<moduleInstanceId>$Catchment$WflowHc</moduleInstanceId>
	<stateExportDir>%WORK_DIR%/FromFews</stateExportDir>
	<stateSelection>
		<warmState>
			<stateSearchPeriod unit="hour" start="-240" end="-5"/>
		</warmState>
	</stateSelection>
</exportStateActivity>

stateSearchPeriod

The <stateSelection> defines which state is exported to the model and so determines the start of the simulation, see 05GeneralAdapterModule-stateSelection
Typically, a <warmState> is configured in the search period. If no warmState is found, the default coldStateFile will be used at the beginning of <stateSearchPeriod>.

The stateSelection search period can be set in several places. 
The hierarchy follows the order shown below, i.e. Topology overrules ModuleConfigFile etc. 
In case of nested Workflows, the top-level Workflow overrules the underlying nested Workflows. 

Time for which a warmState is created 

There are two options in <exportStateActivity> to also save warmStates at other times.

Reduce number of warmStates in the database

In some cases, transient States can be usefull, see 02Statehandling-TransientandLongLivingStates (below).

There are two options in <exportStateActivity> to reduce the number of warm states in the database:

Transient and Long Living States

Example based on the the CHPS application in the USA, which has separate workflows for:

The state handling of these is described in more detail in the table below.

State creation within and after stateSearchPeriod

The UpdateStates run produces 10-15 warmStates every time it's run (i.e. daily). 
Typically, only those at the end of a stateSearchPeriod are used:

All warmStates outside its own stateSearchPeriod will be superseded by next day's run.
But all remain in the database until they expire, which is when the workflow expires.

States created after the stateSearchPeriod of the GA that creates them are considered transient states.
States created within the stateSearchPeriod of the GA that creates them are considered long living states.

UpdateStates workflow in CHPS
The run starts at the end of the warm state search period, at the blue solid square.

UpdateState workflows cannot be run from the Topology.
Instead, they are scheduled to run on server once a day (midnight, 12z), with:

  • T0: 12z
  • <stateSearchPeriod> for warmStates: T0 -15 days till T0 -10 days
  • start of run: To - 10 days (typically)
  • end of run: T0
  • <loopTimeStep>: 12z, so generate a state every day 
  • <simulatedHistoricalModuleInstanceId>: to link to the Forecasts

State handling in UpdateStates workflows in CHPS

Forecasts workflow in CHPS

The run starts at the end of the warm state search period, 
or just at T0-10days if this is configured as such in the Topology.xml

Forecast workflows can be run from the Topology, with:

  • T0: a cardinal time step
  • <stateSearchPeriod> for warmStates: T0 -15days till T0-10 days
  • start of run: T0 - 10 days (typically)
  • end of run: forecast length
  • do not generate states

Modifiers for the Forecasts (<T0) are applied to UpdateStates.

State handling in Forecast Workflow in CHPS

Ensembles worflow in CHPS

Similar to Forecasts workflows.

Ensemble workflows can be run from the Topology, with:

  • T0: a cardinal time step
  • <stateSearchPeriod> for warmStates: T0-10 till T0 days
  • start of run: T0 (typically)
  • end of run: forecast length
  • do not generate states

Modifiers for the Forecasts can be excluded from the Ensembles. 

State handling in Ensembles Workflow in CHPS

UpdateStates workflow with Transient states

With <searchForTransientStates> = False, only long living states are used.

Consequently, the UpdateState run will start one day earlier (T0-11days).
After all, the state at T0 is a transient state produced by the UpdateState run of T0-1d. 

State handling when using transient states


<workflowDescriptor id="UpdateStates" forecast="true" visible="true" allowApprove="true"   autoApprove="true"> 
	<description>UpdateStates</description> 
	<cardinalTimeStep id="12Z"/> 
	<stateSelection> 
    	<warmState> 
        	<stateSearchPeriod start="-15" end="-10" unit="day"/> 
            <searchForTransientStates>false</searchForTransientStates> 
            <transientStateExpiryTime multiplier="1" unit="day"/> 
    	</warmState> 
	</stateSelection> 
	<runExpiryTime multiplier="30" unit="day"/> 
</workflowDescriptor>