Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
733d2a2
Added software for Non global mesh generation using jigsaw
kestonsmith-noaa Jan 29, 2026
88420ed
clarifying edits and performance improvement
kestonsmith-noaa Jan 30, 2026
98b6c47
some parameter changes and plot supresion in Post processing script
kestonsmith-noaa Feb 2, 2026
f688015
Some additional comments and edited paths in scripts to run on Ursa
kestonsmith-noaa Feb 2, 2026
d37b024
added scripts for merging OSM and GSHHS PSLGs based on geographic region
kestonsmith-noaa Feb 2, 2026
890ea10
added jobcards for matlab and python scripts for Ursa
kestonsmith-noaa Feb 2, 2026
3d37fff
added jobcards for matlab and python scripts for Ursa and fixed file …
kestonsmith-noaa Feb 2, 2026
feafe6c
fixed path for python environment
kestonsmith-noaa Feb 2, 2026
145a885
simplified path specification for matlab scripts
kestonsmith-noaa Feb 2, 2026
1e588c9
added README file pointing to online documentation
kestonsmith-noaa Feb 2, 2026
5f014b2
cleared some unused statements
kestonsmith-noaa Feb 3, 2026
bb23080
added bathymetry interpolation routines to archive
kestonsmith-noaa Feb 3, 2026
3517fe9
added missing file, DivideMeshNodes.py
kestonsmith-noaa Feb 3, 2026
c66d48f
added README.txt to InterpolateBathymetry
kestonsmith-noaa Feb 3, 2026
ee3ae59
documentation added within InterpolateCRM.partscat.py
kestonsmith-noaa Feb 3, 2026
9e61f50
Added start of script to download all bathymetry file. Incompleate d…
kestonsmith-noaa Feb 3, 2026
d39b4de
made RWPSMeshGenScript file inputs consistent with PreProcessCoastlin…
kestonsmith-noaa Feb 4, 2026
af159ce
made PostProcessGrid inputs consistent with RWPSMeshGenScript and P…
kestonsmith-noaa Feb 4, 2026
57a397f
fixed path issue for unstrutured dataset
kestonsmith-noaa Feb 4, 2026
2d31977
comments clarifing output file definitions
kestonsmith-noaa Feb 4, 2026
c7de8ed
Added python scripts and postprocessing for generating mesh with modi…
kestonsmith-noaa Feb 4, 2026
3ffc538
Added Ursa jobcards for generating mesh with modified New Orleans Coast
kestonsmith-noaa Feb 4, 2026
95697c7
Fixed file matlab name for OSMxGSHHS.NewOrl post processing
kestonsmith-noaa Feb 4, 2026
1cd904f
removed some unescesary files in unst_msh_gen/RWPSMeshtoolkit/MeshGen…
kestonsmith-noaa Feb 4, 2026
3d542a3
added script to download all needed bathymetry data
kestonsmith-noaa Feb 4, 2026
85a0ca5
added script to download all needed bathymetry data (again)
kestonsmith-noaa Feb 4, 2026
ca1f4ef
added shell script to download all bathymetry data used in RWPS
kestonsmith-noaa Feb 4, 2026
9907187
removed slurm jobcard for downloading data (replaced with shell script)
kestonsmith-noaa Feb 4, 2026
f929a4a
changed final mesh name for defat
kestonsmith-noaa Feb 4, 2026
e047186
fixed error in python env path
kestonsmith-noaa Feb 4, 2026
00dabf5
removed some unused files in unst_msh_gen/RWPSMeshtoolkit/matlab/ and…
kestonsmith-noaa Feb 5, 2026
d213d1a
further headers for funcions in unst_msh_gen/RWPSMeshtoolkit/matlab
kestonsmith-noaa Feb 5, 2026
5bd30cd
filled in further headers in matlab functions
kestonsmith-noaa Feb 5, 2026
8260061
filled in more headers for matlab functions
kestonsmith-noaa Feb 5, 2026
b57932a
finished adding headers to files in unst_msh_gen/RWPSMeshtoolkit/matlab/
kestonsmith-noaa Feb 6, 2026
46676c4
Added function to generate outer boundary from arbitrary rectangle an…
kestonsmith-noaa Feb 6, 2026
7b1405f
Added shell script to download coastline shapefiles used in RWPS mesh…
kestonsmith-noaa Feb 6, 2026
7df5eb3
added generic function for generating boundary PSLG from coastline da…
kestonsmith-noaa Feb 6, 2026
c549d98
Simplified files path specification by adding input paths to SetPath.…
kestonsmith-noaa Feb 10, 2026
90a4c13
Added function LonCon to remove longitude transform from scripts. Cha…
kestonsmith-noaa Feb 11, 2026
6011692
Added sample scripts for local mesh generation. fixed lake meshfile p…
kestonsmith-noaa Feb 11, 2026
ceb89f1
Added paths for local mesh generation example to SetPath
kestonsmith-noaa Feb 11, 2026
b77a507
changes related to update of OSM coastline data. Fixed typo in file …
kestonsmith-noaa Feb 11, 2026
24bb967
renamed RWPSMeshtoolkit as regional, within unst_msh_gen
kestonsmith-noaa Feb 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions unst_msh_gen/regional/InterpolateBathymetry/AddBathyToMesh.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

