5. Structure of resources |
Top Previous Next |
Data for modelling normally have many types, formats and structures: e.g.: CSV, XML, TXT, etc. In SIMPLACE, you should be able to use data from different file types in your solution. As previously shown, you can define the data format and location in the <intefaces> section of a ModelSolution.
In the following section <resources>, you must specify how SIMPLACE will read and name this data. For example:
<resource id="weather" interface="weatherfile" frequence="DAILY">
<header>
<res id="KeyValue" datatype="CHAR" />
<res id="PolygonCode" datatype="CHAR" />
<res id="CURRENTDATE" datatype="DATE" key="CURRENT.DATE" />
<res id="Rain" unit="mm" datatype="DOUBLE" />
<res id="AirTemperatureMax" unit="°C" datatype="DOUBLE" />
<res id="AirTemperatureMin" unit="°C" datatype="DOUBLE" />
<res id="GlobalSolarRadiation" unit="MJ*m**-2" datatype="DOUBLE" />
<res id="WindSpeed" unit="m*s**-1" datatype="DOUBLE" />
<res id="ReferenceEvapotranspiration" unit="mm" datatype="DOUBLE" />
</header>
</resource>
The resource 'weather' reads the file interface 'weatherfile' at a daily frequency. This resource object will contain the variables declared within it (KeyValue, PolygonCode, CURRENTDATE, Rain, AirTemperatureMax, ...) which also need an unique 'id' name, 'datatype' and 'unit' definition. Each one of these variables are the columns of the weatherfile.
Note that the variable CURRENTDATE has an extra attribute key="CURRENT.DATE". This will make SIMPLACE to read the data from the corresponding simulation date from the framework variable CURRENT.DATE. This key attribute can be used to filter data within the filename provided as interface. Imagine that you have one file containing the soil properties for many locations and you want to run SIMPLACE for only one of those locations. This can be done using a variable as the key attribute:
<variables>
<var id="startdate" datatype="DATE">01.01.1982</var>
<var id="enddate" datatype="DATE">31.12.1988</var>
<var id="vLocation" datatype="CHAR" description="key to selected site">Bonn</var>
</variables>
<interfaces default="simpool">
<interface id="soilfile" type="CSV">
<poolsize>2</poolsize>
<divider>,</divider>
<divider />
<filename>${_WORKDIR_}/training/data/soil/soil_database.csv</filename>
</interface>
...
</interfaces>
<resources>
<resource id="soil" interface="soilfile" frequence="ONCE">
<header>
<res id="location" datatype="CHAR" key="vLocation" />
<res id="SoilClassification" datatype="CHAR" />
<res id="SoilTexture" datatype="CHAR" />
<res id="Clay" datatype="DOUBLE" />
<res id="Silt" datatype="DOUBLE" />
<res id="Sand" datatype="DOUBLE" />
<res id="BulkDensity" datatype="DOUBLE" />
...
</header>
</resource>
</resources>
Example above reads a file named 'soil_database.csv' , filter the data for Bonn using key="vLocation" and add it to the resource 'soil'
Now let's do some exercises:
Task 5.1 Solution 05_1_ResourcesWeather.sol.xml uses simplace_modules/test/training/data/weather/bonn5col.xml weather data file, which has 5 columns.
Replace the used weather file with simplace_modules/test/training/data/weather/bonn6col.xml, which has 6 columns and add missing resources.
Hints:
- For each column you need to add one <res /> row in the resource section following the order of columns.
Solution:
Open the 05_1_ResourcesWeather_Answer.sol.xml file to see how it should be done.
Task 5.2 Solution 05_2_ResourcesCrop.sol.xml uses simplace_modules/test/training/data/crop/crop.xml crop file with 3 variables.
Replace the crop file with simplace_modules/test/training/data/crop/crop5_2.xml file, which has 4 variables and also output new added variable (TempSUMAnthesis) in the output file.
Hints:
- For each variable you need to add one <res /> row in the resource section in your solution.
- Add an extra line to the output file for the TempSUMAnthesis variable
Solution:
Open the 05_2_ResourcesCrop_Answer.sol.xml to see how it should be done.
*ModelSolutions are found in simplace_modules\test\training\solution\1_WorkingWithSolutions