def test_run_from_dap_without_cache(self): models = [self.transport] p = Point(self.start_lon, self.start_lat) model = CachingModelController(geometry=p, 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=False) particles = model.run("http://thredds.axiomalaska.com/thredds/dodsC/PWS_L2_FCST.nc", output_formats = ['NetCDF'], output_path=self.output_path) self.assertEquals(len(particles), self.num_particles) # We didn't pass remove_cache=False, so it should have been removed by the CachingModelController. self.assertFalse(os.path.exists(self.cache_path)) self.assertTrue(os.path.exists(os.path.join(self.output_path, "trajectories.nc")))
def test_timechunk_greater_than_timestep(self): models = [self.transport] model = CachingModelController(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=False, time_chunk=48, horiz_chunk=2) particles = model.run("/data/lm/tests/pws_das_2014*.nc", output_formats = ['NetCDF'], output_path=self.output_path, cache_path=self.cache_path, remove_cache=False) self.assertEquals(len(particles), self.num_particles) self.assertTrue(os.path.exists(self.cache_path)) os.remove(self.cache_path) self.assertTrue(os.path.exists(os.path.join(self.output_path, "trajectories.nc")))
def test_no_dap_data_for_requested_run(self): models = [self.transport] # Start is after available time model = CachingModelController(latitude=self.start_lat, longitude=self.start_lon, depth=self.start_depth, start=datetime.utcnow() + timedelta(days=30), step=self.time_step, nstep=self.num_steps, npart=self.num_particles, models=models, use_bathymetry=False, use_shoreline=False) with self.assertRaises(BaseDataControllerError): model.run("http://thredds.axiomalaska.com/thredds/dodsC/PWS_L2_FCST.nc", output_formats = ['NetCDF'], output_path=self.output_path, cache_path=self.cache_path, remove_cache=False) # Start is OK but Ending is after available time model = CachingModelController(latitude=self.start_lat, longitude=self.start_lon, depth=self.start_depth, start=datetime.utcnow() - timedelta(days=2), step=self.time_step, nstep=500, npart=self.num_particles, models=models, use_bathymetry=False, use_shoreline=False) with self.assertRaises(BaseDataControllerError): model.run("http://thredds.axiomalaska.com/thredds/dodsC/PWS_L2_FCST.nc", output_formats = ['NetCDF'], output_path=self.output_path, cache_path=self.cache_path, remove_cache=False)
def test_run_from_multiple_files_with_cache(self): models = [self.transport] p = Point(self.start_lon, self.start_lat) model = CachingModelController(geometry=p, 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, se_shoreline=False, time_chunk=10, horiz_chunk=4, bathy_path=self.bathy_file) particles = model.run("/data/lm/tests/pws_das_2014*.nc", output_formats = ['NetCDF'], output_path=self.output_path, cache_path=self.cache_path, remove_cache=False) self.assertEquals(len(particles), self.num_particles) self.assertTrue(os.path.exists(self.cache_path)) os.remove(self.cache_path) self.assertTrue(os.path.exists(os.path.join(self.output_path, "trajectories.nc")))