#
# Function for taking bathymetry field in a text file and replacing bathymetry
# from a WW3 .msh files with the values from the file specified on the command
# line:
#
# $python3 AddBathyToMesh.py MyBathy.txt
#
# creates a new WW3 mesh with bathymetry from MyBathy.txt
#
#

import FiniteElementMeshRoutines as FE
import numpy as np
import sys

mshnm="HawaiiTest"
mesh="meshes/"+mshnm+".msh"

flin=sys.argv[1]
flout=flin+".WW3.msh"

x, y, z0, e, bnd = FE.loadWW3Mesh(mesh)

zmin=1.
nn=len(x)
z=np.zeros(nn)
f=open(flin, 'r')
for k in range(nn):
line=f.readline()
#print(str(k)+" "+line)
z[k]=float(line.strip())
z[k]=-z[k]
z[k]=max(z[k],zmin)
f.close
FE.WriteWW3Mesh(flout,x,y,z,e,bnd)

141 changes: 141 additions & 0 deletions unst_msh_gen/regional/InterpolateBathymetry/DivideMeshNodes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@

#
# This script partitions the nodes in mshnm into NP parts and writes a script to
# interpolate bathymetry data to the nodes in NP parallel parts
# call:
#
# $ python3 DivideMeshNodes.py 100
#
# to create jobcard: jobcardInterpBathy2Mesh, which is then run:
#
# $ sbatch jobcardInterpBathy2Mesh
#
# to interpolate the bathymetry in 100 parallel tasks
#
# This script should be run after the bathymetry data sets specified in
# InterpolateCRM.partscat.py are present
#
"""
Ursa environment

module purge
module use /scratch3/NCEPDEV/climate/Keston.Smith/global-workflowA/sorc/ufs_model.fd/modulefiles
module load ufs_ursa.intel
module load py-scipy/1.14.1
module load py-netcdf4/1.7.1.post2
pip list
"""

import os
import argparse
import time
import numpy as np
import netCDF4 as nc
import math
import sys
from scipy.interpolate import RegularGridInterpolator
#import re
import FiniteElementMeshRoutines as FE
import random

mshnm="HawaiiTest"
mesh="meshes/"+mshnm+".msh"
OutDir=mshnm+".files/"

jobcard="jobcardInterpBathy2Mesh"


def WriteInterpJobscript(fl,N, ComputeNodes):
with open(fl, 'w') as f:
#yi[k]=float(values[4])
f.write("#!/bin/bash \n")
f.write("#SBATCH --job-name=CRM_interp_masterscript \n")
# f.write("#SBATCH --ntasks="+str(N)+" \n")
f.write("#SBATCH --ntasks=1 \n") # ntasks per interpolation
f.write("#SBATCH --time=08:00:00 \n")
f.write("#SBATCH --output=mpi_test_%j.log \n")
f.write("#SBATCH --error=%j.err \n")
f.write("#SBATCH --account=marine-cpu \n")
f.write("#SBATCH --nodes="+str(ComputeNodes)+" \n")
f.write("#SBATCH --ntasks-per-core=1"+" \n")
f.write("#SBATCH --array=0-"+str(N-1)+" \n")

