def __get__(self, obj, val): tides = obj.__dict__.get('tides') if tides is None: if not obj.args.all_constituents \ and not obj.args.major_constituents \ and not obj.args.constituents: return else: tides = Tides(database=obj.args.tidal_database, velocity=obj.args.bnd_vel) if obj.args.all_constituents: tides.use_all() if obj.args.major_constituents: tides.use_major() if obj.args.constituents: for constituent in obj.args.constituents: tides.use_constituent(constituent) if obj.args.Z0 is not None: tides.add_Z0(obj.args.Z0) obj.__dict__['tides'] = tides return tides
if __name__ == '__main__': # open gr3 file logger.info('Reading hgrid file...') _tic = time() hgrid = Hgrid.open(PARENT / 'hgrid.gr3', crs='EPSG:4326') logger.info(f'Reading hgrind file took {time()-_tic}.') vgrid = Vgrid() fgrid = Fgrid.open(PARENT / 'drag.gr3', crs='EPSG:4326') # setup model domain domain = ModelDomain(hgrid, vgrid, fgrid) logger.info('Model domain setup finished') # set tidal boundary conditions elevbc = Tides() elevbc.use_all() # activate all forcing constituents logger.info('Tidal boundary setup finished') # connect the boundary condition to the domain domain.add_boundary_condition(elevbc) sflux_1 = GFS() # sflux_2 = HWRF() atmos = NWS2(sflux_1, # sflux_2 ) domain.set_atmospheric_forcing(atmos)
def setUp(self): self.tf = Tides() self.tf.start_date = datetime(2017, 9, 23) self.tf.end_date = datetime(2017, 9, 25) self.tf.spinup_time = timedelta(days=7) self.tf.use_constituent('M2')
class TidesTestCase(unittest.TestCase): def setUp(self): self.tf = Tides() self.tf.start_date = datetime(2017, 9, 23) self.tf.end_date = datetime(2017, 9, 25) self.tf.spinup_time = timedelta(days=7) self.tf.use_constituent('M2') def test_use_ll(self): self.tf.use_all() def test___call__(self): self.tf('M2') def test___iter__(self): for c, v in self.tf: pass def test___len__(self): len(self.tf) def test_use_major(self): self.tf.use_major() def test_drop_constituent(self): self.tf.drop_constituent('M2') def test_get_active_constituents(self): self.tf.get_active_constituents() def test_get_nodal_factor(self): for f in self.tf.orbital_frequencies: self.tf.get_nodal_factor(f) def test_get_greenwich_factor(self): for f in self.tf.orbital_frequencies: self.tf.get_greenwich_factor(f) def test_get_nodal_factor_raise(self): self.assertRaises(TypeError, self.tf.get_nodal_factor, '') def test_get_greenwich_factor_raise(self): self.assertRaises(TypeError, self.tf.get_greenwich_factor, '') def test_reset_dates(self): new_date = self.tf.start_date del (self.tf.start_date) self.tf.end_date = new_date def test_use_all(self): self.tf.use_all() def test_deafault_spiunp_time(self): del (self.tf.spinup_time) self.tf.spinup_time
def tidal_forcing(self): tidal_forcing = Tides() for constituent in self.constituents: tidal_forcing.use_constituent(constituent) return tidal_forcing
def test_set_tides_boundary_forcing_by_id(self): h = Mesh.open(self.hgrid) from pyschism.forcing import Tides h.hgrid.generate_boundaries() h.set_boundary_forcing(Tides(), 0)