How to import longitudinal time series from SOBEK-CF models

When running a SOBEK model the "SbkBatch.exe" module is used as a model adapter to convert the FEWS-PI XML data to native SOBEK files, start the SOBEK model(s), and convert the SOBEK native output files back to FEWS-PI XML files. the FEWS General Adapter is used to export and import FEWS-PI XML data from and to the FEWS datastore, as well as starting the SbkBatch.exe module.

One type of data that can not be handled by the SbkBatch.exe model adapter is longitudinal time series data. In order to import longitudinal time series from a SOBEK model run we need to use the "PostSobekModelAdapter"; this is a SOBEK model adapter originally made to handle data for SOBEK-RE models. It can however also be used to import longitudinal time series from SOBEK-CF models.

In this document we will discuss the setup of a PostSobekModelAdapter and the configuration of Branches required to store longitudinal time series. As example, the configuration of the Keelung and Hsientien rivers from the "TanshuiRRCFKT" SOBEK-CF model is used.

FEWS Regional Configuration

DELFT-FEWS is a location oriented system. All time series data must be referenced to a (geographic) location. Scalar time series need no additional information. For longitudinal time series data, each point in the vector must be referenced to a location in a branch structure. This location must be identified by its coordinate within the branch (chainage), and may also be defined by its geographic coordinates within the coordinate system used. An example of a branch is given below.

The FEWS configuration file that stores all information of branches is called the:

Branches 1.00 default.xml

More information on the branches file can be found on:

http://public.wldelft.nl/display/FEWSDOC/05+Branches

Each new branch added to the Branches XML file has an ID, this ID must refer to a location ID in the Locations definition.

Convert SOBEK-CF IDS files to FEWS Branches

SOBEK-CF uses *.ids files in sideview to present longitudinal series. these *.ids files can be converted to FEWS branches in a few steps. An EXCEL spreadsheet with a special conversion function has been created that can help with the conversion of *.ids files to branches. The spreadsheet is called "FEWS Longitudinal profiles.xls".

When converting *.ids files to branches make sure you have the following files available:

  • Keelung.ids: File with the branch information, generated by Netter
  • Calcdim.his and Calcdim.hia: Files with static information from cross-sections that can be found in the SOBEK work folder. Information on bottom level and street level will be extracted from this file.
  • Reachdim.his and Reachdim.hia: Files with static information from reaches that can be found in the SObEK work folder. Information on the length of the reaches will be extracted from this file.
  • Calcpnt.his: SOBEK File with computed water levels on all calculation nodes.
  • Reachseg.his: SOBEK File with computed discharges and velocities.

The following steps need to be followed in order to make the branch file.

  1. Open the "FEWS Longitudinal profiles.xls" file in EXCEL, this file has 4 worksheets named;
    • Calcdim: information that will be copied from the Calcdim.his file.
    • Rechdim: information that will be copied from the Rechdim.his file.
    • Gridpoints: branch information for levels that will be computed within the EXCEL sheet.
    • Segments: branch information for flows that will be computed within the EXCEL sheet.
  2. Delete all information from these 4 worksheets.
  3. Open the "Calcdim.his" file in ODS_View.exe (this is a viewer for HIS files installed on all machines that have SOBEK installed). Make sure the corresponding "Calcdim.hia" file is in the same directory.
    • Select all data in ODS_View and export the data to a CSV file "Calcdim.csv" by pressing the "<Export data> button.
    • Open the "Calcdim.csv" file in EXCEL and convert the column with data from "data to columns", can be found under the "Data" menu item.
    • Copy the data for all cells to the Calcdim worksheet in the "FEWS Longitudinal profiles.xls" file.
  4. Open the "Reachdim.his" file in ODS_View.exe (this is a viewer for HIS files installed on all machines that have SOBEK installed). Make sure the corresponding "Reachdim.hia" file is in the same directory.
    • Select all data in ODS_View and export the data to a CSV file "Rechdim.csv" by pressing the "<Export data> button.
    • Open the "Rechdim.csv" file in EXCEL and convert the column with data from "data to columns", can be found under the "Data" menu item.
    • Copy the data for all cells to the Rechdim worksheet in the "FEWS Longitudinal profiles.xls" file.
  5. Open the "Visual Basic Editor" in EXCEL by pressing ALT+F11. In the top part of the procedure you need to change the filename of the SOBEK Ids file (i.e. "d:\Test\Hsintien.ids").
  6. Then press F5 from the Visual Basic Editor. The procedure will now run and fill the Gridpoints and Segments worksheets.
  7. In XML-Spy you can now create two new branches with ids for the Level and Flow branches; "Hsientien_Level" and "Hsientien_Flow".
    • Copy the first 5 columns of the EXCEL sheet Gridpoints to the "Hsientien_Level" pt elements.

    • Enter also the startChainage and endChainage values in the corresponding elements.
    • Copy the first 2 columns of the EXCEL sheet Segments to the "Hsientien_Flow" pt elements.

    • Enter also the startChainage and endChainage values in the corresponding elements.

The Branches file is now complete, you can add additional information for the description elements, left bank elements, etc..

Note: The Flow branch has no z or z_rb levels, these are not useful for flows.

Note: The distance from the start of the branch is different for levels and flows. Because SOBEK-CF uses a staggered grid, the first calculation point where levels are computed starts with 0. The first pt in the chainage for Flows is halfway the first branch.

