Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.



What

nameofinstrance

nameofinstance.xml

Description

Configuration of the pcraster transformation module

schema location

http

https://

fews

fewsdocs.

wldelft

deltares.nl/schemas/version1.0/pcrTransformationSets.xsd

Entry in ModuleDescriptors

<moduleDescriptor id="PcrTransformation">
<description>PCr Transformation Component</description>
<className>nl.wldelft.fews.system.plugin.transformation.PcrTransformationController</className>
</moduleDescriptor>

Table of Contents
Children Display

Introduction

The pcrTransformation model allows a direct link between data in DELFT-FEWS and pcraster using the PCraster API based on in-memory exchange of (XML) data. As such, Delft-Fews can use all available pcraster functions to process data. Pcraster documentation is available elsewhere.

...

                                <areaMap>
                                                <geoDatum>WGS 1984</geoDatum>
                                                <upperLeftCorner>
                                                                <x>2</x>
                                                                <y>1</y>
                                                                <z>90</z>
                                                </upperLeftCorner>
                                                <rows>100</rows>
                                                <columns>100</columns>
                                                <cellwidth>0.1</cellwidth>
                                                <cellheight>0.1</cellheight>
                                </areaMap>

Defining internal, input and output variables

...

  • timeInJulian
  • timeAsDayofYear
  • timeAsDayofMonth
  • timeAsHourofDay
  • timeAsDaysElapsedSince
  • timeAsHoursElapsedSince
  • Reference date.  Needed if the scalar type is defined as "timeAsDaysElapsedSince" or "timeAsHoursElapsedSince".
    Spatial type options are: spatial and non-spatial.  Generally all grid input timeseries are treated as spatial data, while all scalar timeseries (or constant values) are treated as non-spatial. To treat the scalar timeseries (single data value per time) value or constant value as spatial, one can set this option to "spatial". By doing so, the grid (as defined by area map) will be filled with (single) data value from timeseries for a corresponding timestep. Hence for a given timestep, the input to the PCRaster model will be a grid with a constant value in all the grid cells.

However there is an exception to the above mentioned approach. If the input variable is a scalar timeseries at multiple locations (using LocationSetId in TimeSeriesSet definition) and spatial type is set to spatial, and then the following approach is used:

