Example #1
0
def test_storms():
    input_file_string = os.path.join(_THIS_DIR, 'drive_sp_params_storms.txt')
    inputs = ModelParameterDictionary(input_file_string)
    nrows = inputs.read_int('nrows')
    ncols = inputs.read_int('ncols')
    dx = inputs.read_float('dx')
    dt = inputs.read_float('dt')
    time_to_run = inputs.read_float('run_time')
    uplift = inputs.read_float('uplift_rate')

    mg = RasterModelGrid(nrows, ncols, dx)

    mg.add_zeros('topographic__elevation', at='node')
    z = mg.zeros(at='node')
    mg['node']['topographic__elevation'] = z + np.random.rand(len(z)) / 1000.
    mg.add_zeros('water__unit_flux_in', at='node')

    precip = PrecipitationDistribution(input_file=input_file_string)
    fr = FlowRouter(mg)
    sp = StreamPowerEroder(mg, **inputs)

    for (interval_duration, rainfall_rate) in \
            precip.yield_storm_interstorm_duration_intensity():
        if rainfall_rate != 0.:
            mg.at_node['water__unit_flux_in'].fill(rainfall_rate)
            mg = fr.route_flow()
            sp.run_one_step(dt)
        mg.at_node['topographic__elevation'][
            mg.core_nodes] += uplift * interval_duration
Example #2
0
def main():
    # First we will create an instance of PrecipitationDistribution
    PD = PrecipitationDistribution(mean_storm_duration=2.0,
                                   mean_interstorm_duration=50.0,
                                   mean_storm_depth=0.05,
                                   total_t=37000.)

    # Because the values for storm duration, interstorm duration, storm
    # depth and intensity are set stochastically in the initialization
    # phase, we should see that they seem reasonable.

    print("Mean storm duration is: ", PD.mean_storm_duration, " hours, while",
          "the value from the Poisson distribution is: ", PD.storm_duration)
    print("Mean interstorm Duration is: ", PD.mean_interstorm_duration,
          'hours, while the value from the Poisson distribution is: ',
          PD.interstorm_duration)
    print("Mean storm depth is: ", PD.mean_storm_depth, "mm, while the value",
          "from the Poisson distribution is: ", PD.storm_depth)
    print("Mean intensity is: ", PD.mean_intensity, "mm/hr, while the value",
          "from the Poisson distribution is: ", PD.intensity)
    print('\n')

    # If we generate a time series we can plot a precipitation distribution
    PD.get_storm_time_series()

    # And get the storm array from the component..
    storm_arr = PD.storm_time_series

    # And now to call the plotting method.
    create_precip_plot(storm_arr)
Example #3
0
def test_storms():
    input_file_string = os.path.join(_THIS_DIR, 'drive_sp_params_storms.txt')
    inputs = ModelParameterDictionary(input_file_string)
    nrows = inputs.read_int('nrows')
    ncols = inputs.read_int('ncols')
    dx = inputs.read_float('dx')
    dt = inputs.read_float('dt')
    time_to_run = inputs.read_float('run_time')
    uplift = inputs.read_float('uplift_rate')

    mg = RasterModelGrid(nrows, ncols, dx)

    mg.add_zeros('topographic__elevation', at='node')
    z = mg.zeros(at='node')
    mg['node']['topographic__elevation'] = z + np.random.rand(len(z)) / 1000.
    mg.add_zeros('water__unit_flux_in', at='node')

    precip = PrecipitationDistribution(input_file=input_file_string)
    fr = FlowRouter(mg)
    sp = StreamPowerEroder(mg, **inputs)

    for (interval_duration, rainfall_rate) in \
            precip.yield_storm_interstorm_duration_intensity():
        if rainfall_rate != 0.:
            mg.at_node['water__unit_flux_in'].fill(rainfall_rate)
            mg = fr.route_flow()
            sp.run_one_step(dt)
        mg.at_node['topographic__elevation'][
            mg.core_nodes] += uplift * interval_duration
