def run(self, hydrodatasets, **kwargs): _wind_path = kwargs.get("winddataset", None) num_particles = 1 models = [Transport(horizDisp=0., vertDisp=0.)] if self._wind_model != None: models.append(WindForcing()) for drifter in self.drifters: start_location4d = drifter.locations[0] start_time = start_location4d.time start_lat = start_location4d.latitude start_lon = start_location4d.longitude start_depth = start_location4d.depth time_step = self.time_step num_steps = self.num_steps model = ModelController(latitude=start_lat, longitude=start_lon, depth=start_depth, start=start_time, step=time_step, nstep=num_steps, npart=num_particles, models=models, use_bathymetry=False, use_shoreline=True, time_chunk=10, horiz_chunk=10) for hydromodel in hydrodatasets: model.run(hydromodel, wind=_wind_path) drifter.add_virtual_drifter(model.particles[0])
def test_run_from_polygon(self): self.log.logger.info("**************************************") self.log.logger.info("Running: test_run_from_polygon") models = [self.transport] poly = Point(self.start_lon, self.start_lat, self.start_depth).buffer(0.001) model = ModelController(geometry=poly, start=self.start_time, step=self.time_step, nstep=self.num_steps, npart=self.num_particles, models=models, use_bathymetry=False, use_shoreline=True, time_chunk=10, horiz_chunk=4) cache_path = os.path.join( os.path.dirname(__file__), "..", "paegan/transport/_cache/test_run_from_polygon.nc") model.run( "http://thredds.axiomalaska.com/thredds/dodsC/PWS_L2_FCST.nc", cache=cache_path)
def test_interp(self): self.log.logger.info("**************************************") self.log.logger.info("Running: test_interp") models = [self.transport] num_steps = 100 output_path = os.path.join(self.output_path, "test_interp") shutil.rmtree(output_path, ignore_errors=True) os.makedirs(output_path) output_formats = ['Shapefile', 'NetCDF', 'Trackline'] model = ModelController(latitude=self.start_lat, longitude=self.start_lon, depth=self.start_depth, start=self.start_time, step=self.time_step, nstep=num_steps, npart=self.num_particles, models=models, use_bathymetry=True, use_shoreline=True, time_chunk=10, horiz_chunk=4) cache_path = os.path.join(self.cache_path, "test_interp.nc") model.run( "http://thredds.axiomalaska.com/thredds/dodsC/PWS_L2_FCST.nc", bathy=self.bathy_file, cache=cache_path, output_path=output_path, output_formats=output_formats)
def test_timechunk_greater_than_timestep(self): self.log.logger.info("**************************************") self.log.logger.info("Running: test_timechunk_greater_than_timestep") # 6 days num_steps = 10 num_particles = 2 models = [self.transport] model = ModelController(latitude=self.start_lat, longitude=self.start_lon, depth=self.start_depth, start=self.start_time, step=self.time_step, nstep=num_steps, npart=num_particles, models=models, use_bathymetry=True, use_shoreline=True, time_chunk=24, horiz_chunk=2) cache_path = os.path.join(self.cache_path, "test_timechunk_greater_than_timestep.nc") model.run( "http://thredds.axiomalaska.com/thredds/dodsC/PWS_L2_FCST.nc", bathy=self.bathy_file, cache=cache_path)
def test_bad_dataset(self): self.log.logger.info("**************************************") self.log.logger.info("Running: test_bad_dataset") models = [self.transport] model = ModelController(latitude=self.start_lat, longitude=self.start_lon, depth=self.start_depth, start=self.start_time, step=self.time_step, nstep=self.num_steps, npart=self.num_particles, models=models, use_bathymetry=False, use_shoreline=True, time_chunk=10, horiz_chunk=4, time_method='nearest') cache_path = os.path.join(self.cache_path, "test_bad_dataset.nc") with raises(DataControllerError): model.run("http://asascience.com/thisisnotadataset.nc", cache=cache_path)
def test_start_on_land(self): self.log.logger.info("**************************************") self.log.logger.info("Running: test_start_on_land") # Set the start position and time for the models start_lat = 60.15551950079041 start_lon = -148.1999130249019 models = [self.transport] model = ModelController(latitude=start_lat, longitude=start_lon, depth=self.start_depth, start=self.start_time, step=self.time_step, nstep=self.num_steps, npart=self.num_particles, models=models, use_bathymetry=False, use_shoreline=True, time_chunk=10, horiz_chunk=4, time_method='nearest') cache_path = os.path.join(self.cache_path, "test_start_on_land.nc") with raises(ModelError): model.run( "http://thredds.axiomalaska.com/thredds/dodsC/PWS_L2_FCST.nc", cache=cache_path)
def test_diel_migration(self): self.log.logger.info("**************************************") self.log.logger.info("Running: test_diel_migration") num_steps = 168 num_particles = 4 start_time = datetime(2013, 4, 1, 0, tzinfo=pytz.utc) # Behavior behavior_config = open( os.path.normpath( os.path.join(os.path.dirname(__file__), "./resources/files/diel_suncycles.json"))).read() lb = LarvaBehavior(json=behavior_config) models = [self.transport] models.append(lb) model = ModelController(latitude=60.68, longitude=-146.42, depth=self.start_depth, start=start_time, step=self.time_step, nstep=num_steps, npart=num_particles, models=models, use_bathymetry=True, use_shoreline=True, time_chunk=24, horiz_chunk=2, time_method='nearest') output_path = os.path.join(self.output_path, "test_diel_migration") shutil.rmtree(output_path, ignore_errors=True) os.makedirs(output_path) output_formats = ['Shapefile', 'NetCDF', 'Trackline'] cache_path = os.path.join(self.cache_path, "test_diel_migration.nc") model.run("http://thredds.axiomalaska.com/thredds/dodsC/PWS_DAS.nc", bathy=self.bathy_file, cache=cache_path, output_path=output_path, output_formats=output_formats)
def test_run_from_point(self): self.log.logger.info("**************************************") self.log.logger.info("Running: test_run_from_point") models = [self.transport] p = Point(self.start_lon, self.start_lat, self.start_depth) model = ModelController(geometry=p, start=self.start_time, step=self.time_step, nstep=self.num_steps, npart=self.num_particles, models=models, use_bathymetry=False, use_shoreline=True, time_chunk=10, horiz_chunk=4) cache_path = os.path.join(self.cache_path, "test_run_from_point.nc") model.run( "http://thredds.axiomalaska.com/thredds/dodsC/PWS_L2_FCST.nc", cache=cache_path)