# NetCDF

The SPHY model allows the climate forcing to be read directly from NetCDF format instead of the usual daily pcraster map input. The model runs will slow down when using the NetCDF input, because each time step the data need to be interpolated onto the model grid. It is advisable to use the common pcraster map input instead of the NetCDF input in case model calibration, when many model runs are needed using the same climate period and extent. However, the NetCDF input can be useful for scenario model runs, for instance in climate change impact assessments.

The NetCDF input can be used for precipitation and temperature (daily average, minimum and maximum). Here we explain how to use the NetCDF input for precipitation. All steps are identical for each of the three temperature inputs. To use the NetCDF input, first the precNetcdfFLAG should be set to 1. The location of the NetCDF file should be indicated under precNetcdf, which is the file with a \*.nc extension. The input variable precNetcdfInput is used to give some specific information about how the data are stored in the NetCDF file, each element is separated by a comma (“,”). The information can be obtained by reading the NetCDF file in R, python or other programming or GIS software. The information includes:

* Variable name: This is the variable name given in the NetCDF file. For precipitation this can include precipitation, pcp, prec, etc. For temperature this can include temp, tavg, tmin, tmax, avgtemp, mintemp, maxtemp, etc.
* X-coordinate: The x-coordinate is a variable stored in the NetCDF file. In case of a rectangular grid, this is often indicated with an X, lon or longitude. In case of a rotated grid, this is often indicated with rlon.
* Y-coordinate: The y-coordinate is a variable stored in the NetCDF file. In case of a rectangular grid, this is often indicated with an Y, lat or latitude. In case of a rotated grid, this is often indicated with rlat.
* Interpolation method: There are three interpolation methods implemented: linear, cubic or nearest neighbor. It is suggested to use linear or nearest neighbor interpolation for precipitation input. The cubic interpolation technique may result in negative values in case the NetCDF input includes many 0 values and occasional positive values. For temperature input, all three interpolation techniques can be used. For more information on the difference between the three interpolation techniques see: <https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.griddata.html>
* Multiplication factor: Often precipitation NetCDF data are stored in mm \* 10 format. This to decrease the size of the NetCDF files. In that case a multiplication factor of 0.1 is needed to let the model know that the data first need to be multiplied by 0.1 before further processing.
* EPSG code NetCDF file: The coordinate system of the NetCDF file is most likely different than the coordinate system of the SPHY project. The coordinate system of the NetCDF file is needed to make the necessary transformations of the coordinates and data interpolation. The coordinate system of the NetCDF file can be found by reading the NetCDF in R, python or any GIS program. Each coordinate system is linked to a so-called EPSG code. For instance, the WGS84 coordinate system has EPSG code 4326. In that case, the input will be “epsg:4326”. The code can be found in the following website: <https://spatialreference.org/>. NetCDF file often use rotated pole coordinates. In that case the word “rotated” should be provided. To make the necessary transformations to the coordinates, the NetCDF script will search for the grid\_north\_pole\_latitude and grid\_north\_pole\_longitude variables inside the NetCDF file. Beware, the script will crash in case these variables do not exist.
* EPSG code model domain: Similar to the EPSG code of the NetCDF file, the same needs to be provided of the model domain. See above for information on how to find the EPSG code of the model domain.

The NetCDF input can be for example:

*precNetcdfInput = pcp,X,Y,linear,0.1,epsg:25830,epsg:25830*

* Variable name: pcp
* X-coordinate: X
* Y-coordinate: Y
* Interpolation method: linear
* Multiplication factor: 0.1
* EPSG code NetCDF file: epsg:25830
* EPSG code model domain: epsg:25830

*precNetcdfInput = precipitation,rlon,rlat,linear,1,rotated,epsg:25830*

* Variable name: precipitation
* X-coordinate: rlon
* Y-coordinate: rlat
* Interpolation method: linear
* Multiplication factor: 1
* EPSG code NetCDF file: rotated
* EPSG code model domain: epsg:25830
