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 representations (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.BoundingBox(*, north: float = 0.0, west: float = 0.0, south: float = 0.0, east: float = 0.0)#

Class for keeping track of the bounding box of a raster

east: float = 0.0#
north: float = 0.0#
south: float = 0.0#
west: float = 0.0#
class lue.pcraster.Configuration(*, bounding_box=None, cell_size=None, array_shape=None, partition_shape=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.

class lue.pcraster.VALUESCALE(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
Boolean = 1#
Directional = 2#
Ldd = 3#
Nominal = 4#
Ordinal = 5#
Scalar = 6#
lue.pcraster.abs(expression)#
lue.pcraster.accucapacityflux(flow_direction, material, transportcapacity)#
lue.pcraster.accucapacitystate(flow_direction, material, transportcapacity)#
lue.pcraster.accuflux(flow_direction, material)#
lue.pcraster.accufraction(flow_direction, material, transportcapacity)#
lue.pcraster.accufractionflux(flow_direction, material, transportcapacity)#
lue.pcraster.accufractionstate(flow_direction, material, transportcapacity)#
lue.pcraster.accuthreshold(flow_direction, material, threshold)#
lue.pcraster.accuthresholdflux(flow_direction, material, threshold)#
lue.pcraster.accuthresholdstate(flow_direction, material, threshold)#
lue.pcraster.accutraveltimeflux(flow_direction, material, transporttraveltime)#
lue.pcraster.accutraveltimefractionflux(flow_direction, material, transporttraveltime)#
lue.pcraster.accutraveltimefractionstate(flow_direction, material, transporttraveltime)#
lue.pcraster.accutraveltimestate(flow_direction, material, transporttraveltime)#
lue.pcraster.accutriggerflux(flow_direction, material, transporttrigger)#
lue.pcraster.accutriggerstate(flow_direction, 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(amount, flow_direction)#
lue.pcraster.cellarea(*args)#
lue.pcraster.celllength(*args)#
lue.pcraster.cellvalue(*args)#
lue.pcraster.clone()#
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(flow_direction, expression)#
lue.pcraster.downstreamdist(flow_direction)#
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.harmonize_types(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)#

Return whether expression’s value scale is boolean

lue.pcraster.is_directional(expression)#

Return whether expression’s value scale is directional

lue.pcraster.is_ldd(expression)#

Return whether expression’s value scale is LDD

lue.pcraster.is_nominal(expression)#

Return whether expression’s value scale is nominal

lue.pcraster.is_non_spatial(argument)#

Return whether argument is non-spatial

A non-spatial is represented by a LUE asynchronous scalar

lue.pcraster.is_ordinal(expression)#

Return whether expression’s value scale is ordinal

lue.pcraster.is_scalar(expression)#

Return whether expression’s value scale is scalar

lue.pcraster.is_spatial(argument)#

Return whether argument is spatial

A spatial is represented by a LUE asynchronous raster

lue.pcraster.kinematic(flow_direction, 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.lue_is_float32_raster(argument)#

Return whether argument is an asynchronous LUE float32 raster

lue.pcraster.lue_is_float32_scalar(argument)#

Return whether argument is a LUE asynchronous scalar float32 value

lue.pcraster.lue_is_int32_raster(argument)#

Return whether argument is an asynchronous LUE int32 raster

lue.pcraster.lue_is_int32_scalar(argument)#

Return whether argument is a LUE asynchronous scalar int32 value

lue.pcraster.lue_is_uint8_raster(argument)#

Return whether argument is an asynchronous LUE uint8 raster

lue.pcraster.lue_is_uint8_scalar(argument)#

Return whether argument is a LUE asynchronous scalar uint8 value

lue.pcraster.lue_is_value(argument)#

Return whether argument is a numeric value

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.numpy2pcr(data_type, array, no_data_value)#
lue.pcraster.numpy_scalar_type(expression)#
lue.pcraster.order(*args)#
lue.pcraster.ordinal(expression)#
lue.pcraster.path(*args)#
lue.pcraster.pcr2numpy(array, no_data_value)#
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(pathname)#
lue.pcraster.setglobaloption(option)#
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(timeseries_pathname: str, id_expression, timestep: int)#
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 positive

lue.pcraster.uniform(expression)#
lue.pcraster.uniqueid(expression)#
lue.pcraster.upstream(flow_direction, 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(expression)#
lue.pcraster.ycoordinate(expression)#

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

run(*, rate_limit=0)#
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()