def main():
    # First we will create an instance of PrecipitationDistribution
    PD = PrecipitationDistribution(mean_storm_duration = 2.0,
                                   mean_interstorm_duration = 50.0,
                                   mean_storm_depth = 0.05, total_t = 37000.)

    # Because the values for storm duration, interstorm duration, storm
    # depth and intensity are set stochastically in the initialization
    # phase, we should see that they seem reasonable.

    print("Mean storm duration is: ", PD.mean_storm_duration, " hours, while",
             "the value from the Poisson distribution is: ", PD.storm_duration)
    print("Mean interstorm Duration is: ", PD.mean_interstorm_duration,
          'hours, while the value from the Poisson distribution is: ',
          PD.interstorm_duration)
    print("Mean storm depth is: ", PD.mean_storm_depth, "mm, while the value",
          "from the Poisson distribution is: ", PD.storm_depth)
    print("Mean intensity is: ", PD.mean_intensity, "mm/hr, while the value",
          "from the Poisson distribution is: ", PD.intensity)
    print('\n')


    # If we generate a time series we can plot a precipitation distribution
    PD.get_storm_time_series()

    # And get the storm array from the component..
    storm_arr = PD.storm_time_series

    # And now to call the plotting method.
    create_precip_plot(storm_arr)
Example #5
0
mg['node']['topographic__elevation'] = z + numpy.random.rand(len(z)) / 1000.
mg.add_zeros('node', 'water__unit_flux_in')

#make some K values in a field to test
#mg.at_node['K_values'] = 0.1+numpy.random.rand(nrows*ncols)/10.
mg.at_node['K_values'] = numpy.empty(nrows * ncols, dtype=float)
#mg.at_node['K_values'].fill(0.1+numpy.random.rand()/10.)
mg.at_node['K_values'].fill(0.001)

print('Running ...')

#instantiate the components:
fr = FlowRouter(mg)
sp = StreamPowerEroder(mg, input_file_string)
#fsp = FastscapeEroder(mg, input_file_string)
precip = PrecipitationDistribution(input_file=input_file_string)

#load the Fastscape module too, to allow direct comparison
fsp = FastscapeEroder(mg, input_file_string)

try:
    #raise NameError
    mg = copy.deepcopy(mg_mature)
except NameError:
    print('building a new grid...')
    out_interval = 50000.
    last_trunc = time_to_run  #we use this to trigger taking an output plot
    #run to a steady state:
    #We're going to cheat by running Fastscape SP for the first part of the solution
    for (interval_duration,
         rainfall_rate) in precip.yield_storm_interstorm_duration_intensity():
## Create Grid - !! later we can load a real ascii file
mg = RasterModelGrid((4, 5))

## Defiend param for the generator - i.e., rainfall scenario (Need to check the units)
mean_duration = 50
mean_inter_duration = 20
mean_depth = 0.5
total_time = 60 * 24 * 30  #60 min * 24 hours * 30 days
delta_t = 1
np.random.seed(np.arange(10))

# Initialize generator
precip = PrecipitationDistribution(
    mg,
    mean_storm_duration=mean_duration,
    mean_interstorm_duration=mean_inter_duration,
    mean_storm_depth=mean_depth,
    total_t=total_time,
    delta_t=delta_t)
n = random.randint(1, 101)  ## random number for stochastic results.
precip.seed_generator(seedval=n)

## Arrays for saving the outputs.
storm_dts = []
interstorm_dts = []
intensities = []
storm_dts = []

## Iterating over all of the storms.
for (storm_dt, interstorm_dt) in precip.yield_storms():
    storm_dts.append(np.array(storm_dt))
Example #7
0
mg['node'][ 'topographic__elevation'] = z + numpy.random.rand(len(z))/1000.
mg.add_zeros('node', 'water__unit_flux_in')

#make some K values in a field to test
#mg.at_node['K_values'] = 0.1+numpy.random.rand(nrows*ncols)/10.
mg.at_node['K_values'] = numpy.empty(nrows*ncols, dtype=float)
#mg.at_node['K_values'].fill(0.1+numpy.random.rand()/10.)
mg.at_node['K_values'].fill(0.001)

