RainFARM Julia module Documentation
RainFARM.jl is a Julia library and a collection of command-line interface tools implementing the RainFARM (Rainfall Filtered Autoregressive Model) stochastic precipitation downscaling method adapted for climate models. Adapted for climate downscaling according to (D'Onofrio et al. 2018) and with fine-scale orographic weights (Terzago et al. 2018).
RainFARM (Rebora et al. 2006) is a metagaussian stochastic downscaling procedure based on the extrapolation of the coarse-scale Fourier power spectrum of a spatio-temporal precipitation field to small scales.
Functions
RainFARM.rainfarm
— Function.rainfarm(r,slope,nf,weight=1.;fglob=false, fsmooth=false, verbose=false)
Perform general RainFARM downscaling.
#Arguments
r
: large-scale array to downscaleslope
: spatial spectral slopenf
: refinement factor for spatial downscalingweight
: weights for orographic downscalingfglob
: conserve global average over domainfsmooth
: use smoothing instead of gp conservationverbose
: provide some progress report
RainFARM.rfweights
— Function.ww = rfweights(orofile, reffile, nf; weightsfn="", varname="", fsmooth=false)
Compute orographic weights from a fine-scale precipitation climatology file.
#Arguments
orofile
: filename of input climatologyreffile
: filename of reference file (for metadata, e.g. the file to downscale)nf
: refinement factor for spatial downscalingweightsfn
: write weights to file weightsfnvarname
: variable name in climatologyfsmooth
: use smoothing instead of gp conservation
#Returns
ww
: a weight matrix also saved to weightsfn
#Depends
This function uses external system calls using the "cdo" command (https://code.mpimet.mpg.de/projects/cdo/wiki/Cdo) which needs to be available on your system.
RainFARM.fft3d
— Function.(fx,ft)=fft3d(z)
Compute spatial (fx
) and temporal (ft
) Fourier spectra of field z
.
RainFARM.fitslopex
— Function.sx = fitslopex(fx; kmin=1)
Return spectral slope (minus 1) of spatial spectrum fx
.
RainFARM.lon_lat_fine
— Function.(lon_f, lat_f) = lon_lat_fine(lon, lat,nf)
Interpolate longitude and latitude arrays (2d or 1d) lon
and lat
to higher resolution by a factor nf
.
RainFARM.read_netcdf2d
— Function.(data, lon, lat, time) = read_netcdf2d(file, varname="")
Read variable varname
(optional) from netcdf file
. Returns data and coordinate and time axes.
RainFARM.write_netcdf2d
— Function.write_netcdf2d(fname,var,lon,lat,varname,filenc)
Write field var
to netcdf file fname
, with coordinates lon
and lat
and variable name varname
. File filenc
is used to copy metadata from.
RainFARM.agg
— Function.za = agg(z,nas,nat)
Aggregate field z
to an array za
of size (nas,nas,nat)
RainFARM.interpola
— Function.zi = interpola(z,ns,nt)
Interpolate field z
to size (ns,ns,nt)
using nearest neighbors.
RainFARM.initmetagauss
— Function.f = initmetagauss(sx,st,nso,nto)
Generate the spectral amplitudes f
for a metagaussian field of size nso * nso * nto
with slopes sx
and st
.
RainFARM.metagauss
— Function.fr = metagauss(f)
Generate a metagaussian field multiplying the spectralfield f
with random phases and performing an inverse FFT transform to real space.
RainFARM.gaussianize
— Function.g = gaussianize(z)
Gaussianize field z
using a sorted random sequence.
RainFARM.smoothconv
— Function.zs = smoothconv(z,nas)
Smoothen field z(ns,ns)
with a circular kernel of diameter ns/nas
using convolution. Takes into account missing values.
RainFARM.mergespec_spaceonly
— Function.fm = mergespec_spaceonly(ra,f,kmax)
Spectral merging of coarse field ra
and fine field f
at wavenumber kmax
.
RainFARM.downscale_spaceonly
— Function.rf = downscale_spaceonly(r,f,weight=1.;fglob=false, fsmooth=false )
Downscale precipitation field r
using metagaussian spectral field f
. An optional weights array can be specified. Precipitation can be conserved globally (fglob
) or using convolution (fsmooth
).
Index
RainFARM.agg
RainFARM.downscale_spaceonly
RainFARM.fft3d
RainFARM.fitslopex
RainFARM.gaussianize
RainFARM.initmetagauss
RainFARM.interpola
RainFARM.lon_lat_fine
RainFARM.mergespec_spaceonly
RainFARM.metagauss
RainFARM.rainfarm
RainFARM.read_netcdf2d
RainFARM.rfweights
RainFARM.smoothconv
RainFARM.write_netcdf2d
Scientific references
Terzago, S., Palazzi, E., and von Hardenberg, J. (2018). Stochastic downscaling of precipitation in complex orography: a simple method to reproduce a realistic fine-scale climatology, Nat. Hazards Earth Syst. Sci., 18, 2825-2840, doi: https://doi.org/10.5194/nhess-18-2825-2018
D’Onofrio, D., Palazzi, E., von Hardenberg, J., Provenzale, a., & Calmanti, S. (2014). Stochastic Rainfall Downscaling of Climate Models. Journal of Hydrometeorology, 15(2), 830–843. doi: https://doi.org/10.1175/JHM-D-13-096.1
Rebora, N., Ferraris, L., von Hardenberg, J., & Provenzale, A. (2006). RainFARM: Rainfall Downscaling by a Filtered Autoregressive Model. Journal of Hydrometeorology, 7(4), 724–738. doi: https://doi.org/10.1175/JHM517.1
Authors
Julia module - J. von Hardenberg (2016-2018). Based on a Matlab version for climate downscaling by D. D'Onofrio and J. von Hardenberg (2014). Original Matlab code following Rebora et al. 2006, developed jointly by ISAC-CNR and CIMA Foundation in 2004-2006.