Skip to content

Commit

Permalink
Update deterministic setup script and prep env
Browse files Browse the repository at this point in the history
  • Loading branch information
SorooshMani-NOAA committed Feb 6, 2024
1 parent 269f744 commit 5ffef49
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 20 deletions.
2 changes: 1 addition & 1 deletion singularity/info/files/hurricane_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def main(args):
gdf_track
))
df_dt['date_time'] = (
track.start_date, track.end_date, forecast_start
forecast_start - timedelta(days=2), track.end_date, forecast_start
)


Expand Down
54 changes: 35 additions & 19 deletions singularity/prep/files/setup_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
from pyschism import dates
from pyschism.enums import NWSType
from pyschism.driver import ModelConfig
from pyschism.forcing.bctides import iettype, ifltype
from pyschism.forcing.bctides.tides import Tides, TidalDatabase
from pyschism.forcing.bctides.tpxo import TPXO_ELEVATION
from pyschism.forcing.bctides.tpxo import TPXO_VELOCITY
from pyschism.forcing.nws import GFS, HRRR, ERA5, BestTrackForcing
from pyschism.forcing.nws.nws2 import hrrr3
from pyschism.forcing.source_sink import NWM
Expand Down Expand Up @@ -146,17 +148,19 @@ def copy_meteo_cache(sflux_dir, meteo_cache_path):


def setup_schism_model(
mesh_path,
domain_bbox_path,
date_range_path,
station_info_path,
out_dir,
main_cache_path,
parametric_wind=False,
nhc_track_file=None,
storm_id=None,
use_wwm=False,
):
mesh_path,
domain_bbox_path,
date_range_path,
station_info_path,
out_dir,
main_cache_path,
parametric_wind=False,
nhc_track_file=None,
storm_id=None,
use_wwm=False,
tpxo_dir=None,
):


domain_box = gpd.read_file(domain_bbox_path)
atm_bbox = Bbox(domain_box.to_crs('EPSG:4326').total_bounds.reshape(2, 2))
Expand All @@ -173,9 +177,12 @@ def setup_schism_model(
# measurement days +7 days of simulation: 3 ramp, 2 prior
# & 2 after the measurement dates
dt_data = pd.read_csv(date_range_path, delimiter=',')
date_1, date_2 = pd.to_datetime(dt_data.date_time).dt.strftime('%Y%m%d%H').values
date_1 = datetime.strptime(date_1, '%Y%m%d%H')
date_2 = datetime.strptime(date_2, '%Y%m%d%H')
date_1, date_2, date_3 = pd.to_datetime(dt_data.date_time).dt.strftime(
"%Y%m%d%H").values
date_1 = datetime.strptime(date_1, "%Y%m%d%H")
date_2 = datetime.strptime(date_2, "%Y%m%d%H")
# date_3 = datetime.strptime(date_3, "%Y%m%d%H")


# If there are no observation data, it's hindcast mode
hindcast_mode = (station_info_path).is_file()
Expand Down Expand Up @@ -239,15 +246,23 @@ def setup_schism_model(
# hrrr3.HRRR combination are supported by nws2 mechanism
pass

logger.info('Creating model configuration ...')

tidal_flags = [3, 3, 0, 0]
logger.info("Creating model configuration ...")
config = ModelConfig(
hgrid=hgrid,
fgrid=fgrid,
iettype=iettype.Iettype3(database='tpxo'),
ifltype=ifltype.Ifltype3(database='tpxo'),
flags=[tidal_flags for _ in hgrid.boundaries.open.itertuples()],
constituents=[], # we're overwriting Tides obj
database='tpxo', # we're overwriting Tides obj
nws=atmospheric,
source_sink=NWM(),
)
tide_db = TidalDatabase.TPXO.value(
h_file=tpxo_dir / TPXO_ELEVATION, u_file=tpxo_dir / TPXO_VELOCITY,
)
tides = Tides(tidal_database=tide_db, constituents='all')
config.bctides.tides = tides

if config.forcings.nws and getattr(config.forcings.nws, 'sflux_2', None):
config.forcings.nws.sflux_2.inventory.file_interval = timedelta(hours=6)
Expand Down Expand Up @@ -448,7 +463,8 @@ def main(args):
nhc_track_file=nhc_track,
storm_id=f'{storm_name}{storm_year}',
use_wwm=use_wwm,
)
tpxo_dir=tpxo_dir,
)


if __name__ == '__main__':
Expand Down
3 changes: 3 additions & 0 deletions singularity/prep/prep.def
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ From: continuumio/miniconda3:23.5.2-0-alpine
mamba install -y -n $ENV_NAME -cconda-forge \
--force-reinstall geopandas geopandas-base

pip uninstall pygeos # We use shapely 2
mamba install -y -cconda-forge --force-reinstall geopandas

git clone https://github.com/schism-dev/schism
cp -v schism/src/Utility/Pre-Processing/STOFS-3D-Atl-shadow-VIMS/Pre_processing/Source_sink/Relocate/relocate_source_feeder.py /scripts
cp -v schism/src/Utility/Pre-Processing/STOFS-3D-Atl-shadow-VIMS/Pre_processing/Source_sink/feeder_heads_bases_v2.1.xy /refs
Expand Down

0 comments on commit 5ffef49

Please sign in to comment.