Port models to LUE

Contents

Port models to LUE#

TODO

See the status of LUE page to find out more about which PCRaster operations already have an equivalent in LUE and which PCRaster Python Framework classes are available in LUE as well.

lue.pcraster#

This module contains wrappers around LUE operations that behave as PCRaster operations as much as possible. This makes it easier to port models that use the PCRaster Python package to use the LUE Python package.

Currently, it is not possible to provide wrappers for all PCRaster operations. In some cases, we can work around missing functionality in LUE by doing things slightly different. This may involve a performance penalty. Over time these workarounds will be removed.

In case a PCRaster operation supports passing in a non-spatial value, but the LUE operation does not, the wrappers will convert the non-spatial values into a spatial value automatically.

In case PCRaster contains an operation which LUE does not, then we try to work around it by using other operations that produce the same results. If no work-around can be used, a NotImplementedError exception is raised.

LUE does not support value scales. The wrappers in this module assume the cell representations used are the PCRaster ones:

  • uint8 for LDD and boolean values

  • int32 for nominal and ordinal values

  • float32 for scalar and directional values

LUE itself supports additional cell represenations (uint32, int64, uint64, float64).

LUE does not have the notion of non-spatial. This is relevant when passing two “non-spatial” arguments to an operator (e.g.: a & b). The regular Python rules are then in effect.

class lue.pcraster.Configuration(array_shape=None, partition_shape=None, cell_size=None)#

Class for storing information that is required for LUE to be able to mimic PCRaster

PCRaster makes use of a clone raster. This raster contains information about the shape of the underlying array and the size of the raster cells. This class fulfills the same role.