f.write(" \n")

f.write("module purge \n")
f.write("module use /scratch3/NCEPDEV/climate/Keston.Smith/global-workflowA/sorc/ufs_model.fd/modulefiles \n")
f.write("module load ufs_ursa.intel \n")
f.write("module load py-scipy/1.14.1 \n")
f.write("module load py-netcdf4/1.7.1.post2 \n")
f.write("pip list \n")
f.write("srun python3 InterpolateCRM.partscat.py $SLURM_ARRAY_TASK_ID > InterpJob.$SLURM_ARRAY_TASK_ID.out \n")
f.write("wait \n")
f.write("## Run this after the full job array is compleate.\n")
f.write("## Patch randomly shuffled fields in orgigonal order.\n")

f.write("python3 KnitOutputBackTogether.py "+str(N)+" GMN\n")
f.write("python3 KnitOutputBackTogether.py "+str(N)+" GMU\n")
f.write("python3 KnitOutputBackTogether.py "+str(N)+" InvDist\n")
f.write("python3 KnitOutputBackTogether.py "+str(N)+" NDataPoints\n")
f.write("python3 KnitOutputBackTogether.py "+str(N)+" ClosestValue\n")
f.write("python3 KnitOutputBackTogether.py "+str(N)+" LengthScale\n")
f.write("python3 KnitOutputBackTogether.py "+str(N)+" GMU.std\n")
f.write("python3 KnitOutputBackTogether.py "+str(N)+" GMN.std\n")
#f.write("python3 KnitOutputBackTogether.py "+str(N)+" GMM\n")
#f.write("python3 KnitOutputBackTogether.py "+str(N)+" GM0\n")


# Create the output directory------------------------------------------
try:
os.mkdir(OutDir)
print(f"Directory '{OutDir}' created successfully.")
except FileExistsError:
print(f"Directory '{OutDir}' already exists. Proceeding ...")
except PermissionError:
print(f"Permission denied: Unable to create '{OutDir}'.")

fl="meshes/"+mshnm+".msh"

xi, yi, ei =FE.loadWW3MeshCoords(fl)

#tmp
lsE=FE.lengthscale(xi, yi, ei)
areaE=FE.ElementArea(xi, yi, ei)
lsN=FE.ComputeNodeLengthScale(lsE, areaE, ei)
np.savetxt("LengthScaleNodes.txt", lsN, fmt='%.6f', delimiter='\n')

# randomly sort nodes for roughly equal jobs size
# nodes within CRM envelope use far more compute than
# open ocean nodes with fewer points used in interpolation

nn=len(xi)
Nodes = list(range( nn ))
random.shuffle(Nodes) # randomize order of nodes for equitable job load

Nparts=int(sys.argv[1])

nn=xi.shape[0]
NodesPerProc=math.ceil(nn/Nparts)
print(str(NodesPerProc)+ " " + str(nn))
a = range(nn)

NodeList = []
for i in range(0, len(a), NodesPerProc): # Slice list in steps of n
NodeList.append(a[i:i + NodesPerProc])

print("NodeList")
print(NodeList)
for k in range(Nparts):
flo=OutDir+'NodeList.'+str(k)+'.txt'
f=open(flo, 'w')
f.write("List of nodes for job "+str(k) + "\n")
List=NodeList[k]
n=len(List)
f.write(str(n) + "\n")
for j in range(n):
#f.write(str(List[j]) + '\n') # sequential order of nodes, output can be cat > back together
f.write(str(Nodes[List[j]]) + '\n') # random order of nodes
f.close

#write jobcard to do interpolation
WriteInterpJobscript(jobcard,Nparts,1)
103 changes: 103 additions & 0 deletions unst_msh_gen/regional/InterpolateBathymetry/DowloadBathyData.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/bin/bash
#############################################################################################################

# Script to download global and regional bathymetry files:
# You will need ~ 20 GB free space

echo "Downloading bathymetry data"

