-
Notifications
You must be signed in to change notification settings - Fork 4
Add interpolation weight calc #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
07d10ee
1fbf8e8
d6b7eaf
5a5ed4a
d82dc06
38580ec
5d69933
4ba7b2d
531f59e
97af00d
a94b153
a805b29
4aedb5a
5988ba9
a493c00
b9fd93f
c7b20dc
005a568
6c1c479
afbbd56
5f0e7b6
976fa89
8f21c8f
4848eae
10e8b0c
88effe3
76cfdd4
e24200e
80e42ee
56a8ab9
4aed3c2
8b9f696
5d95849
9363b14
e63f791
7842f94
95a511f
e57dafc
bf468d5
390b860
6ee7506
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| Scripts to create interpolation weights and distance to boundary files for interpolating forcing to RWPS mesh. | ||
| To run: | ||
|
|
||
| $ cd RWPS/dev/compute_interpolation_weights/ush | ||
| $ sh compute_interpolation_weights.sh oc_1500m_30km | ||
|
|
||
| to generate interpolation files for mesh rwps.oc_1500m_30km.msh. Files will be writen to directory: | ||
| RWPS/interpolation_weights | ||
|
|
||
| Interpolation weights are created for: | ||
|
|
||
| nbm oc domain | ||
| rrfs hi domain (used for wind) | ||
| rrfs pr domain (used for wind) | ||
| rrfs ak domain (used for wind) | ||
| rrfs na domain (used for wind) | ||
| rrfs conus domain (used for wind) | ||
| nbm ak domain (used for ice concentration) | ||
| rtofs glo domain (used for current without extrapolation) | ||
| rtofs glo domain (used for ice with extrapolation) | ||
| stofs domain (used for waterlevel and current) | ||
|
|
||
| Currently only setup to work on wcoss2. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #!/bin/bash | ||
| #PBS -N compute_interpolation_weights | ||
| #PBS -j oe | ||
| #PBS -S /bin/bash | ||
| #PBS -q dev | ||
| #PBS -A NWPS-DEV | ||
| #PBS -l walltime=04:00:00 | ||
| #PBS -l select=1:ncpus=32:mem=500GB | ||
| #PBS -l place=excl | ||
| #PBS -l debug=true | ||
|
|
||
| module reset | ||
| module load PrgEnv-intel/8.5.0 | ||
| module load intel/19.1.3.304 | ||
| module load craype/2.7.17 | ||
| module load cray-mpich/8.1.19 | ||
| module load hdf5-C/1.14.0 | ||
| module load netcdf-C/4.9.2 | ||
| module load esmf-C/8.6.0 | ||
| module load ve/hafs/2.1 | ||
|
|
||
| pip list -v | ||
|
|
||
| $HOMErwps/dev/compute_interpolation_weights/jobs/COMPUTE_INTERPOLATION_WEIGHTS | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| #!/bin/bash | ||
|
|
||
| ###################################################################### | ||
| # This job computes interpolation weights and distance to boundary for | ||
| # a RWPS mesh. Currently configured for: | ||
| # nbm oc domain (wind) | ||
| # nbm ak domain (ice) | ||
| # rrfs hi domain (wind) | ||
| # rrfs pr domain (wind) | ||
| # rrfs ak domain (wind) | ||
| # rrfs conus domain (wind) | ||
| # rrfs na domain (wind) | ||
| # rtofs glo domain (surface currents, ice) | ||
| # stofs v3 (waterlevel, currents) | ||
| # | ||
| # Different sets of interpolation weights are created for rtofs ice | ||
| # and surface currents so that ice concentration can be extrapolated | ||
| # by nearest node while currents are not extrapolated into coastal | ||
| # regions outside of rtofs marine domain. | ||
| # | ||
| # Files are created in local RWPS/fix directory. | ||
| ###################################################################### | ||
|
|
||
| cd $HOMErwps/dev/compute_interpolation_weights/ush | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is where maybe instead in the future we could cd into a working directory? |
||
|
|
||
| # Sample input directory | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you make a note here about if this sample data didn't exist what this data is? |
||
| SID="/lfs/h2/emc/couple/noscrub/keston.smith/SampleInput" | ||
| date="20260730" | ||
| cycl="00" | ||
| Nprocs=32 | ||
|
|
||
| ###################################################################### | ||
| # Compute rrfs interpolation weights for interpolating wind. | ||
| # no extrapolation for rrfs forecasts. | ||
| ###################################################################### | ||
| rrfs_hi=$SID/wind.$date.$cycl/rrfs.$date.$cycl.wind10m.hi.nc | ||
| rrfs_pr=$SID/wind.$date.$cycl/rrfs.$date.$cycl.wind10m.pr.nc | ||
| rrfs_ak=$SID/wind.$date.$cycl/rrfs.$date.$cycl.wind10m.ak.nc | ||
| rrfs_na=$SID/wind.$date.$cycl/rrfs.$date.$cycl.wind10m.na.nc | ||
| rrfs_conus=$SID/wind.$date.$cycl/rrfs.$date.$cycl.wind10m.conus.nc | ||
|
|
||
|
|
||
| rrfsIntrp="$out/InterpolationWeights.$meshname.rrfs" | ||
| rrfsDst="$out/DistToBndy.$meshname.rrfs" | ||
|
|
||
| rm -rf $rrfsIntrp.hi.nc $rrfsDst.hi.nc __pycache__ | ||
| python ./compute_gridded_to_rwps_interp_weights.py $rrfs_hi $mesh $rrfsIntrp.hi.nc $rrfsDst.hi.nc -1 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of ./compute_gridded_to_rwps_interp_weights.py if you're running from a working directory or if this was an ops not a dev job, this should instead be: ${USHrwps}/compute_gridded_to_rwps_interp_weights.py |
||
|
|
||
| rm -rf $rrfsIntrp.pr.nc $rrfsDst.pr.nc __pycache__ | ||
| python ./compute_gridded_to_rwps_interp_weights.py $rrfs_pr $mesh $rrfsIntrp.pr.nc $rrfsDst.pr.nc -1 | ||
|
|
||
| rm -rf $rrfsIntrp.ak.nc $rrfsDst.ak.nc __pycache__ | ||
| python ./compute_gridded_to_rwps_interp_weights.py $rrfs_ak $mesh $rrfsIntrp.ak.nc $rrfsDst.ak.nc -1 | ||
|
|
||
| rm -rf $rrfsIntrp.na.nc $rrfsDst.na.nc __pycache__ | ||
| python ./compute_gridded_to_rwps_interp_weights.py $rrfs_na $mesh $rrfsIntrp.na.nc $rrfsDst.na.nc -1 | ||
|
|
||
| rm -rf $rrfsIntrp.conus.nc $rrfsDst.conus.nc __pycache__ | ||
| python ./compute_gridded_to_rwps_interp_weights.py $rrfs_conus $mesh $rrfsIntrp.conus.nc $rrfsDst.conus.nc -1 | ||
|
|
||
| ###################################################################### | ||
| # Compute nbm interpolation weights on oc domain for interpolating wind. | ||
| # Extrapolate to cover minor edge differences on south and east boundaries. | ||
| ###################################################################### | ||
| nbm_oc=$SID/wind.$date.$cycl/nbm.$date.$cycl.wind10m.oc.nc | ||
| nbmIntrp="$out/InterpolationWeights.$meshname.nbm" | ||
| nbmDst="$out/DistToBndy.$meshname.nbm" | ||
|
|
||
| #extrapolate nbm oc wind to all points | ||
| rm $nbmIntrp.oc.nc $nbmDst.oc.nc | ||
| python ./compute_gridded_to_rwps_interp_weights.py $nbm_oc $mesh $nbmIntrp.oc.nc $nbmDst.oc.nc 1 | ||
|
|
||
|
|
||
| ###################################################################### | ||
| # Compute nbm interpolation weights on ak domain for interpolating ice. | ||
| # No extrapolation outside the ak region | ||
| ###################################################################### | ||
| nbm_ak=$SID/ice.$date.$cycl/nbm.$date.$cycl.ice.ak.nc | ||
| #do not extrapolate for NBM .ak. domain | ||
| rm $nbmIntrp.ak.nc $nbmDst.ak.nc | ||
| python ./compute_gridded_to_rwps_interp_weights.py $nbm_ak $mesh $nbmIntrp.ak.nc $nbmDst.ak.nc -1 | ||
|
|
||
| rtofs_ice=$SID/ice.$date.$cycl/rtofs.ice.$date.nc | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should these 3 lines about rtofs go after the comment block ? |
||
| rtofsIntrp="$out/InterpolationWeights.$meshname.rtofs" | ||
| rtofsDst="$out/DistToBndy.$meshname.rtofs" | ||
|
|
||
| ###################################################################### | ||
| # Compute rtofs interpolation weights for interpolating ice. | ||
| # Do extrapolate rtofs .glo. for full ice coverage in near shore. | ||
| ###################################################################### | ||
| rm $rtofsIntrp.ice.nc $rtofsDst.ice.nc | ||
| python ./compute_gridded_to_rwps_interp_weights.py $rtofs_ice $mesh $rtofsIntrp.ice.nc $rtofsDst.ice.nc 1 | ||
|
|
||
|
|
||
| ###################################################################### | ||
| # Compute rtofs interpolation weights for interpolating currents. | ||
| # Do not extrapolate into coastal regions | ||
| ###################################################################### | ||
| rtofs_cur=$SID/rtofs.$date/currents.$date.rtofs.nc | ||
| #do not extrapolate rtofs .glo. currents | ||
| rm $rtofsIntrp.current.nc $rtofsDst.current.nc | ||
| python ./compute_gridded_to_rwps_interp_weights.py $rtofs_cur $mesh $rtofsIntrp.current.nc $rtofsDst.current.nc -1 | ||
|
|
||
|
|
||
| ###################################################################### | ||
| # Compute stofs interpolation weights for stofs v3 output | ||
| # All dates after ~ August 18 2026 | ||
| ###################################################################### | ||
| stofs_glo="$SID/stofs.v3/stofs.20260819.00/stofs_2d_glo.t00z.fields.cwl.nc" | ||
|
|
||
| mkdir -p STOFSInterpWeights.$meshname | ||
|
|
||
| # First construct parallel jobscript to compute weights using Nprocs division of destination domain(meshfile) | ||
| python compute_unstr_to_rwps_interp_weights.py $stofs_glo $mesh $Nprocs | ||
|
|
||
| # Now run the parallel job script | ||
| qsub -W block=true jobcardcompute_unstr_to_rwps_interp_weightsPBS | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note, qsub from a JJOB is not something that we would do in operations. Since this is dev, we can leave it as is, but I'll be honest, it's not my favorite. It means this just is very hard to port to multiple machines, etc. |
||
| wait | ||
|
|
||
| # combine text file output of parallel jobs | ||
| cat STOFSInterpWeights.$meshname/Part.IntrpWghts.*.txt > InterpWeights.$meshname.stofs.txt | ||
|
|
||
| # sort order of nodes and convert output weights to netcdf file | ||
| python convert_weights_to_netcdf.py $stofs_glo $mesh InterpWeights.$meshname.stofs.txt 1 | ||
| mv InterpWeights.$meshname.stofs.nc $out/InterpolationWeights.$meshname.stofs.nc | ||
| mv DistToBndy.$meshname.stofs.nc $out/DistToBndy.$meshname.stofs.nc | ||
|
|
||
| # clean up temporary directory and files | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the future, creating a working directory for the temporary files would be ideal. I watched as the job went and we had tons of files in the package directory that were then deleted. For future dev jobs, please think about using a temporary working directory instead. |
||
| rm -rf STOFSInterpWeights.$meshname | ||
| rm InterpWeights.$meshname.stofs.txt | ||
| rm *.out | ||
| rm ESMPy* | ||
| rm jobcardcompute_unstr_to_rwps* | ||
| rm -rf __pycache__ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Files are now in an output directory, correct?