print( 'Running ...' )

#instantiate the components:
fr = FlowRouter(mg)
sp = StreamPowerEroder(mg, input_file_string)
#fsp = FastscapeEroder(mg, input_file_string)
precip = PrecipitationDistribution(input_file=input_file_string)

#load the Fastscape module too, to allow direct comparison
fsp = FastscapeEroder(mg, input_file_string)

try:
    #raise NameError
    mg = copy.deepcopy(mg_mature)
except NameError:
    print('building a new grid...')
    out_interval = 50000.
    last_trunc = time_to_run #we use this to trigger taking an output plot
    #run to a steady state:
    #We're going to cheat by running Fastscape SP for the first part of the solution
    for (interval_duration, rainfall_rate) in precip.yield_storm_interstorm_duration_intensity():
        if rainfall_rate != 0.:
Example #8
0
"""

import os
from matplotlib import pyplot as plt
from landlab.components.uniform_precip import PrecipitationDistribution
from landlab.components.fire_generator import FireGenerator
import numpy as np
from math import ceil

# Input text file name and location
filename = os.path.join(os.path.dirname(__file__), 'fireraininput.txt')

# Initializing the PrecipitationDistribution class using the default file
# and getting the time series needed for comparison against the fire time series.

Rain = PrecipitationDistribution(filename)
Rain.get_storm_time_series()
storm= Rain.storm_time_series

# Initializing the FireGenerator class using the default file and getting the
# time series needed for comparison against the precipitation time series.

# As an additional step, we should find the scale parameter and set it.
# The default value is set to 0.

Fire = FireGenerator(filename)
Fire.get_scale_parameter()
Fire.generate_fire_time_series()
fires = Fire.fire_events

## Methods used to find these potentially erosion-inducing events.
Example #9
0
"""

import os
from matplotlib import pyplot as plt
from landlab.components.uniform_precip import PrecipitationDistribution
from landlab.components.fire_generator import FireGenerator
import numpy as np
from math import ceil

# Input text file name and location
filename = os.path.join(os.path.dirname(__file__), 'fireraininput.txt')

# Initializing the PrecipitationDistribution class using the default file
# and getting the time series needed for comparison against the fire time series.

Rain = PrecipitationDistribution(filename)
Rain.get_storm_time_series()
storm = Rain.storm_time_series

# Initializing the FireGenerator class using the default file and getting the
# time series needed for comparison against the precipitation time series.

# As an additional step, we should find the scale parameter and set it.
# The default value is set to 0.

Fire = FireGenerator(filename)
Fire.get_scale_parameter()
Fire.generate_fire_time_series()
fires = Fire.fire_events

## Methods used to find these potentially erosion-inducing events.
#these are for the storm generator:
#create file called: landlab_parameters_storms.py
#and add:
'''
mean_storm_duration:
0.1
mean_storm_depth:
0.2
mean_interstorm_duration:
0.4
'''
#%% re-instantiate the FastscapeEroder, so we can 
input_file = './landlab_parameters1.txt'
inputs = load_params(input_file) # load the data into a dictionary
storm_inputs = load_params('./landlab_parameters_storms.txt')
precip = PrecipitationDistribution(total_t=total_t, delta_t=dt, **storm_inputs)
print(storm_inputs)
mg = RasterModelGrid((nrows, ncols), dx)
z = mg.add_zeros('node', 'topographic__elevation')
initial_roughness = np.random.rand(z.size)/100000.
z += initial_roughness
dt = 0.1
total_t = 250.
for edge in (mg.nodes_at_top_edge, mg.nodes_at_left_edge, mg.nodes_at_right_edge):
    mg.status_at_node[edge] = CLOSED_BOUNDARY
for edge in ( mg.nodes_at_bottom_edge):
    mg.status_at_node[edge] = FIXED_VALUE_BOUNDARY

fr = FlowRouter(mg, **inputs)
sp = FastscapeEroder(mg, **inputs)
lin_diffuse = LinearDiffuser(mg, **inputs)