コード例 #1
0
    def test_bad_dataset(self):
        models = [self.transport]

        model = BaseModelController(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)

        with raises(BaseDataControllerError):
            model.run("http://example.com/thisisnotadataset.nc")
コード例 #2
0
    def test_run_10m_shoreline(self):
        models = [self.transport]

        p = Point(self.start_lon, self.start_lat)

        model = BaseModelController(geometry=p,
                                    depth=self.start_depth,
                                    start=self.start_time,
                                    step=self.time_step,
                                    nstep=300,
                                    npart=2,
                                    models=models,
                                    use_bathymetry=False,
                                    use_shoreline=True,
                                    shoreline_index_buffer=0.05)

        particles = model.run("/data/lm/tests/pws_das_2014*.nc")
        self.assertEquals(len(particles), 2)
        # Not a caching controller, no cache path should exist
        self.assertFalse(os.path.exists(self.cache_path))
コード例 #3
0
    def test_start_on_land_from_point_no_depth(self):
        # Set the start position and time for the models
        start_lat = 60.15551950079041
        start_lon = -148.1999130249019

        p = Point(start_lon, start_lat)

        models = [self.transport]

        model = BaseModelController(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)

        with raises(ModelError):
            model.run("/data/lm/tests/pws_das_2014*.nc")
コード例 #4
0
    def test_run_from_point(self):
        models = [self.transport]

        p = Point(self.start_lon, self.start_lat)

        model = BaseModelController(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("/data/lm/tests/pws_das_2014*.nc", output_formats = ['NetCDF'], output_path=self.output_path)
        self.assertEquals(len(particles), self.num_particles)
        # Not a caching controller, no cache path should exist
        self.assertFalse(os.path.exists(self.cache_path))
        self.assertTrue(os.path.exists(os.path.join(self.output_path, "trajectories.nc")))
コード例 #5
0
    def test_no_local_data_for_requested_run(self):
        models = [self.transport]

        # Start is after available time
        model = BaseModelController(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("/data/lm/tests/pws_das_2014*.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 = BaseModelController(latitude=self.start_lat,
                                    longitude=self.start_lon,
                                    depth=self.start_depth,
                                    start=datetime(2014, 1, 1, 0),
                                    step=self.time_step,
                                    nstep=500,
                                    npart=self.num_particles,
                                    models=models,
                                    use_bathymetry=False,
                                    use_shoreline=False)

        with self.assertRaises(BaseDataControllerError):
            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)
コード例 #6
0
    def test_run_from_point_with_wfs_shoreline(self):
        models = [self.transport]

        p = Point(self.start_lon, self.start_lat)

        model = BaseModelController(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=True,
                                    shoreline_path='http://geo.asascience.com/geoserver/shorelines/ows',
                                    shoreline_feature='shorelines:10m_land_polygons')

        particles = model.run("/data/lm/tests/pws_das_2014*.nc", output_formats = ['NetCDF'], output_path=self.output_path)
        self.assertEquals(len(particles), self.num_particles)
        # Not a caching controller, no cache path should exist
        self.assertFalse(os.path.exists(self.cache_path))
        self.assertTrue(os.path.exists(os.path.join(self.output_path, "trajectories.nc")))