#############################################################################################################
######################## Download main Coastal Relief Moesl (CRM) files #####################################
#############################################################################################################
# see: https://www.ncei.noaa.gov/products/coastal-relief-model
#############################################################################################################
#Northeast Atlantic
wget --output-document crm_vol1_2023.nc https://www.ngdc.noaa.gov/thredds/fileServer/crm/cudem/crm_vol1_2023.nc
#Southeast Atlantic
wget --output-document crm_vol2_2023.nc https://www.ngdc.noaa.gov/thredds/fileServer/crm/cudem/crm_vol2_2023.nc
# Florida and East Gulf of America
wget --output-document crm_vol3_2023.nc https://www.ngdc.noaa.gov/thredds/fileServer/crm/cudem/crm_vol3_2023.nc
# Central GOA
wget --output-document crm_vol4_2023.nc https://www.ngdc.noaa.gov/thredds/fileServer/crm/cudem/crm_vol4_2023.nc
# Western GOA
wget --output-document crm_vol5_2023.nc https://www.ngdc.noaa.gov/thredds/fileServer/crm/cudem/crm_vol5_2023.nc
#Central Pacific
wget --output-document crm_vol7_2023.nc https://www.ngdc.noaa.gov/thredds/fileServer/crm/cudem/crm_vol7_2023.nc
#Northwest Pacific
wget --output-document crm_vol8_2023.nc https://www.ngdc.noaa.gov/thredds/fileServer/crm/cudem/crm_vol8_2023.nc
#Puerto Rico
wget --output-document crm_vol9_2023.nc https://www.ngdc.noaa.gov/thredds/fileServer/crm/cudem/crm_vol9_2023.nc
#Hawaii
wget --output-document crm_vol10_2023.nc https://www.ngdc.noaa.gov/thredds/fileServer/crm/cudem/crm_vol10_2023.nc
#Other CRM files
# Southern California
wget --output-document crm_vol6.nc https://www.ngdc.noaa.gov/thredds/fileServer/crm/crm_vol6.nc
# Southern Alaska
wget --output-document crm_southak.nc https://www.ngdc.noaa.gov/thredds/fileServer/crm/crm_southak.nc
#############################################################################################################

echo "Done Coastal Relief Model (CRM) Download"

#############################################################################################################
######################## Download regional files in Pacific #################################################
#############################################################################################################
# see: https://pae-paha.pacioos.hawaii.edu/thredds/bathymetry.html
#############################################################################################################
# American Samoa
wget --output-document ngdc_bathy_90m_amsamoa.nc https://pae-paha.pacioos.hawaii.edu/thredds/ncss/ngdc_bathy_90m_amsamoa?var=elev&disableLLSubset=on&disableProjSubset=on&horizStride=1&addLatLon=true
# Mariana islands
wget --output-document ngdc_bathy_180m_mariana.nc https://pae-paha.pacioos.hawaii.edu/thredds/ncss/ngdc_bathy_180m_mariana?var=elev&disableLLSubset=on&disableProjSubset=on&horizStride=1&addLatLon=true
#North Western Hawiian islands
wget --output-document hurl_bathy_60m_nwhi.nc https://pae-paha.pacioos.hawaii.edu/thredds/ncss/hurl_bathy_60m_nwhi?var=elev&disableLLSubset=on&disableProjSubset=on&horizStride=1&addLatLon=true
#############################################################################################################

echo "Done regional files in Pacific Download"

#############################################################################################################
######################## Download small scale bathymetry for US Minor outlying islands in Pacific ###########
#############################################################################################################
# see: https://pae-paha.pacioos.hawaii.edu/thredds/bathymetry.html
#############################################################################################################
wget --output-document ngdc_bathy_10m_wake.nc https://pae-paha.pacioos.hawaii.edu/thredds/ncss/ngdc_bathy_10m_wake?var=elev&disableLLSubset=on&disableProjSubset=on&horizStride=1&addLatLon=true

wget --output-document pibhmc_bathy_20m_jarvis.nc https://pae-paha.pacioos.hawaii.edu/thredds/ncss/pibhmc_bathy_20m_jarvis?var=elev&disableLLSubset=on&disableProjSubset=on&horizStride=1&addLatLon=true

