Esempio n. 1
0
def make_model(images_dir=os.path.join(base_dir, 'images')):
    print 'initializing the model'

    start_time = datetime(2004, 12, 31, 13, 0)
    model = Model(start_time=start_time, duration=timedelta(days=3),
                  time_step=30 * 60, uncertain=False)

    print 'adding the map'
    model.map = GnomeMap()

    # draw_ontop can be 'uncertain' or 'forecast'
    # 'forecast' LEs are in black, and 'uncertain' are in red
    # default is 'forecast' LEs draw on top
    renderer = Renderer(images_dir=images_dir,
                        #size=(800, 600),
                        output_timestep=timedelta(hours=1),
                        draw_ontop='uncertain')
    renderer.viewport = ((-76.5, 37.), (-75.8, 38.))

    print 'adding outputters'
    model.outputters += renderer

    netcdf_file = os.path.join(base_dir, 'script_plume.nc')
    scripting.remove_netcdf(netcdf_file)

    model.outputters += NetCDFOutput(netcdf_file, which_data='most',
                                     output_timestep=timedelta(hours=2))

    print 'adding two spills'
    # Break the spill into two spills, first with the larger droplets
    # and second with the smaller droplets.
    # Split the total spill volume (100 m^3) to have most
    # in the larger droplet spill.
    # Smaller droplets start at a lower depth than larger

    wd = WeibullDistribution(alpha=1.8, lambda_=.00456,
                             min_=.0002)  # 200 micron min
    end_time = start_time + timedelta(hours=24)
    spill = point_line_release_spill(num_elements=1000,
                                     volume=90,  # default volume_units=m^3
                                     start_position=(-76.126872, 37.680952,
                                                     1700),
                                     release_time=start_time,
                                     end_release_time=end_time,
                                     element_type=plume(distribution=wd))
    model.spills += spill

    wd = WeibullDistribution(alpha=1.8, lambda_=.00456,
                             max_=.0002)  # 200 micron max
    spill = point_line_release_spill(num_elements=1000, volume=10,
                                     start_position=(-76.126872, 37.680952,
                                                     1800),
                                     release_time=start_time,
                                     element_type=plume(distribution=wd))
    model.spills += spill

    print 'adding a RandomMover:'
    model.movers += RandomMover(diffusion_coef=50000)

    print 'adding a RiseVelocityMover:'
    model.movers += RiseVelocityMover()

    print 'adding a RandomVerticalMover:'
    model.movers += RandomVerticalMover(vertical_diffusion_coef_above_ml=5,
                                        vertical_diffusion_coef_below_ml=.11,
                                        mixed_layer_depth=10)

    # print 'adding a wind mover:'

    # series = np.zeros((2, ), dtype=gnome.basic_types.datetime_value_2d)
    # series[0] = (start_time, (30, 90))
    # series[1] = (start_time + timedelta(hours=23), (30, 90))

    # wind = Wind(timeseries=series, units='knot')
    #
    # default is .4 radians
    # w_mover = gnome.movers.WindMover(wind, uncertain_angle_scale=0)
    #
    # model.movers += w_mover

    print 'adding a simple mover:'
    s_mover = SimpleMover(velocity=(0.0, -.1, 0.0))
    model.movers += s_mover

    return model
Esempio n. 2
0
def make_model(images_dir=os.path.join(base_dir, 'images')):
    print 'initializing the model'

    start_time = datetime(2004, 12, 31, 13, 0)
    model = Model(start_time=start_time,
                  duration=timedelta(days=3),
                  time_step=30 * 60,
                  uncertain=False)

    print 'adding the map'
    model.map = GnomeMap()

    # draw_ontop can be 'uncertain' or 'forecast'
    # 'forecast' LEs are in black, and 'uncertain' are in red
    # default is 'forecast' LEs draw on top
    renderer = Renderer(
        output_dir=images_dir,
        # size=(800, 600),
        output_timestep=timedelta(hours=1),
        draw_ontop='uncertain')
    renderer.viewport = ((-76.5, 37.), (-75.8, 38.))

    print 'adding outputters'
    model.outputters += renderer

    netcdf_file = os.path.join(base_dir, 'script_plume.nc')
    scripting.remove_netcdf(netcdf_file)

    model.outputters += NetCDFOutput(netcdf_file,
                                     which_data='most',
                                     output_timestep=timedelta(hours=2))

    print 'adding two spills'
    # Break the spill into two spills, first with the larger droplets
    # and second with the smaller droplets.
    # Split the total spill volume (100 m^3) to have most
    # in the larger droplet spill.
    # Smaller droplets start at a lower depth than larger

    wd = WeibullDistribution(alpha=1.8, lambda_=.00456,
                             min_=.0002)  # 200 micron min
    end_time = start_time + timedelta(hours=24)
    # spill = point_line_release_spill(num_elements=10,
    #                                  amount=90,  # default volume_units=m^3
    #                                  units='m^3',
    #                                  start_position=(-76.126872, 37.680952,
    #                                                  1700),
    #                                  release_time=start_time,
    #                                  end_release_time=end_time,
    #                                  element_type=plume(distribution=wd,
    #                                                     density=600)
    #                                  )

    spill = subsurface_plume_spill(
        num_elements=10,
        start_position=(-76.126872, 37.680952, 1700),
        release_time=start_time,
        distribution=wd,
        amount=90,  # default volume_units=m^3
        units='m^3',
        end_release_time=end_time,
        density=600)

    model.spills += spill

    wd = WeibullDistribution(alpha=1.8, lambda_=.00456,
                             max_=.0002)  # 200 micron max
    spill = point_line_release_spill(
        num_elements=10,
        amount=90,
        units='m^3',
        start_position=(-76.126872, 37.680952, 1800),
        release_time=start_time,
        element_type=plume(distribution=wd, substance_name='oil_crude'))
    model.spills += spill

    print 'adding a RandomMover:'
    model.movers += RandomMover(diffusion_coef=50000)

    print 'adding a RiseVelocityMover:'
    model.movers += RiseVelocityMover()

    print 'adding a RandomVerticalMover:'
    model.movers += RandomVerticalMover(vertical_diffusion_coef_above_ml=5,
                                        vertical_diffusion_coef_below_ml=.11,
                                        mixed_layer_depth=10)

    # print 'adding a wind mover:'

    # series = np.zeros((2, ), dtype=gnome.basic_types.datetime_value_2d)
    # series[0] = (start_time, (30, 90))
    # series[1] = (start_time + timedelta(hours=23), (30, 90))

    # wind = Wind(timeseries=series, units='knot')
    #
    # default is .4 radians
    # w_mover = gnome.movers.WindMover(wind, uncertain_angle_scale=0)
    #
    # model.movers += w_mover

    print 'adding a simple mover:'
    s_mover = SimpleMover(velocity=(0.0, -.3, 0.0))
    model.movers += s_mover

    return model
