-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compound flooding scripts: updated some regions in Bathy_loading/ and…
… other minor changes.
- Loading branch information
1 parent
dc72ff2
commit d9d0599
Showing
9 changed files
with
223 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,8 @@ site/ | |
|
||
src/Core/_version | ||
.DS_Store | ||
|
||
# Files related to Python scripts # | ||
############# | ||
*.egg* | ||
__pycache__ |
12 changes: 12 additions & 0 deletions
12
...ocessing/STOFS-3D-Atl-shadow-VIMS/Pre_processing/Bathy_loading/regions/minas_inlet_2m.reg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Region written by ACE/gredit | ||
1 | ||
9 1 | ||
-64.443032 45.318950 | ||
-64.511029 45.314985 | ||
-64.534135 45.351003 | ||
-64.493865 45.397595 | ||
-64.391538 45.398586 | ||
-64.310337 45.390986 | ||
-64.295483 45.355959 | ||
-64.335424 45.299124 | ||
-64.401771 45.298463 |
48 changes: 48 additions & 0 deletions
48
...Processing/STOFS-3D-Atl-shadow-VIMS/Pre_processing/Bathy_loading/regions/st_lawrence1.reg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
Region written by ACE/gredit | ||
1 | ||
45 1 | ||
-60.483012 45.719008 | ||
-60.114531 45.733735 | ||
-60.026095 45.969367 | ||
-60.085052 46.293361 | ||
-60.114531 46.661536 | ||
-60.247184 46.926622 | ||
-60.615666 47.073892 | ||
-61.205236 46.676263 | ||
-61.647414 46.146091 | ||
-61.942199 45.998821 | ||
-62.236985 45.925186 | ||
-62.384377 45.895732 | ||
-62.679163 45.881005 | ||
-63.136080 45.910459 | ||
-63.460344 45.998821 | ||
-63.740390 46.190272 | ||
-63.932000 46.278634 | ||
-64.226785 46.322815 | ||
-64.388917 46.455358 | ||
-64.668963 46.852987 | ||
-64.683702 47.176981 | ||
-64.551049 47.648245 | ||
-64.374178 47.824969 | ||
-64.256264 48.252052 | ||
-64.020436 48.399322 | ||
-64.035175 48.841132 | ||
-64.271003 49.076764 | ||
-64.713181 49.297669 | ||
-65.759669 49.371304 | ||
-66.599807 49.282942 | ||
-67.145159 49.194580 | ||
-67.425205 49.165126 | ||
-68.058994 49.474393 | ||
-68.810696 49.312396 | ||
-70.151969 48.576046 | ||
-71.493242 47.338978 | ||
-71.124760 46.484812 | ||
-69.179178 46.543720 | ||
-67.572598 46.617355 | ||
-65.450144 46.087183 | ||
-64.565788 45.984094 | ||
-63.607736 45.586465 | ||
-62.384377 45.424468 | ||
-61.603196 45.468649 | ||
-60.939930 45.748462 |
27 changes: 27 additions & 0 deletions
27
...Processing/STOFS-3D-Atl-shadow-VIMS/Pre_processing/Bathy_loading/regions/st_lawrence2.reg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Region written by ACE/gredit | ||
1 | ||
24 1 | ||
-68.176908 49.459666 | ||
-68.073733 49.047310 | ||
-67.646294 49.076764 | ||
-67.233595 49.253488 | ||
-66.865113 49.651117 | ||
-66.319761 49.975111 | ||
-65.229055 50.092927 | ||
-63.740390 50.137108 | ||
-62.752859 49.960384 | ||
-61.470543 49.842568 | ||
-60.556709 49.872022 | ||
-59.392307 50.196016 | ||
-58.168948 50.726188 | ||
-56.945589 51.256361 | ||
-56.356019 51.609809 | ||
-55.589577 51.830714 | ||
-55.368488 52.125254 | ||
-56.061234 52.360886 | ||
-57.903641 51.771806 | ||
-60.541969 50.961821 | ||
-63.239255 50.785096 | ||
-65.951279 50.755642 | ||
-67.631555 50.092927 | ||
-67.970558 49.665844 |
27 changes: 27 additions & 0 deletions
27
...Processing/STOFS-3D-Atl-shadow-VIMS/Pre_processing/Bathy_loading/regions/st_lawrence3.reg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Region written by ACE/gredit | ||
1 | ||
24 1 | ||
-55.397967 51.948530 | ||
-55.854884 51.786533 | ||
-56.341280 51.595082 | ||
-56.842414 51.315269 | ||
-57.476203 50.932366 | ||
-58.404776 49.754206 | ||
-59.392307 48.826405 | ||
-59.657614 48.325687 | ||
-59.598657 47.633518 | ||
-59.171218 47.338978 | ||
-58.198427 47.324251 | ||
-57.446724 47.250616 | ||
-56.827675 47.103346 | ||
-56.429715 46.823533 | ||
-55.958059 46.632082 | ||
-55.545359 46.440631 | ||
-54.867353 46.352269 | ||
-53.997737 46.293361 | ||
-53.319731 46.337542 | ||
-52.848074 46.646809 | ||
-52.892292 47.103346 | ||
-53.452384 47.957512 | ||
-54.454654 50.402194 | ||
-55.132660 51.698171 |
83 changes: 83 additions & 0 deletions
83
...ity/Pre-Processing/STOFS-3D-Atl-shadow-VIMS/Pre_processing/Gr3/Nudge_gr3/gen_nudge_gr3.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
from pylib_essentials.schism_file import schism_grid | ||
|
||
def gen_nudge(hgrid:schism_grid, outdir, rlmax = 1.5, rnu_day=0.25): | ||
""" | ||
schism_grid (from pylib) must be in lon/lat coordinates | ||
set up nudge zone within rlmax distance from the ocean boundary; | ||
modify the nudging zone width rlmax. | ||
rlmax can be a uniform value, e.g., rl_max = 1.5, | ||
or a 2D array of the same size as the hgrid's number of nodes, | ||
e.g., rl_max = np.zeros(NP) with further tuning of the nudging zone width. | ||
""" | ||
|
||
rnu_max = 1.0 / rnu_day / 86400.0 | ||
|
||
#get nudge zone | ||
lon = hgrid.x | ||
lat = hgrid.y | ||
nudge_coeff = np.zeros(hgrid.x.shape, dtype=float) | ||
|
||
global_idxs = {} | ||
|
||
t0 = time() | ||
|
||
nudge_coeff = np.array([0.0]*NP, dtype=float) | ||
|
||
for i in self.ocean_bnd_ids: | ||
print(f'boundary {i}') | ||
bnd_idxs = gdf.iloc[i].indexes | ||
|
||
dis = abs((lon + 1j*lat)[:, None] - (lon[bnd_idxs] + 1j*lat[bnd_idxs])[None, :]).min(axis=1) | ||
|
||
out = (1-dis/rlmax)*rnu_max | ||
out[out<0] = 0 | ||
out[out>rnu_max] = rnu_max | ||
fp = out>0 | ||
nudge_coeff[fp] = np.maximum(out[fp], nudge_coeff[fp]) | ||
|
||
idxs_nudge=np.zeros(NP, dtype=int) | ||
idxs=np.where(out > 0)[0] | ||
idxs_nudge[idxs]=1 | ||
|
||
#expand nudging marker to neighbor nodes | ||
i34 = self.hgrid.elements.i34 | ||
fp = i34==3 | ||
idxs=np.where(np.max(out[elnode[fp, 0:3]], axis=1) > 0)[0] | ||
idxs_nudge[elnode[fp,0:3][idxs,:]]=1 | ||
idxs=np.where(np.max(out[elnode[~fp, :]], axis=1) > 0)[0] | ||
idxs_nudge[elnode[~fp,:][idxs,:]]=1 | ||
|
||
idxs=np.where(idxs_nudge == 1)[0] | ||
global_idxs[i] = idxs | ||
|
||
|
||
#logger.info(f'len of nudge idxs is {len(idxs)}') | ||
logger.info(f'It took {time() -t0} sencods to calcuate nudge coefficient') | ||
|
||
nudge = [f"rlmax={rlmax}, rnu_day={rnu_day}"] | ||
nudge.extend("\n") | ||
nudge.append(f"{NE} {NP}") | ||
nudge.extend("\n") | ||
hgrid = self.hgrid.to_dict() | ||
nodes = hgrid['nodes'] | ||
elements = hgrid['elements'] | ||
for idn, (coords, values) in nodes.items(): | ||
line = [f"{idn}"] | ||
line.extend([f"{x:<.7e}" for x in coords]) | ||
line.extend([f"{nudge_coeff[int(idn)-1]:<.7e}"]) | ||
line.extend("\n") | ||
nudge.append(" ".join(line)) | ||
|
||
for id, element in elements.items(): | ||
line = [f"{id}"] | ||
line.append(f"{len(element)}") | ||
line.extend([f"{e}" for e in element]) | ||
line.extend("\n") | ||
nudge.append(" ".join(line)) | ||
|
||
with open(outdir / 'TEM_nudge.gr3','w+') as fid: | ||
fid.writelines(nudge) | ||
|
||
shutil.copy2(outdir / 'TEM_nudge.gr3', outdir / 'SAL_nudge.gr3') | ||
|
||
return global_idxs |
21 changes: 21 additions & 0 deletions
21
src/Utility/Pre-Processing/STOFS-3D-Atl-shadow-VIMS/Pre_processing/Nudge/gen_nudge2.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#! /usr/bin/env python | ||
from datetime import datetime, timedelta | ||
import logging | ||
|
||
from pyschism.mesh import Hgrid, Vgrid | ||
from pyschism.forcing.hycom.hycom2schism import Nudge | ||
|
||
|
||
logging.basicConfig(level=logging.INFO, force=True) | ||
|
||
|
||
if __name__ == '__main__': | ||
|
||
hgrid=Hgrid.open('./hgrid.gr3', crs='epsg:4326') | ||
vgrid='./vgrid.in' | ||
outdir='./' | ||
start_date = datetime(2022, 1, 1) | ||
rnday=171 | ||
|
||
nudge=Nudge() | ||
nudge.fetch_data(outdir, hgrid, vgrid, start_date, rnday) |
29 changes: 0 additions & 29 deletions
29
src/Utility/Pre-Processing/STOFS-3D-Atl-shadow-VIMS/Pre_processing/setup.py
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-157 Bytes
src/Utility/Pre-Processing/STOFS-3D-Atl-shadow-VIMS/__pycache__/__init__.cpython-39.pyc
Binary file not shown.