def check_seeding(self): print('#' * 50) print('Hang on, plot is comming in a few seconds...') print('#' * 50) month = np.int(self.months.index(self.monthvar.get()) + 1) start_time = datetime(np.int(self.yearvar.get()), month, np.int(self.datevar.get()), np.int(self.hourvar.get()), np.int(self.minutevar.get())) emonth = np.int(self.months.index(self.emonthvar.get()) + 1) end_time = datetime(np.int(self.eyearvar.get()), emonth, np.int(self.edatevar.get()), np.int(self.ehourvar.get()), np.int(self.eminutevar.get())) sys.stdout.flush() lon = np.float(self.lon.get()) lat = np.float(self.lat.get()) radius = np.float(self.radius.get()) elon = np.float(self.elon.get()) elat = np.float(self.elat.get()) eradius = np.float(self.eradius.get()) if lon != elon or lat != elat or start_time != end_time: lon = [lon, elon] lat = [lat, elat] radius = [radius, eradius] start_time = [start_time, end_time] cone = True else: cone = False so = Leeway(loglevel=50) for k, v in self.GUI_config.items(): try: so.set_config(k, v) except: pass so.seed_cone(lon=lon, lat=lat, radius=radius, time=start_time) so.plot(buffer=.5, fast=True) del so
def test_leewayrun(tmpdir, test_data): """Test the expected Leeway left/right split.""" lee = Leeway(loglevel=20) object_type = 50 # FISHING-VESSEL-1 reader_landmask = reader_global_landmask.Reader(extent=[ 3, 59.8, 6, 60.5 ]) lee.add_reader([reader_landmask]) lee.seed_cone(lon=[4.5, 4.7], lat=[60.1, 60], number=100, object_type=object_type, time=[datetime(2015, 1, 1, 0), datetime(2015, 1, 1, 6)]) lee.set_config('environment:fallback:x_wind', 0) lee.set_config('environment:fallback:y_wind', 10) lee.set_config('environment:fallback:x_sea_water_velocity', 0) lee.set_config('environment:fallback:y_sea_water_velocity', 0) # Check that 10 out of 100 elements strand towards coast lee.run(steps=24, time_step=3600) assert lee.num_elements_scheduled() == 0 assert lee.num_elements_active() == 88 assert lee.num_elements_deactivated() == 12 # stranded asciif = tmpdir + '/leeway_ascii.txt' lee.export_ascii(asciif) asciitarget = test_data + "/generated/test_leewayrun_export_ascii.txt" import filecmp assert filecmp.cmp(asciif, asciitarget)