def make_model(images_dir=os.path.join(base_dir, 'images')): print 'initializing the model' start_time = datetime(2015, 9, 24, 1, 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=47), time_step=300) mapfile = get_datafile(os.path.join(base_dir, 'columbia_river.bna')) print 'adding the map' 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=(600, 1200)) renderer.delay = 15 # renderer.viewport = ((-123.35, 45.6), (-122.68, 46.13)) # renderer.viewport = ((-122.9, 45.6), (-122.6, 46.0)) print 'adding outputters' model.outputters += renderer print 'adding a spill' # for now subsurface spill stays on initial layer # - will need diffusion and rise velocity # - wind doesn't act # - start_position = (-76.126872, 37.680952, 5.0), spill1 = continuous_release_spill(initial_elements=10000, num_elements=400, start_position=(-122.625, 45.609, 0.0), release_time=start_time, end_position=(-122.6, 45.605, 0.0), end_release_time=start_time + timedelta(seconds=36000)) model.spills += spill1 print 'adding a RandomMover:' # model.movers += RandomMover(diffusion_coef=10000) print 'adding a wind mover:' series = [] for i in [(1, (5, 90)), (7, (5, 180)), (13, (5, 270)), (19, (5, 0)), (25, (5, 90))]: series.append((start_time + timedelta(hours=i[0]), i[1])) wind1 = WindTS.constant_wind('wind1', 0.5, 0, 'm/s') wind2 = WindTS(timeseries=series, units='knots', extrapolate=True) # wind = Wind(timeseries=series, units='knots') model.movers += PyWindMover(wind=wind1) print 'adding a current mover:' # url = ('http://geoport.whoi.edu/thredds/dodsC/clay/usgs/users/jcwarner/Projects/Sandy/triple_nest/00_dir_NYB05.ncml') # test = GridCurrent.from_netCDF(name='gc1', filename=url) curr_file = get_datafile('COOPSu_CREOFS24.nc') curr = GridCurrent.from_netCDF( name='gc2', filename=curr_file, ) c_mover = PyGridCurrentMover(curr, extrapolate=True, default_num_method='Trapezoid') # renderer.add_grid(curr.grid) # renderer.add_vec_prop(curr) model.movers += c_mover print 'adding a random mover' model.movers += RandomMover(diffusion_coef=1000) # curr_file = get_datafile(os.path.join(base_dir, 'COOPSu_CREOFS24.nc')) # c_mover = GridCurrentMover(curr_file) # model.movers += c_mover return model
def make_model(images_dir=os.path.join(base_dir, 'images')): print 'initializing the model' start_time = datetime(2015, 9, 24, 1, 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=47), time_step=300) mapfile = get_datafile(os.path.join(base_dir, 'columbia_river.bna')) print 'adding the map' 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=(600, 1200)) renderer.delay=15 # renderer.viewport = ((-123.35, 45.6), (-122.68, 46.13)) # renderer.viewport = ((-122.9, 45.6), (-122.6, 46.0)) print 'adding outputters' model.outputters += renderer print 'adding a spill' # for now subsurface spill stays on initial layer # - will need diffusion and rise velocity # - wind doesn't act # - start_position = (-76.126872, 37.680952, 5.0), spill1 = continuous_release_spill(initial_elements=10000, num_elements=400, start_position=(-122.625, 45.609, 0.0), release_time=start_time, end_position=(-122.6, 45.605, 0.0), end_release_time=start_time + timedelta(seconds=36000)) model.spills += spill1 print 'adding a RandomMover:' # model.movers += RandomMover(diffusion_coef=10000) print 'adding a wind mover:' series = [] for i in [(1, (5, 90)), (7, (5, 180)), (13, (5, 270)), (19, (5, 0)), (25, (5, 90))]: series.append((start_time + timedelta(hours=i[0]), i[1])) wind1 = WindTS.constant_wind('wind1', 0.5, 0, 'm/s') wind2 = WindTS(timeseries = series, units='knots', extrapolate=True) # wind = Wind(timeseries=series, units='knots') model.movers += PyWindMover(wind=wind1) print 'adding a current mover:' # url = ('http://geoport.whoi.edu/thredds/dodsC/clay/usgs/users/jcwarner/Projects/Sandy/triple_nest/00_dir_NYB05.ncml') # test = GridCurrent.from_netCDF(name='gc1', filename=url) curr_file = get_datafile('COOPSu_CREOFS24.nc') curr = GridCurrent.from_netCDF(name='gc2', filename=curr_file,) c_mover = PyGridCurrentMover(curr, extrapolate = True, default_num_method='Trapezoid') # renderer.add_grid(curr.grid) # renderer.add_vec_prop(curr) model.movers += c_mover print 'adding a random mover' model.movers += RandomMover(diffusion_coef=1000) # curr_file = get_datafile(os.path.join(base_dir, 'COOPSu_CREOFS24.nc')) # c_mover = GridCurrentMover(curr_file) # model.movers += c_mover return model
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=24), 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 print 'adding a spill' # for now subsurface spill stays on initial layer # - will need diffusion and rise velocity # - wind doesn't act # - start_position = (-76.126872, 37.680952, 5.0), spill1 = point_line_release_spill(num_elements=1000, start_position=(-74.15, 40.5, 0.0), release_time=start_time) model.spills += spill1 print 'adding a RandomMover:' # model.movers += RandomMover(diffusion_coef=50000) print 'adding a wind mover:' series = [] for i in [(1, (5, 90)), (7, (5, 180)), (13, (5, 270)), (19, (5, 0)), (25, (5, 90))]: series.append((start_time + timedelta(hours=i[0]), i[1])) wind1 = WindTS.constant_wind('wind1', 5, 270, 'knots') wind2 = WindTS(timeseries=series, units='knots', extrapolate=True) wind = Wind(timeseries=series, units='knots') model.movers += PyWindMover(wind=wind2) # model.movers += WindMover(wind) # print 'adding a current mover:' # # url = ('http://geoport.whoi.edu/thredds/dodsC/clay/usgs/users/jcwarner/Projects/Sandy/triple_nest/00_dir_NYB05.ncml') # # cf = roms_field('nos.tbofs.fields.n000.20160406.t00z_sgrid.nc') # cf = roms_field(url) # cf.set_appearance(on=True) # renderer.grids += [cf] # renderer.delay = 25 # u_mover = UGridCurrentMover(cf) # model.movers += u_mover # curr_file = get_datafile(os.path.join(base_dir, 'COOPSu_CREOFS24.nc')) # c_mover = GridCurrentMover(curr_file) # model.movers += c_mover return model
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=24), 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 print 'adding a spill' # for now subsurface spill stays on initial layer # - will need diffusion and rise velocity # - wind doesn't act # - start_position = (-76.126872, 37.680952, 5.0), spill1 = point_line_release_spill(num_elements=1000, start_position=(-74.15, 40.5, 0.0), release_time=start_time) model.spills += spill1 print 'adding a RandomMover:' # model.movers += RandomMover(diffusion_coef=50000) print 'adding a wind mover:' series = [] for i in [(1, (5, 90)), (7, (5, 180)), (13, (5, 270)), (19, (5, 0)), (25, (5, 90))]: series.append((start_time + timedelta(hours=i[0]), i[1])) wind1 = WindTS.constant_wind('wind1', 5, 270, 'knots') wind2 = WindTS(timeseries = series, units='knots', extrapolate=True) wind = Wind(timeseries=series, units='knots') model.movers += PyWindMover(wind=wind2) # model.movers += WindMover(wind) # print 'adding a current mover:' # # url = ('http://geoport.whoi.edu/thredds/dodsC/clay/usgs/users/jcwarner/Projects/Sandy/triple_nest/00_dir_NYB05.ncml') # # cf = roms_field('nos.tbofs.fields.n000.20160406.t00z_sgrid.nc') # cf = roms_field(url) # cf.set_appearance(on=True) # renderer.grids += [cf] # renderer.delay = 25 # u_mover = UGridCurrentMover(cf) # model.movers += u_mover # curr_file = get_datafile(os.path.join(base_dir, 'COOPSu_CREOFS24.nc')) # c_mover = GridCurrentMover(curr_file) # model.movers += c_mover return model