Importing Longitudinal time series from SOBEK-CF computations

In FEWS the General Adapter is used to run external models. As mentioned before the "SbkBatch.exe" module is used as model adapter for SOBEK-CF and the "PostSobekModelAdapter" is used to import longitudinal time series. An example of a General Adapter configuration that runs the "PostSobekModelAdapter" is shown below.

<?xml version="1.0" encoding="UTF-8"?>
<generalAdapterRun xmlns="http://www.wldelft.nl/fews"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.wldelft.nl/fews http://fews.wldelft.nl/schemas/version1.0/generalAdapterRun.xsd">
	<!-- General information for General Adapter run -->
	<general>
		<description>SOBEK Model Forecast run for Tanshui with Keelung tunnel</description>
		<rootDir>%REGION_HOME%/Modules/TanshuiRRCFKT</rootDir>
		<workDir>%ROOT_DIR%</workDir>
		<exportDir>%ROOT_DIR%</exportDir>
		<exportIdMap>SobekTanshui_RR_CF_Export</exportIdMap>
		<importDir>%ROOT_DIR%/Update_output</importDir>
		<importIdMap>SobekTanshui_RR_CF_Import</importIdMap>
		<dumpFileDir>%REGION_HOME%/DumpFiles</dumpFileDir>
		<dumpDir>%ROOT_DIR%</dumpDir>
		<diagnosticFile>%ROOT_DIR%/diagnostics/postsobekmodeladapter.xml</diagnosticFile>
		<convertDatum>false</convertDatum>
		<timeZone>
			<timeZoneOffset>+00:00</timeZoneOffset>
		</timeZone>
		</general>
		<activities>
			<executeActivities>
				<!-- Longitudinal display Level -->
				<executeActivity>
					<command>
						<className>nl.wldelft.fews.adapter.sobek.PostSobekModelAdapter</className>
					</command>
					<arguments>
						<argument>%ROOT_DIR%</argument>
						<argument>Config/Level_Profile_Config.xml</argument>
					</arguments>
					<timeOut>800000</timeOut>
				</executeActivity>
				<!-- Longitudinal display flow -->
				<executeActivity>
					<command>
						<className>nl.wldelft.fews.adapter.sobek.PostSobekModelAdapter</className>
					</command>
					<arguments>
						<argument>%ROOT_DIR%</argument>
						<argument>Config/Flow_Profile_Config.xml</argument>
					</arguments>
					<timeOut>800000</timeOut>
				</executeActivity>
			</executeActivities>
			<importActivities>
				<!-- Import SBK results -->
				<importTimeSeriesActivity>
					<description>Import XML file</description>
					<importFile>Calcpnt.xml</importFile>
					<timeSeriesSets>
						<timeSeriesSet>
							<moduleInstanceId>Tanshui_Sobek_Profile_KeelungTunnel</moduleInstanceId>
							<valueType>longitudinalprofile</valueType>
							<parameterId>H.simulated</parameterId>
							<locationId>Keelung_Level</locationId>
							<timeSeriesType>simulated forecasting</timeSeriesType>
							<timeStep unit="minute" multiplier="15" />
							<readWriteMode>add originals</readWriteMode>
							<expiryTime unit="day" multiplier="2" />
						</timeSeriesSet>
					</timeSeriesSets>
				</importTimeSeriesActivity>
				<importTimeSeriesActivity>
					<description>Import XML file</description>
					<importFile>Reachseg.xml</importFile>
					<timeSeriesSets>
						<timeSeriesSet>
							<moduleInstanceId>Tanshui_Sobek_Profile_KeelungTunnel</moduleInstanceId>
							<valueType>longitudinalprofile</valueType>
							<parameterId>Q.simulated</parameterId>
							<locationId>Keelung_Flow</locationId>
							<timeSeriesType>simulated forecasting</timeSeriesType>
							<timeStep unit="minute" multiplier="15" />
							<readWriteMode>add originals</readWriteMode>
							<expiryTime unit="day" multiplier="2" />
						</timeSeriesSet>
					</timeSeriesSets>
				</importTimeSeriesActivity>
			</importActivities>
		</activities>
</generalAdapterRun>

This configuration can be executed as a separate Module Instance or included in the Module instance that runs the SOBEK model with the "SbkBatch.exe" module.

Note: Do not forget to add the branch location to the IdMapping configuration.

Configuration of the "PostSobekModelAdapter" is done with a separate configuration file. For importing the Flows as longitudinal time series, the following configuration file can be used.

Note: The hisfile element "Reachseg.his" is added as a dummy, if you do not enter a hisfile element in the adapter configuration, the adapter will read all *.his that are located in the workDir folder and return an error if one of those files is incorrect.

In this example the "PostSobekModelAdapter" will read the mapfile element "Reachseg.his" file from the workDir folder "TANS2004.lit/work". It will try to map all data points from this "Reachseg.his" file with pt locations from the brachFile "Flow_Tanshui_Branch.xml". The result file will be named "Reachseg.xml" and stored in the exportDir "Update_output".

One file that need to be located in the configDir element "Config" is the "Flow_Tanshui_Branch.xml" file. This is partly a copy from the Branches XML file from the FEWS Regionalconfigfiles folder. This file is required by the "PostSobekModelAdapter" and has the following layout.

  • No labels