RainFARM Julia module Documentation

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.rainfarmFunction.
rainfarm(r,slope,nf,weight=1.;fglob=false, fsmooth=false, verbose=false)

Perform general RainFARM downscaling.

#Arguments

  • r : large-scale array to downscale
  • slope : spatial spectral slope
  • nf : refinement factor for spatial downscaling
  • weight : weights for orographic downscaling
  • fglob : conserve global average over domain
  • fsmooth: use smoothing instead of gp conservation
  • verbose: provide some progress report
source
RainFARM.rfweightsFunction.
ww = rfweights(orofile, reffile, nf; weightsfn="", varname="", fsmooth=false)

Compute orographic weights from a fine-scale precipitation climatology file.

#Arguments

  • orofile : filename of input climatology
  • reffile : filename of reference file (for metadata, e.g. the file to downscale)
  • nf : refinement factor for spatial downscaling
  • weightsfn: write weights to file weightsfn
  • varname : variable name in climatology
  • fsmooth : 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.

source
RainFARM.fft3dFunction.
(fx,ft)=fft3d(z)

Compute spatial (fx) and temporal (ft) Fourier spectra of field z.

source
RainFARM.fitslopexFunction.
sx = fitslopex(fx; kmin=1)

Return spectral slope (minus 1) of spatial spectrum fx.

source
RainFARM.lon_lat_fineFunction.
(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.

source
(data, lon, lat, time) = read_netcdf2d(file, varname="")

Read variable varname (optional) from netcdf file. Returns data and coordinate and time axes.

source
write_netcdf2d(fname,var,lon,lat,varname,filenc)

Write field varto netcdf file fname, with coordinates lon and lat and variable name varname. File filenc is used to copy metadata from.

source
RainFARM.aggFunction.
za = agg(z,nas,nat)

Aggregate field z to an array za of size (nas,nas,nat)

source
RainFARM.interpolaFunction.
zi = interpola(z,ns,nt)

Interpolate field z to size (ns,ns,nt) using nearest neighbors.

source
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.

source
RainFARM.metagaussFunction.
fr = metagauss(f)

Generate a metagaussian field multiplying the spectralfield f with random phases and performing an inverse FFT transform to real space.

source
RainFARM.gaussianizeFunction.
g = gaussianize(z)

Gaussianize field z using a sorted random sequence.

source
RainFARM.smoothconvFunction.
zs = smoothconv(z,nas)

Smoothen field z(ns,ns) with a circular kernel of diameter ns/nas using convolution. Takes into account missing values.

source
fm = mergespec_spaceonly(ra,f,kmax)

Spectral merging of coarse field ra and fine field f at wavenumber kmax.

source
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).

source

Index

Scientific references

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.