wget --output-document pibhmc_bathy_20m_johnston.nc https://pae-paha.pacioos.hawaii.edu/thredds/ncss/pibhmc_bathy_20m_johnston?var=elev&disableLLSubset=on&disableProjSubset=on&horizStride=1&addLatLon=true

wget --output-document pibhmc_bathy_20m_kingman.nc https://pae-paha.pacioos.hawaii.edu/thredds/ncss/pibhmc_bathy_20m_kingman?var=elev&disableLLSubset=on&disableProjSubset=on&horizStride=1&addLatLon=true

wget --output-document pibhmc_bathy_40m_baker.nc https://pae-paha.pacioos.hawaii.edu/thredds/ncss/pibhmc_bathy_40m_baker?var=elev&disableLLSubset=on&disableProjSubset=on&horizStride=1&addLatLon=true

wget --output-document pibhmc_bathy_40m_howland.nc https://pae-paha.pacioos.hawaii.edu/thredds/ncss/pibhmc_bathy_40m_howland?var=elev&disableLLSubset=on&disableProjSubset=on&horizStride=1&addLatLon=true

wget --output-document pibhmc_bathy_40m_palmyra.nc https://pae-paha.pacioos.hawaii.edu/thredds/ncss/pibhmc_bathy_40m_palmyra?var=elev&disableLLSubset=on&disableProjSubset=on&horizStride=1&addLatLon=true

wget --output-document pibhmc_bathy_40m_rose.nc https://pae-paha.pacioos.hawaii.edu/thredds/ncss/pibhmc_bathy_40m_rose?var=elev&disableLLSubset=on&disableProjSubset=on&horizStride=1&addLatLon=true

wget --output-document pibhmc_bathy_40m_vailuluu.nc https://pae-paha.pacioos.hawaii.edu/thredds/ncss/pibhmc_bathy_40m_vailuluu?var=elev&disableLLSubset=on&disableProjSubset=on&horizStride=1&addLatLon=true

wget --output-document pibhmc_bathy_40m_swains.nc https://pae-paha.pacioos.hawaii.edu/thredds/ncss/pibhmc_bathy_40m_swains?var=elev&disableLLSubset=on&disableProjSubset=on&horizStride=1&addLatLon=true

wget --output-document pibhmc_bathy_5m_palmyra.nc https://pae-paha.pacioos.hawaii.edu/thredds/ncss/pibhmc_bathy_5m_palmyra?var=elev&disableLLSubset=on&disableProjSubset=on&horizStride=1&addLatLon=true

wget --output-document sopac_bathy_50m_majuro_reef.nc https://pae-paha.pacioos.hawaii.edu/thredds/ncss/sopac_bathy_50m_majuro_reef?var=elev&disableLLSubset=on&disableProjSubset=on&horizStride=1&addLatLon=true
#############################################################################################################

echo "Done small scale bathymetry for US Minor outlying islands in Pacific download"

#############################################################################################################
######################## Global SDB [~0m to ~30m] depth from copernicus #####################################
#############################################################################################################
# see: https://data.marine.copernicus.eu/product/BATHYMETRY_GLO_PHY_COASTAL_L4_MY_016_001/files?subdataset=cmems_obs-sdb_glo_phy_comp_my_100m-l4-s2_static_202511
#############################################################################################################
wget --output-document cmems_obs-sdb_glo_phy-comp_my-oa-100m-l4-s2_static.nc https://s3.waw3-1.cloudferro.com/mdl-native-17/native/BATHYMETRY_GLO_PHY_COASTAL_L4_MY_016_001/cmems_obs-sdb_glo_phy_wk_my_100m-l4-s2_static_202511/cmems_obs-sdb_glo_phy-wk_my-oa-100m-l4-s2_static.nc
#############################################################################################################

echo "Done Global SDB download"

#############################################################################################################
######################## 60 second Global Bathymetry#########################################################
wget https://github.com/dengwirda/dem/releases/download/v0.1.1/RTopo_2_0_4_GEBCO_v2024_60sec_pixel.zip
#############################################################################################################

echo "Done Global Bathymetry download"
Loading