From e9857cdbf485b00bee7af2626d9a9942b74d5b71 Mon Sep 17 00:00:00 2001 From: cuill Date: Fri, 20 Oct 2023 14:54:00 -0400 Subject: [PATCH] removed unused variables --- pyschism/driver.py | 198 ---------------------------- pyschism/forcing/bctides/bctides.py | 9 +- pyschism/forcing/bctides/bctypes.py | 18 --- 3 files changed, 2 insertions(+), 223 deletions(-) delete mode 100644 pyschism/forcing/bctides/bctypes.py diff --git a/pyschism/driver.py b/pyschism/driver.py index fa16612a..88751011 100644 --- a/pyschism/driver.py +++ b/pyschism/driver.py @@ -85,140 +85,6 @@ def write( if self.waves is not None: self.waves.write() - # self.fetch_data(driver) - - # if bctides is not False and self.bctides is not None: - # # TODO: We need a smarter way to generate bctides.in - # bctides = "bctides.in" if bctides is True else bctides - # self.bctides.write(bctides, overwrite) - - # if nws is not False and self.config.forcings.atmosphere is not None: - # if isinstance(self.config.forcings.atmosphere, NWS2): - # self.config.forcings.atmosphere.write( - # self.outdir / "sflux", overwrite, windrot=self.config.windrot - # ) - # else: - # self.nws.write(self.outdir, overwrite) - - # if hydrology is not False and self.config.forcings.hydrology is not None: - # for hydrology in self.config.forcings.hydrology: - # hydrology.write(self.outdir, overwrite) - - # def fetch_data(self, driver: 'ModelDriver'): - # if not isinstance(driver, ModelDriver): - # raise_type_error('driver', driver, ModelDriver) - - # # if self.tides is not None: - # # self.tides.fetch_data(hgrid, start_date, rnday) - - # if self.atmosphere is not None: - # self.atmosphere.fetch_data( - # start_date=driver.param.opt.start_date, - # rnday=driver.param.core.rnday, - # bbox=driver.config.hgrid.get_bbox( - # 'EPSG:4326', output_type='bbox'), - # prc=False if driver.config.vgrid.is2D() else True, - # rad=False if driver.config.vgrid.is2D() else True, - # ) - - # if self.hydrology is not None: - # for forcing in self.hydrology: - # forcing.fetch_data( - # driver.config.hgrid, - # driver.param.opt.start_date, - # driver.param.core.rnday - # ) - - # if self.baroclinic is not None: - # if driver.param.opt.ihot == 1: - # self.baroclinic.fetch_data( - # driver.config.hgrid, - # driver.param.opt.start_date, - # driver.param.core.rnday - # ) - - # if self.waves is not None: - # self.waves.fetch_data( - # driver.config.hgrid, - # driver.param.opt.start_date, - # driver.param.core.rnday - # ) - - # def max_end_date(self): - # end_date = dates.nearest_cycle() - # if self.atmosphere is not None: - # end_date = np.max([end_date, np.max(self.atmosphere.timevector)]) - # if self.hydrology is not None: - # for forcing in self.hydrology: - # end_date = np.max([end_date, np.max(forcing.timevector)]) - # if self.baroclinic is not None: - # end_date = np.max([end_date, np.max(self.baroclinic.timevector)]) - # if self.waves is not None: - # end_date = np.max([end_date, np.max(self.waves.timevector)]) - - # if end_date == dates.nearest_cycle(): - # return None - # return end_date - - # @property - # def tides(self): - # return self._tides - - # @tides.setter - # def tides(self, tides: Union[Tides, None]): - # if tides is not None: - # if not isinstance(tides, Tides): - # raise_type_error('tides', tides, Tides) - # self._tides = tides - - # @property - # def atmosphere(self): - # return self._atmosphere - - # @atmosphere.setter - # def atmosphere(self, atmosphere: Union[NWS, None]): - # if atmosphere is not None: - # if not isinstance(atmosphere, NWS): - # raise_type_error('atmosphere', atmosphere, NWS) - # self._atmosphere = atmosphere - - # @property - # def hydrology(self): - # return self._hydrology - - # @hydrology.setter - # def hydrology(self, hydrology: Union[Hydrology, List[Hydrology], None]): - # if hydrology is not None: - # if not isinstance(hydrology, Iterable): - # hydrology = [hydrology] - # for forcing in hydrology: - # if not isinstance(forcing, Hydrology): - # raise_type_error('hydrology', forcing, Hydrology) - # self._hydrology = hydrology - - # @property - # def baroclinic(self): - # return self._baroclinic - - # @baroclinic.setter - # def baroclinic(self, baroclinic: Union[BaroclinicForcing, None]): - # if baroclinic is not None: - # if not isinstance(baroclinic, BaroclinicForcing): - # raise_type_error('baroclinic', baroclinic, BaroclinicForcing) - # self._baroclinic = baroclinic - - # @property - # def waves(self): - # return self._waves - - # @waves.setter - # def waves(self, waves: None): - # if waves is not None: - # raise NotImplementedError( - # 'waves forcing not yet implemented.') - # self._waves = waves - - class Gr3FieldTypes(Enum): ALBEDO = gridgr3.Albedo DIFFMIN = gridgr3.Diffmin @@ -320,32 +186,6 @@ def __init__( self.temp_ic = temp_ic # flag_ic(2) = 1 !S self.salt_ic = salt_ic - # ! initial conditions for other tracers. - # ! 1: needs inputs [MOD]_hvar_[1,2,...].ic ('1...' is tracer id); format of each file is similar to salt.ic; - # ! i.e. horizontally varying i.c. is used for each tracer. - # ! 2: needs [MOD]_vvar_[1,2,...].ic. Format of each file (for each tracer in tis MOD) is similar to ts.ic - # ! (i.e. level #, z-coord., tracer value). Verically varying i.c. is used for each tracer. - # ! 0: model sets own i.c. (EcoSim; TIMOR) - # flag_ic(3) = 1 !GEN (user defined module) - # flag_ic(4) = 1 !Age i.c. flag set inside code - # flag_ic(5) = 1 !SED3D - # flag_ic(6) = 1 !EcoSim - # flag_ic(7) = 1 !ICM - # flag_ic(8) = 1 !CoSINE - # flag_ic(9) = 1 !FIB - # flag_ic(10) = 1 !TIMOR - # flag_ic(11) = 1 !FABM - # flag_ic(12) = 0 # !DVD (must=0) - - # # temp_ic - # self.param.opt.flag_ic[0] = ( - # 1 if temp_ic is not None and self.hotstart is None else 0 - # ) - - # # salt_ic - # self.param.opt.flag_ic[1] = ( - # 1 if salt_ic is not None and self.hotstart is None else 0 - # ) # TODO: init tracers (flag_ic[2:]) @@ -549,44 +389,6 @@ def obj_write(var, obj, default_filename, overwrite): self.outdir / "Makefile", overwrite ) - # if shapiro is not False and self.config.shapiro is not None: - # self.config.shapiro.from_binary(self.outdir, self.config.hgrid, 'epsg:26918') - - # if fluxflag is not False and self.config.fluxflag is not None: - # self.fluxflag = Fluxflag.constant(self.model_domain.hgrid, -1) - # with open(self.outdir / 'fluxflag.prop', 'w+') as fid: - # fid.writelines(self.config.fluxflag) - # fluxflag = 'fluxflag.prop' if fluxflag is True else fluxflag - # self.config.fluxflag.write(self.outdir / fluxflag, overwrite) - - # if tvdflag is not False and self.config.tvdflag is not None: - # # Hard-wire the polygon at this point. - # # coords = [(-75.340506, 40.843483), (-75.533474, 40.436019), (-75.796036, 39.535807), - # # (-75.672664, 39.339972), (-75.305709, - # # 39.460000), (-75.103251, 39.636884), - # # (-74.692008, 39.744277), (-74.391485, - # # 40.009603), (-74.359851, 40.252818), - # # (-74.514858, 40.745565), (-74.834362, - # # 40.957194), (-75.210807, 40.935083), - # # (-75.283565, 40.925607)] - # # poly = Polygon(coords) - # # self.tvdflag = Tvdflag.define_by_region( - # # hgrid=self.model_domain.hgrid, region=poly, value=1) - # with open(self.outdir / 'tvd.prop', 'w+') as fid: - # fid.writelines(self.config.tvdflag) - # #fluxflag = 'tvd.prop' if fluxflag is True else fluxflag - # #self.config.tvdflag.write(self.outdir / 'tvd.prop') - - # if rtofs is not False: - # self.start_date = nearest_cycle_date() - # self.hotstart = HotStartInventory() - # self.hotstart.fetch_data( - # outdir, self.model_domain.hgrid, self.start_date) - # self.obnd = OpenBoundaryInventory() - # self.obnd.fetch_data(outdir, self.start_date, rnday=3, bbox=self.config.hgrid.get_bbox()) - - # update forcings - @property def outdir(self): return self._outdir diff --git a/pyschism/forcing/bctides/bctides.py b/pyschism/forcing/bctides/bctides.py index 9d8e6075..97fa403e 100644 --- a/pyschism/forcing/bctides/bctides.py +++ b/pyschism/forcing/bctides/bctides.py @@ -233,7 +233,6 @@ def write( output_directory, start_date: datetime = None, rnday = None, - constituents = 'major', overwrite: bool = True, ): """ @@ -242,7 +241,6 @@ def write( output_directory: str start_date: datetime.datetime rnday: int, float or datetime.timedelta - constituents: str or list overwrite: bool """ @@ -256,14 +254,11 @@ def write( else: raise IOError("Please specify the number of days!") - if constituents is not None: - self.constituents = constituents - else: - raise IOError("Please specify tidal constituents!") - output_directory = pathlib.Path(output_directory) output_directory.mkdir(exist_ok=overwrite, parents=True) + bctides = output_directory / "bctides.in" + if bctides.exists() and not overwrite: raise IOError("path exists and overwrite is False") with open(bctides, "w") as f: diff --git a/pyschism/forcing/bctides/bctypes.py b/pyschism/forcing/bctides/bctypes.py deleted file mode 100644 index c9ecc601..00000000 --- a/pyschism/forcing/bctides/bctypes.py +++ /dev/null @@ -1,18 +0,0 @@ -from abc import abstractmethod, abstractproperty - -from pyschism.forcing.base import ModelForcing - - -class BoundaryForcing(ModelForcing): - - @abstractmethod - def get_boundary_string(self, boundary) -> str: - pass - - @abstractproperty - def forcing_digit(self): - """ bctype int value """ - raise NotImplementedError - - -Bctype = BoundaryForcing