Esempio n. 3
0
def make_model(images_dir=os.path.join(base_dir, 'images')):
    print 'initializing the model'

    start_time = datetime(2012, 10, 25, 0, 1)
    # start_time = datetime(2015, 12, 18, 06, 01)

    # 1 day of data in file
    # 1/2 hr in seconds
    model = Model(start_time=start_time,
                  duration=timedelta(hours=2),
                  time_step=900)

    mapfile = get_datafile(os.path.join(base_dir, 'nyharbor.bna'))

    print 'adding the map'
    '''TODO: sort out MapFromBna's map_bounds parameter...
    it does nothing right now, and the spill is out of bounds'''
    model.map = MapFromBNA(mapfile, refloat_halflife=0.0)  # seconds

    # draw_ontop can be 'uncertain' or 'forecast'
    # 'forecast' LEs are in black, and 'uncertain' are in red
    # default is 'forecast' LEs draw on top
    renderer = Renderer(mapfile, images_dir, image_size=(1024, 768))
#     renderer.viewport = ((-73.5, 40.5), (-73.1, 40.75))
#     renderer.viewport = ((-122.9, 45.6), (-122.6, 46.0))

    print 'adding outputters'
    model.outputters += renderer

    netcdf_file = os.path.join(base_dir, 'script_ny_plume.nc')
    scripting.remove_netcdf(netcdf_file)

    model.outputters += NetCDFOutput(netcdf_file, which_data='all')

    print 'adding two spills'
    # Break the spill into two spills, first with the larger droplets
    # and second with the smaller droplets.
    # Split the total spill volume (100 m^3) to have most
    # in the larger droplet spill.
    # Smaller droplets start at a lower depth than larger

    end_time = start_time + model.duration
#     wd = WeibullDistribution(alpha=1.8,
#                              lambda_=.00456,
#                              min_=.0002)  # 200 micron min
# 
#     spill = subsurface_plume_spill(num_elements=10,
#                                    start_position=(-74.15,
#                                                    40.5,
#                                                    7.2),
#                                    release_time=start_time,
#                                    distribution=wd,
#                                    amount=90,  # default volume_units=m^3
#                                    units='m^3',
#                                    end_release_time=end_time,
#                                    density=600)
# 
#     model.spills += spill

#     wd = WeibullDistribution(alpha=1.8,
#                              lambda_=.00456,
#                              max_=.0002)  # 200 micron max

    wd = UniformDistribution(low=.0002,
                             high=.0002)

    spill = point_line_release_spill(num_elements=10, amount=90,
                                     units='m^3',
                                     start_position=(-74.15,
                                                     40.5,
                                                     7.2),
                                     release_time=start_time,
                                     element_type=plume(distribution=wd,
                                                        substance_name='ALASKA NORTH SLOPE (MIDDLE PIPELINE)')
                                     )
    model.spills += spill

    print 'adding a RandomMover:'
    model.movers += RandomMover(diffusion_coef=50000)

    print 'adding a RiseVelocityMover:'
    model.movers += RiseVelocityMover()

    print 'adding a RandomVerticalMover:'