lue.pcraster.abs(expression)#
lue.pcraster.accucapacityflux(ldd, material, transportcapacity)#
lue.pcraster.accucapacitystate(ldd, material, transportcapacity)#
lue.pcraster.accuflux(ldd, material)#
lue.pcraster.accufraction(ldd, material, transportcapacity)#
lue.pcraster.accufractionflux(ldd, material, transportcapacity)#
lue.pcraster.accufractionstate(ldd, material, transportcapacity)#
lue.pcraster.accuthreshold(ldd, material, threshold)#
lue.pcraster.accuthresholdflux(ldd, material, threshold)#
lue.pcraster.accuthresholdstate(ldd, material, threshold)#
lue.pcraster.accutraveltimeflux(ldd, material, transporttraveltime)#
lue.pcraster.accutraveltimefractionflux(ldd, material, transporttraveltime)#
lue.pcraster.accutraveltimefractionstate(ldd, material, transporttraveltime)#
lue.pcraster.accutraveltimestate(ldd, material, transporttraveltime)#
lue.pcraster.accutriggerflux(ldd, material, transporttrigger)#
lue.pcraster.accutriggerstate(ldd, material, transporttrigger)#
lue.pcraster.acos(expression)#
lue.pcraster.areaarea(areaclass)#
lue.pcraster.areaaverage(expression, areaclass)#
lue.pcraster.areadiversity(expression, areaclass)#
lue.pcraster.areamajority(expression, areaclass)#
lue.pcraster.areamaximum(expression, areaclass)#
lue.pcraster.areaminimum(expression, areaclass)#
lue.pcraster.areanormal(areaclass)#
lue.pcraster.areaorder(expression, areaclass)#
lue.pcraster.areatotal(expression, areaclass)#
lue.pcraster.areauniform(areaclass)#
lue.pcraster.argorder(*args)#
lue.pcraster.argorderaddarealimited(*args)#
lue.pcraster.argorderarealimited(*args)#
lue.pcraster.argorderwithid(*args)#
lue.pcraster.argorderwithidaddarealimited(*args)#
lue.pcraster.argorderwithidarealimited(*args)#
lue.pcraster.asin(expression)#
lue.pcraster.aspect(dem)#
lue.pcraster.atan(expression)#
lue.pcraster.boolean(expression)#
lue.pcraster.catchment(*args)#
lue.pcraster.catchmenttotal(*args)#
lue.pcraster.cellarea(*args)#
lue.pcraster.celllength(*args)#
lue.pcraster.clump(expression)#
lue.pcraster.cos(expression)#
lue.pcraster.cover(expression1, expression2, *expressions)#
lue.pcraster.defined(expression)#
lue.pcraster.directional(expression)#
lue.pcraster.div(expression1, expression2)#
lue.pcraster.downstream(ldd, expression)#
lue.pcraster.downstreamdist(ldd)#
lue.pcraster.dynamicwave(*args)#
lue.pcraster.dynwaveflux(*args)#
lue.pcraster.dynwavestate(*args)#
lue.pcraster.eq(expression1, expression2)#
lue.pcraster.exp(power)#
lue.pcraster.extentofview(*args)#
lue.pcraster.fac(*args)#
lue.pcraster.ge(expression1, expression2)#
lue.pcraster.gt(expression1, expression2)#
lue.pcraster.horizontan(*args)#
lue.pcraster.idiv(*args)#
lue.pcraster.ifthen(condition, expression)#
lue.pcraster.ifthenelse(condition, expression1, expression2)#
lue.pcraster.influencesimplegauss(*args)#
lue.pcraster.inversedistance(*args)#
lue.pcraster.is_boolean(expression)#
lue.pcraster.is_directional(expression)#
lue.pcraster.is_ldd(expression)#
lue.pcraster.is_nominal(expression)#
lue.pcraster.is_non_spatial(argument)#
lue.pcraster.is_ordinal(expression)#
lue.pcraster.is_scalar(expression)#
lue.pcraster.is_spatial(argument)#
lue.pcraster.kinematic(ldd, Qold, q, alpha, beta, nrTimeSlices, dT, dX)#
lue.pcraster.kinwaveflux(*args)#
lue.pcraster.kinwavestate(*args)#
lue.pcraster.ldd(expression)#
lue.pcraster.lddcreate(elevation, outflowdepth, corevolume, corearea, catchmentprecipitation)#
lue.pcraster.lddcreatedem(*args)#
lue.pcraster.ldddist(*args)#
lue.pcraster.lddmask(*args)#
lue.pcraster.lddrepair(*args)#
lue.pcraster.le(expression1, expression2)#
lue.pcraster.ln(expression)#
lue.pcraster.log10(expression)#
lue.pcraster.lookup(*args)#
lue.pcraster.lookuplinear(*args)#
lue.pcraster.lookupmapstack(*args)#
lue.pcraster.lookuppotential(*args)#
lue.pcraster.lookupstate(*args)#
lue.pcraster.lt(expression1, expression2)#
lue.pcraster.maparea(*args)#
lue.pcraster.mapmaximum(expression)#
lue.pcraster.mapminimum(expression)#
lue.pcraster.mapnormal()#
lue.pcraster.maptotal(expression)#
lue.pcraster.mapuniform()#
lue.pcraster.markwhilesumge(*args)#
lue.pcraster.markwhilesumle(*args)#
lue.pcraster.max(*args)#
lue.pcraster.min(*args)#
lue.pcraster.mod(*args)#
lue.pcraster.ne(expression1, expression2)#
lue.pcraster.nodirection(*args)#
lue.pcraster.nominal(expression)#
lue.pcraster.non_spatial_to_spatial(fill_value, template=None)#
lue.pcraster.normal(expression)#
lue.pcraster.numpy_scalar_type(expression)#
lue.pcraster.order(*args)#
lue.pcraster.ordinal(expression)#
lue.pcraster.path(*args)#
lue.pcraster.pcrand(expression1, expression2)#
lue.pcraster.pcrnot(expression)#
lue.pcraster.pcror(expression1, expression2)#
lue.pcraster.pcrxor(expression1, expression2)#
lue.pcraster.pit(*args)#
lue.pcraster.plancurv(*args)#
lue.pcraster.pred(*args)#
lue.pcraster.profcurv(*args)#
lue.pcraster.read_if_necessary(*args) tuple#
lue.pcraster.readmap(pathname)#
lue.pcraster.report(expression, pathname)#
lue.pcraster.rounddown(expression)#
lue.pcraster.roundoff(expression)#
lue.pcraster.roundup(expression)#
lue.pcraster.scalar(expression)#
lue.pcraster.setclone(*args)#
lue.pcraster.shift(*args)#
lue.pcraster.shift0(*args)#
lue.pcraster.sin(expression)#
lue.pcraster.slope(dem)#
lue.pcraster.slopelength(*args)#
lue.pcraster.spatial(expression)#
lue.pcraster.spread(*args)#
lue.pcraster.spreadldd(*args)#
lue.pcraster.spreadlddzone(*args)#
lue.pcraster.spreadmax(*args)#
lue.pcraster.spreadmaxzone(*args)#
lue.pcraster.spreadzone(*args)#
lue.pcraster.sqr(expression)#
lue.pcraster.sqrt(expression)#
lue.pcraster.streamorder(*args)#
lue.pcraster.subcatchment(*args)#
lue.pcraster.succ(*args)#
lue.pcraster.tan(expression)#
lue.pcraster.time(*args)#
lue.pcraster.timeinput(*args)#
lue.pcraster.timeinputboolean(*args)#
lue.pcraster.timeinputdirectional(*args)#
lue.pcraster.timeinputldd(*args)#
lue.pcraster.timeinputmodulo(*args)#
lue.pcraster.timeinputnominal(*args)#
lue.pcraster.timeinputordinal(*args)#
lue.pcraster.timeinputscalar(*args)#
lue.pcraster.timeinputsparse(*args)#
lue.pcraster.timeoutput(*args)#
lue.pcraster.timeslice(*args)#
lue.pcraster.transient(*args)#
lue.pcraster.translate_window_length(pcraster_window_length)#

