Esempio n. 1
0
def dispfluxperdir(Input,NScal,NEScal,EScal,SEScal,SScal,SWScal,WScal,NWScal):
    # note that all arguments should be greater than zero
    x=0
    Tmp=Input
    Flux=Input
    NTotFlux=scalar(0)
    NETotFlux=scalar(0)
    ETotFlux=scalar(0)
    SETotFlux=scalar(0)
    STotFlux=scalar(0)
    SWTotFlux=scalar(0)
    WTotFlux=scalar(0)
    NWTotFlux=scalar(0)
    while x < 200:
      x = x+1
      NFlux, NEFlux, EFlux, SEFlux, SFlux, SWFlux, WFlux, NWFlux = upstreamsComponent(Tmp,NScal,NEScal,EScal,SEScal,SScal,SWScal,WScal,NWScal)
      NTotFlux=NTotFlux+NFlux
      NETotFlux=NETotFlux+NEFlux
      ETotFlux=ETotFlux+EFlux
      SETotFlux=SETotFlux+SEFlux
      STotFlux=STotFlux+SFlux
      SWTotFlux=SWTotFlux+SWFlux
      WTotFlux=WTotFlux+WFlux
      NWTotFlux=NWTotFlux+NWFlux
      Tmp = upstreams(Tmp,NScal,NEScal,EScal,SEScal,SScal,SWScal,WScal,NWScal)
      xFormat = '%3d' % (x)
      pcr.write(3 * '\b')
      pcr.write(xFormat)
      sys.stdout.flush()
    # TotFlux is idem to results of dispflux(apart from pits)
    TotFlux = NTotFlux + NETotFlux + ETotFlux + SETotFlux + STotFlux + SWTotFlux + WTotFlux + NWTotFlux
    return TotFlux, NTotFlux, NETotFlux, ETotFlux, SETotFlux, STotFlux, SWTotFlux, WTotFlux, NWTotFlux
