Index: wflow-py/wflow/wflow_lib.py =================================================================== diff -u -rbcfa3db98112744a480253f1f934f647f5f7cd17 -r747660a81dcda25969a896bed20b0a9d21b01180 --- wflow-py/wflow/wflow_lib.py (.../wflow_lib.py) (revision bcfa3db98112744a480253f1f934f647f5f7cd17) +++ wflow-py/wflow/wflow_lib.py (.../wflow_lib.py) (revision 747660a81dcda25969a896bed20b0a9d21b01180) @@ -662,8 +662,44 @@ return drainwidth +def classify(inmap,lower=[0,10,20,30],upper=[10,20,30,40],classes=[2,2,3,4]): + """ + classify a scaler maps accroding to the boundaries given in classes. + """ + result=ordinal(cover(-1)) + for l, u, c in zip(lower, upper,classes): + result = cover(ifthen(inmap >= l,ifthen(inmap < u,ordinal(c))),result) + + return ifthen(result >=0,result) + + +def hand(dem,ldd,threshold=50.0,stream=None): + """ + Determines heigth above nearest drain. + + Input: + ldd + dem + Optional: + threshold - to determine streams (number of upstreams cell needed to be a stream) + stream - if the threshols is not a stream map (boolean) should be supplied + + Returns: Hand and the stream map + + """ + + #setglobaloption("unittrue") + if threshold: + stream = boolean(ifthenelse(accuflux(ldd,1) > threshold, boolean(1), boolean(0))) + + demdiff = dem - downstream(ldd,dem) + hand = ldddist(ldd,stream,max(demdiff,0))/celllength() + + return hand, stream + + def sCurve(X,a=0.0,b=1.0,c=1.0): """