Translate PCRaster window lengths in real distance units, to LUE window lengths, in whole number of cells

The assumption here is that @a pcraster_window_length passed in: - is dividable by the cell size - corresponds with an odd number of cells (odd_number * cell_size) - is possitive

lue.pcraster.uniform(expression)#
lue.pcraster.uniqueid(expression)#
lue.pcraster.upstream(ldd, material)#
lue.pcraster.view(*args)#
lue.pcraster.window4total(expression)#
lue.pcraster.windowaverage(expression, window_length)#
lue.pcraster.windowdiversity(expression, window_length)#
lue.pcraster.windowhighpass(expression, window_length)#
lue.pcraster.windowmajority(expression, window_length)#
lue.pcraster.windowmaximum(expression, window_length)#
lue.pcraster.windowminimum(expression, window_length)#
lue.pcraster.windowtotal(expression, window_length)#
lue.pcraster.xcoordinate(*args)#
lue.pcraster.ycoordinate(*args)#

lue.pcraster.framework#

This module contains classes that mimic the behaviour of the PCRaster Python Framework.

See the PCRaster Python Modelling Framework documentation for more information.

class lue.pcraster.framework.DynamicFramework(model, last_time_step=0, first_time_step=1)#

Class for running dynamic models

setQuiet(quiet=True)#
class lue.pcraster.framework.DynamicModel#

Base class for dynamic models

currentTimeStep()#
dynamic()#
firstTimeStep()#
initial()#
nrTimeSteps()#
readmap(name)#
report(variable, name)#
setDebug()#
setQuiet(quiet=True)#
timeSteps()#
exception lue.pcraster.framework.FrameworkError(message)#
class lue.pcraster.framework.MonteCarloFramework(model, nr_samples=0, remove_dirs=True)#

Class for running stochastic models

setForkSamples(fork, nr_cpus=1)#
setQuiet(quiet=True)#
class lue.pcraster.framework.MonteCarloModel#

Base class for stochastic models

currentSampleNumber()#
post_monte_carlo()#
postmcloop()#
pre_monte_carlo()#
premcloop()#
class lue.pcraster.framework.StaticFramework(model)#

Class for running static models

class lue.pcraster.framework.StaticModel#

Base class for static models

initial()#
readmap(name)#
report(variable, name)#
setDebug()#
lue.pcraster.framework.generateNameS(name, sample)#

Return a filename based on the name and sample number passed in.

The resulting name contains a directory and a filename part. The sample number is used as the directory name and the name is used as the filename.

The sample number normally ranges from [1, nrSamples].

See also: generateNameT(), generateNameST()

lue.pcraster.framework.generateNameST(name, sample, timestep)#

Return a filename based on the name, sample number and time step.

See also: generateNameT(), generateNameS()

lue.pcraster.framework.generateNameT(name, time)#

Return a filename based on the name and time step passed in.

The resulting name obeys the 8.3 DOS style format. The time step will be added to the end of the filename and be prepended by 0’s if needed.

The time step normally ranges from [1, nrTimeSteps]. The length of the name should be max 8 characters to leave room for the time step.

The name passed in may contain a directory name.

See also: generateNameS(), generateNameST()