#     model.movers += RandomVerticalMover(vertical_diffusion_coef_above_ml=5,
#                                         vertical_diffusion_coef_below_ml=.11,
#                                         mixed_layer_depth=10)

    url = ('http://geoport.whoi.edu/thredds/dodsC/clay/usgs/users/jcwarner/Projects/Sandy/triple_nest/00_dir_NYB05.ncml')
    gc = GridCurrent.from_netCDF(url)
    u_mover = PyGridCurrentMover(gc, default_num_method='Trapezoid')
    model.movers += u_mover
    # print 'adding a wind mover:'

    # series = np.zeros((2, ), dtype=gnome.basic_types.datetime_value_2d)
    # series[0] = (start_time, (30, 90))
    # series[1] = (start_time + timedelta(hours=23), (30, 90))

    # wind = Wind(timeseries=series, units='knot')
    #
    # default is .4 radians
    # w_mover = gnome.movers.WindMover(wind, uncertain_angle_scale=0)
    #
    # model.movers += w_mover

    print 'adding a simple mover:'
#     s_mover = SimpleMover(velocity=(0.0, -.3, 0.0))
#     model.movers += s_mover

    return model
Esempio n. 4
0
def make_model(images_dir=os.path.join(base_dir, 'images')):
    print 'initializing the model'

    start_time = datetime(2012, 10, 25, 0, 1)
    # start_time = datetime(2015, 12, 18, 06, 01)

    # 1 day of data in file
    # 1/2 hr in seconds
    model = Model(start_time=start_time,
                  duration=timedelta(hours=2),
                  time_step=900)

    mapfile = get_datafile(os.path.join(base_dir, 'nyharbor.bna'))

    print 'adding the map'
    '''TODO: sort out MapFromBna's map_bounds parameter...
    it does nothing right now, and the spill is out of bounds'''
    model.map = MapFromBNA(mapfile, refloat_halflife=0.0)  # seconds

    # draw_ontop can be 'uncertain' or 'forecast'
    # 'forecast' LEs are in black, and 'uncertain' are in red
    # default is 'forecast' LEs draw on top
    renderer = Renderer(mapfile, images_dir, image_size=(1024, 768))
    #     renderer.viewport = ((-73.5, 40.5), (-73.1, 40.75))
    #     renderer.viewport = ((-122.9, 45.6), (-122.6, 46.0))

    print 'adding outputters'
    model.outputters += renderer

    netcdf_file = os.path.join(base_dir, 'script_ny_plume.nc')
    scripting.remove_netcdf(netcdf_file)

    model.outputters += NetCDFOutput(netcdf_file, which_data='all')

    print 'adding two spills'
    # Break the spill into two spills, first with the larger droplets
    # and second with the smaller droplets.
    # Split the total spill volume (100 m^3) to have most
    # in the larger droplet spill.
    # Smaller droplets start at a lower depth than larger

    end_time = start_time + model.duration
    #     wd = WeibullDistribution(alpha=1.8,
    #                              lambda_=.00456,
    #                              min_=.0002)  # 200 micron min
    #
    #     spill = subsurface_plume_spill(num_elements=10,
    #                                    start_position=(-74.15,
    #                                                    40.5,
    #                                                    7.2),
    #                                    release_time=start_time,
    #                                    distribution=wd,
    #                                    amount=90,  # default volume_units=m^3
    #                                    units='m^3',
    #                                    end_release_time=end_time,
    #                                    density=600)
    #
    #     model.spills += spill

    #     wd = WeibullDistribution(alpha=1.8,
    #                              lambda_=.00456,
    #                              max_=.0002)  # 200 micron max

    wd = UniformDistribution(low=.0002, high=.0002)

    spill = point_line_release_spill(
        num_elements=10,
        amount=90,
        units='m^3',
        start_position=(-74.15, 40.5, 7.2),
        release_time=start_time,
        element_type=plume(
            distribution=wd,
            substance_name='ALASKA NORTH SLOPE (MIDDLE PIPELINE, 1997)'))
    model.spills += spill

    print 'adding a RandomMover:'
    model.movers += RandomMover(diffusion_coef=50000)

    print 'adding a RiseVelocityMover:'
    model.movers += RiseVelocityMover()

    print 'adding a RandomVerticalMover:'
    #     model.movers += RandomVerticalMover(vertical_diffusion_coef_above_ml=5,
    #                                         vertical_diffusion_coef_below_ml=.11,
    #                                         mixed_layer_depth=10)

    url = (
        'http://geoport.whoi.edu/thredds/dodsC/clay/usgs/users/jcwarner/Projects/Sandy/triple_nest/00_dir_NYB05.ncml'
    )
    gc = GridCurrent.from_netCDF(url)
    u_mover = PyCurrentMover(gc, default_num_method='RK2')
    model.movers += u_mover
    # print 'adding a wind mover:'

    # series = np.zeros((2, ), dtype=gnome.basic_types.datetime_value_2d)
    # series[0] = (start_time, (30, 90))
    # series[1] = (start_time + timedelta(hours=23), (30, 90))

    # wind = Wind(timeseries=series, units='knot')
    #
    # default is .4 radians
    # w_mover = gnome.movers.WindMover(wind, uncertain_angle_scale=0)
    #
    # model.movers += w_mover

    print 'adding a simple mover:'
    #     s_mover = SimpleMover(velocity=(0.0, -.3, 0.0))
    #     model.movers += s_mover

    return model