...

  • Variable id (should be matching exactly as defined in the PCRaster text model.
  • Data type (similar to that for internal variables), and 
  • TimeSeriesSet, (at present) all output data should be grid timeseries.

Examples

Info

Please not that the input variable should be regarded as read-only in the actual pcraster script. You should NOT try to modify them within the script. Make a copy in an other variable(e.g. mycopy = theinputvar; ) if this is needed.

Examples

Here are few examples, showing different possibilities to define an interval, input and output variables. Refer to Here are few examples, showing different possibilities to define an interval, input and output variables. Refer to the comments for details:

...

A working sample configuration for PcrTransformation is shown as below:

Code Blocknoformat
xml
xml

<?xml version="1.0" encoding="UTF-8"?>
<!-- Solar radiation module demonstration configuration -->
<pcrTransformationSets xmlns="http://www.wldelft.nl/fews" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.wldelft.nl/fews
http https://fewsfewsdocs.wldelftdeltares.nl/schemas/version1.0/pcrTransformationSets.xsd" version="1.1">
	<logLevel>WARN</logLevel>
	<pcrTransformationSet id="Potradiation">
		<areaMap>
			<locationId>Radiation</locationId>
		</areaMap>
		<definitions>
			<dataExchange>memory</dataExchange>
			<inputVariable variableId="Altitude" dataType="scalar" convertDatum="false" spatialType="spatial">
				<timeSeriesSet>
					<moduleInstanceId>Radiation</moduleInstanceId>
					<valueType>grid</valueType>
					<parameterId>Time.event</parameterId>
					<locationId>Radiation</locationId>
					<timeSeriesType>external historical</timeSeriesType>
					<timeStep unit="minute" multiplier="15"/>
					<relativeViewPeriod unit="hour" start="0" end="48"/>
					<readWriteMode>add originals</readWriteMode>
				</timeSeriesSet>
			</inputVariable>
			<inputVariable variableId="YearDay" dataType="scalar" convertDatum="false" scalarType="timeAsDayofYear">
				<timeSeriesSet>
					<moduleInstanceId>Radiation</moduleInstanceId>
					<valueType>scalar</valueType>
					<parameterId>Time.event</parameterId>
					<locationId>Radiation</locationId>
					<timeSeriesType>external historical</timeSeriesType>
					<timeStep unit="minute" multiplier="15"/>
					<relativeViewPeriod unit="hour" start="0" end="48"/>
					<readWriteMode>add originals</readWriteMode>
				</timeSeriesSet>
			</inputVariable>
			<inputVariable variableId="Hour" dataType="scalar" convertDatum="false" scalarType="timeAsHourofDay">
				<timeSeriesSet>
					<moduleInstanceId>Radiation</moduleInstanceId>
					<valueType>scalar</valueType>
					<parameterId>Time.event</parameterId>
					<locationId>Radiation</locationId>
					<timeSeriesType>external historical</timeSeriesType>
					<timeStep unit="minute" multiplier="15"/>
					<relativeViewPeriod unit="hour" start="0" end="48"/>
					<readWriteMode>add originals</readWriteMode>
				</timeSeriesSet>
			</inputVariable>
			<!-- Total potential Solar radiation -->
			<outputVariable variableId="SL" dataType="scalar" convertDatum="false">
				<timeSeriesSet>
					<moduleInstanceId>Radiation</moduleInstanceId>
					<valueType>grid</valueType>
					<parameterId>Sol.pot</parameterId>
					<locationId>Radiation</locationId>
					<timeSeriesType>external historical</timeSeriesType>
					<timeStep unit="minute" multiplier="15"/>
					<relativeViewPeriod unit="hour" start="0" end="48"/>
					<readWriteMode>add originals</readWriteMode>
				</timeSeriesSet>
			</outputVariable>
			<!-- Diffuse radiation -->
			<outputVariable variableId="SLDF" dataType="scalar" convertDatum="false">
				<timeSeriesSet>
					<moduleInstanceId>Radiation</moduleInstanceId>
					<valueType>grid</valueType>
					<parameterId>Sol.pot.diffuse</parameterId>
					<locationId>Radiation</locationId>
					<timeSeriesType>external historical</timeSeriesType>
					<timeStep unit="minute" multiplier="15"/>
					<relativeViewPeriod unit="hour" start="0" end="48"/>
					<readWriteMode>add originals</readWriteMode>
				</timeSeriesSet>
			</outputVariable>
			<!-- direct radiation -->
			<outputVariable variableId="SLDR" dataType="scalar" convertDatum="false">
				<timeSeriesSet>
					<moduleInstanceId>Radiation</moduleInstanceId>
					<valueType>grid</valueType>
					<parameterId>Sol.pot.direct</parameterId>
					<locationId>Radiation</locationId>
					<timeSeriesType>external historical</timeSeriesType>
					<timeStep unit="minute" multiplier="15"/>
					<relativeViewPeriod unit="hour" start="0" end="48"/>
					<readWriteMode>add originals</readWriteMode>
				</timeSeriesSet>
			</outputVariable>
		</definitions>
		<pcrModel id="String">
			<text><![CDATA[
#! --unittrue --degrees
# Test script to determine radiation over a grid.
#
# Inputs from Delft-Fews into this script
# - YearDay -> scalar with  day since beginning of year
# - Hour of day -> Fractional hour of day (e.g. 12.5 = 12:30)
# Ouputs to FEWS
# - SL -> Total Solar radiation
#
# This version determines Clear Sky radiation assuming a level surface using a uniform
# altitude. This level is configured in the script below.
Altitude=spatial(10);

Latitude = ycoordinate(boolean(Altitude));
Longitude = xcoordinate(boolean(Altitude));

Day =YearDay;
pi = 3.1416;
Sc       = 1367.0;          # Solar constant (Gates, 1980) [W/m2]
Trans    = 0.6;             # Transmissivity tau (Gates, 1980)

AtmPcor = ((288-0.0065*Altitude)/288)**5.256;            # atm pressure corr [-]

# Solar geometry
# ----------------------------
# SolDec  :declination sun per day  between +23 and -23 [deg]
# HourAng :hour angle [-] of sun during day
# SolAlt  :solar altitude [deg], height of sun above horizon
# SolDec  = -23.4*cos(360*(Day+10)/365);
# Now added a new function that should work on all latitudes!
theta    =(Day-1)*360/365;  # day expressed in degrees

# Time change equal to 4 min per degree longtitude
# Assume the time input to be GMT
HourS = Hour + (Longitude * 4/60);

SolDec =180/pi * (0.006918-0.399912 * cos(theta)+0.070257 * sin(theta) -   0.006758 * cos(2*theta)+0.000907 * sin(2*theta) -  0.002697 * cos(3*theta)+0.001480 * sin(3*theta));

HourAng = 15*(HourS-12.01);

SolAlt  = scalar(asin(scalar(sin(Latitude)*sin(SolDec)+cos(Latitude)*
           cos(SolDec)*cos(HourAng))));

# Solar azimuth
# ----------------------------
# SolAzi  :angle solar beams to N-S axes earth [deg]
 SolAzi = scalar(acos((sin(SolDec)*cos(Latitude)-cos(SolDec)*
          sin(Latitude)*cos(HourAng))/cos(SolAlt)));
 SolAzi = if(HourS le 12 then SolAzi else 360 - SolAzi);

 Slope = spatial(0.0001);
 Aspect = spatial(1);

# Surface azimuth
# ----------------------------
# cosIncident :cosine of angle of incident; angle solar beams to angle surface
 cosIncident = sin(SolAlt)*cos(Slope)+cos(SolAlt)*sin(Slope)
               *cos(SolAzi-Aspect);

# Radiation outer atmosphere
# ----------------------------
 OpCorr = Trans**((sqrt(1229+(614*sin(SolAlt))**2)
          -614*sin(SolAlt))*AtmPcor);    # correction for air masses [-]
 Sout   = Sc*(1+0.034*cos(360*Day/365)); # radiation outer atmosphere [W/m2]
 Snor   = Sout*OpCorr;                   # rad on surface normal to the beam [W/m2]

# Radiation at DEM
# ----------------------------
# Sdir   :direct sunlight on a horizontal surface [W/m2] if no shade
# Sdiff  :diffuse light [W/m2] for shade and no shade
# Stot   :total incomming light Sdir+Sdiff [W/m2] at Hour
# Radiation :avg of Stot(Hour) and Stot(Hour-HourStep)
# NOTE: PradM only valid for HourStep and DayStep = 1
 Sdir   = if(Snor*cosIncident<0,0.0,Snor*cosIncident);
 Sdiff  = if(Sout*(0.271-0.294*OpCorr)*sin(SolAlt)<0, 0.0,
          Sout*(0.271-0.294*OpCorr)*sin(SolAlt));

# Fill in missing values with areaaaverage
SLDR=cover((Sdir*1),(Altitude * 0) + areaaverage(Sdir*1,boolean(Altitude))); # hourly rad [W/m2]
SLDF=cover((Sdiff*1),(Altitude * 0) + areaaverage(Sdiff*1,boolean(Altitude))); # hourly rad [W/m2]

SL   = SLDR + SLDF;       # Total rad  in [W/m2]



			]]></text>
		</pcrModel>
	</pcrTransformationSet>
</pcrTransformationSets>

Points precipitation to grid example

Code Block
xml
xml
<?xml version="1.0" encoding="UTF-8"?>
<pcrTransformationSets 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/pcrTransformationSets.xsd" version="1.1">
	<logLevel>WARN</logLevel>
	<pcrTransformationSet id="Thiessen">
		<areaMap>
			<locationId>FineGrid</locationId>
		</areaMap>
		<definitions>
			<dataExchange>memory</dataExchange>
			<inputVariable variableId="P" dataType="scalar" convertDatum="false">
				<timeSeriesSet>
					<moduleInstanceId>ImportPubRts</moduleInstanceId>
					<valueType>scalar</valueType>
					<parameterId>P.obs</parameterId>
					<locationSetId>MetGauges_P.obs</locationSetId>
					<timeSeriesType>external historical</timeSeriesType>
					<timeStep unit="minute" multiplier="10"/>
					<relativeViewPeriod unit="hour" start="-96" startOverrulable="true" end="0"/>
					<readWriteMode>add originals</readWriteMode>
				</timeSeriesSet>
			</inputVariable>
			<outputVariable variableId="MeasMap" dataType="scalar" convertDatum="false">
				<timeSeriesSet>
					<moduleInstanceId>PrecipitationGaugeToGrid_Historical</moduleInstanceId>
					<valueType>grid</valueType>
					<parameterId>P.obs</parameterId>
					<locationId>FineGrid</locationId>
					<timeSeriesType>simulated forecasting</timeSeriesType>
					<timeStep unit="minute" multiplier="10"/>
					<relativeViewPeriod unit="hour" start="-96" end="0" startOverrulable="true"/>
					<readWriteMode>add originals</readWriteMode>
				</timeSeriesSet>
			</outputVariable>
		</definitions>
		<pcrModel id="String">
			<text><![CDATA[#! --unittrue --degrees
dynamic
# Simple Thiesen polygons to get spatial average precipitation on a grid

# Creat unique Id's for input stations
Unq = uniqueid(boolean(P));
# Now generate polygons and fill those
GaugeArea = spreadzone(ordinal(cover(Unq,0)),0,1);
MeasMap = areaaverage(P,GaugeArea);	
]]></text>
		</pcrModel>
	</pcrTransformationSet>
</pcrTransformationSets>

PCRaster installation

For 64 bit support PCRaster needs to be installed manually. See: PCRaster