Esempio n. 2
0
def sedflowBeltsOpti(PreviousHeight,Belts,InputCubePerYear, Diffusion, WidthStream, FixedHead, Duration, Discretisation, \
    NLdd,NELdd,ELdd,SELdd,SLdd,SWLdd,WLdd,NWLdd):

    # this is a copy of seflowOpti, maar BeltArea (through Belts) has been added
    # BeltArea (in nr of cells) is the area of the channel belt 'connected' to each channel cell
 
    # PreviousHeight has mv elsewhere
    # Diffusion in (m3/m)/yr, volume per m width per year
    # Duration, time (yr) represented by one call
    # discretisation of Duration (nr of subtimesteps) 
    # LET OP: fixed head ook verdelen over discretisations!!
    # LET OP: NLdd, NELdd etc kan er volgens mij uit

    AreaOfInterest=defined(PreviousHeight)
    AreaOfInterestZero=mapif(AreaOfInterest,scalar(0.0))

    ChannelsId=uniqueid(AreaOfInterest)
    BeltsBooleanMV=mapif(mapne(Belts,(0)),boolean(1))
    BeltsIDs=spreadzone(nominal(ChannelsId),scalar(0),scalar(BeltsBooleanMV))
    BeltsArea=mapif(AreaOfInterest,areaarea(BeltsIDs))/cellarea()

    TimeStep=Duration/Discretisation
    # input per year (m/year)
    Input=InputCubePerYear/cellarea()
    # input per subtimestep (m/time step)
    InputTS=Input*TimeStep

    # transport (m3/year) for slope is 1
    KCuub=WidthStream*Diffusion
    # transport (m/year) for slope is 1
    KM=KCuub/cellarea()
    # transport (m/subtimestep) for slope is 1
    KTS=KM*TimeStep 

    # expected slope (-)
    SlExp=mapif(boolean(PreviousHeight),mapmaximum(cover(InputTS,scalar(-1000.0))))/KTS

 
    ## create ldd's in all directions
    #LddN=mapif(AreaOfInterest,ldd(nominal(8)))
    #LddNE=mapif(AreaOfInterest,ldd(nominal(9)))
    #LddE=mapif(AreaOfInterest,ldd(nominal(6)))
    #LddSE=mapif(AreaOfInterest,ldd(nominal(3)))
    #LddS=mapif(AreaOfInterest,ldd(nominal(2)))
    #LddSW=mapif(AreaOfInterest,ldd(nominal(1)))
    #LddW=mapif(AreaOfInterest,ldd(nominal(4)))
    #LddNW=mapif(AreaOfInterest,ldd(nominal(7)))

    # modify the input ldds
    NLdd=mapif(AreaOfInterest,NLdd)
    NELdd=mapif(AreaOfInterest,NELdd)
    ELdd=mapif(AreaOfInterest,ELdd)
    SELdd=mapif(AreaOfInterest,SELdd)
    SLdd=mapif(AreaOfInterest,SLdd)
    SWLdd=mapif(AreaOfInterest,SWLdd)
    WLdd=mapif(AreaOfInterest,WLdd)
    NWLdd=mapif(AreaOfInterest,NWLdd)

    # calculate downstream distance
    NLddDownstreamDist=downstreamdist(NLdd)
    NELddDownstreamDist=downstreamdist(NELdd)
    ELddDownstreamDist=downstreamdist(ELdd)
    SELddDownstreamDist=downstreamdist(SELdd)
    SLddDownstreamDist=downstreamdist(SLdd)
    SWLddDownstreamDist=downstreamdist(SWLdd)
    WLddDownstreamDist=downstreamdist(WLdd)
    NWLddDownstreamDist=downstreamdist(NWLdd)

    Elevation = PreviousHeight

    for x in range(0, Discretisation):
       ## transport to downstream neighbour
       Tmp=slopedownstreamOptiOpti(NLdd,Elevation,AreaOfInterestZero,NLddDownstreamDist)*KTS
       NSl=mapifelse(lt(Tmp,scalar(0.0)),scalar(0.0),Tmp)
       Tmp=slopedownstreamOptiOpti(NELdd,Elevation,AreaOfInterestZero,NELddDownstreamDist)*KTS
       NESl=mapifelse(lt(Tmp,scalar(0.0)),scalar(0.0),Tmp)
       Tmp=slopedownstreamOptiOpti(ELdd,Elevation,AreaOfInterestZero,ELddDownstreamDist)*KTS
       ESl=mapifelse(lt(Tmp,scalar(0.0)),scalar(0.0),Tmp)
       Tmp=slopedownstreamOptiOpti(SELdd,Elevation,AreaOfInterestZero,SELddDownstreamDist)*KTS
       SESl=mapifelse(lt(Tmp,scalar(0.0)),scalar(0.0),Tmp)
       Tmp=slopedownstreamOptiOpti(SLdd,Elevation,AreaOfInterestZero,SLddDownstreamDist)*KTS
       SSl=mapifelse(lt(Tmp,scalar(0.0)),scalar(0.0),Tmp)
       Tmp=slopedownstreamOptiOpti(SWLdd,Elevation,AreaOfInterestZero,SWLddDownstreamDist)*KTS
       SWSl=mapifelse(lt(Tmp,scalar(0.0)),scalar(0.0),Tmp)
       Tmp=slopedownstreamOptiOpti(WLdd,Elevation,AreaOfInterestZero,WLddDownstreamDist)*KTS
       WSl=mapifelse(lt(Tmp,scalar(0.0)),scalar(0.0),Tmp)
       Tmp=slopedownstreamOptiOpti(NWLdd,Elevation,AreaOfInterestZero,NWLddDownstreamDist)*KTS
       NWSl=mapifelse(lt(Tmp,scalar(0.0)),scalar(0.0),Tmp)
       TotSl=NSl+NESl+ESl+SESl+SSl+SWSl+WSl+NWSl
    
       #Elevation = cover(FixedHead,InputTS+Elevation+upstreamsperdir(NSl,NESl,ESl,SESl,SSl,SWSl,WSl,NWSl,LddN,LddNE,LddE,LddSE,LddS,LddSW,LddW,LddNW)-TotSl)
       Elevation = cover(FixedHead,InputTS/BeltArea+Elevation+ \
                   upstreamsperdir(NSl,NESl,ESl,SESl,SSl,SWSl,WSl,NWSl,NLdd,NELdd,ELdd,SELdd,SLdd,SWLdd,WLdd,NWLdd)/BeltArea-TotSl/BeltArea)
       xFormat = '%3d' % (x)
       pcr.write(3 * '\b')
       pcr.write(xFormat)
       sys.stdout.flush()

    return Elevation, TotSl