Example #1
0
# basePath = 'D:\Box Sync\GlobalSteepness\Datasets\TestCases\mad_'
# outPath = 'D:\Box Sync\GlobalSteepness\Datasets\TestCases\Derivatives\mad_'

# Load in the different grids
dem, flowAcc, flowDir, lats, longs, geoTransform = hp.loadGrids(basePath)

# What is the no data value? Should improve this to automatically find things
ndv = -32768.0

# What parameters do we want to use?
theta = 0.7  # Scaling power of drainage area
Ao = 500 ** 2  # Approximate drainage area of a pixel

# Calculate the areas of each pixels
areas = hp.calcPixelAreas(lats, longs, geoTransform)

# Do all the things!
maxTransportLength, meanDirs, maxZalongMaxL, areas, intA = hp.calculateAll(
    flowDir, flowAcc, dem, lats, longs, areas, theta, Ao, ndv, mask=None
)

# Save the grids
# np.save(outPath+'maxL.npy',maxTransportLength)
# np.save(outPath+'meanDir.npy',meanDirs)
# np.save(outPath+'maxZalongL.npy',maxZalongMaxL)
# np.save(outPath+'area.npy',areas)
# np.save(outPath+'intA.npy',intA)


# Makes some plots!
Example #2
0
thetas = (0.3, 0.5, 0.7) #Scaling power of drainage area
Ao = 500**2 #Approximate drainage area of a pixel, used to normalized drainage area when calculating the integrated area

for name in baseNames:

    print('Working on continent: %s' %name)
    print('At the tone, current time will be: %s' %strftime("%m/%d/%Y %H:%M:%S"))

    #Where are these files being stored
    thisBasePath = os.path.join(basePath,name,name+'_')

    #Load in the different grids
    dem, flowAcc, flowDir, lats, longs, geoTransform = hp.loadGrids(thisBasePath)

    #Calculate the areas of each pixels
    areas = hp.calcPixelAreas(lats, longs, geoTransform, np.logical_not(dem==ndv))

    #Do all the things!
    maxTransportLength, meanDirs, maxZalongMaxL, areas, intA = hp.calculateAllMultipleThetas(flowDir,flowAcc,dem,lats,longs,areas, thetas,Ao,ndv,mask = None)

    #Save the grids
    np.save(thisBasePath+'maxL.npy',maxTransportLength)
    np.save(thisBasePath+'meanDir.npy',meanDirs)
    np.save(thisBasePath+'maxZalongL.npy',maxZalongMaxL)
    np.save(thisBasePath+'area.npy',areas)
    np.save(thisBasePath+'intA.npy',intA)

    maxTransportLength = None
    meanDirs = None
    maxZalongMaxL = None
    areas = None