Skip to content

Commit

Permalink
Merge pull request #103 from schism-dev/feature/bctides
Browse files Browse the repository at this point in the history
removed unused variables
  • Loading branch information
cuill committed Oct 20, 2023
2 parents ef84e0a + e9857cd commit 99a041b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 223 deletions.
198 changes: 0 additions & 198 deletions pyschism/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:])

Expand Down Expand Up @@ -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
Expand Down
9 changes: 2 additions & 7 deletions pyschism/forcing/bctides/bctides.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ def write(
output_directory,
start_date: datetime = None,
rnday = None,
constituents = 'major',
overwrite: bool = True,
):
"""
Expand All @@ -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
"""

Expand All @@ -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:
Expand Down
18 changes: 0 additions & 18 deletions pyschism/forcing/bctides/bctypes.py

This file was deleted.

0 comments on commit 99a041b

Please sign in to comment.