Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save raphaeldussin/656bb249f1763845192c95b2500b8a35 to your computer and use it in GitHub Desktop.
Save raphaeldussin/656bb249f1763845192c95b2500b8a35 to your computer and use it in GitHub Desktop.
Subsetting a ROMS grid/output file
#!/bin/bash
# interior rho points + 1 point on each side
imin=135
imax=155
jmin=375
jmax=380
iminv=$(( $imin ))
imaxv=$(( $imax ))
jminv=$(( $jmin ))
jmaxv=$(( $jmax -1 ))
iminu=$(( $imin ))
imaxu=$(( $imax -1 ))
jminu=$(( $jmin ))
jmaxu=$(( $jmax ))
iminp=$(( $imin + 1 ))
imaxp=$(( $imax ))
jminp=$(( $jmin + 1 ))
jmaxp=$(( $jmax ))
iminv=$(( $imin ))
imaxv=$(( $imax + 1 ))
jminv=$(( $jmin ))
jmaxv=$(( $jmax + 1 ))
ncks -d xi_rho,$imin,$imax -d eta_rho,$jmin,$jmax \
-d xi_v,$iminv,$imaxv -d eta_v,$jminv,$jmaxv \
-d xi_u,$iminu,$imaxu -d eta_u,$jminu,$jmaxu \
-d xi_psi,$iminp,$imaxp -d eta_psi,$jminp,$jmaxp \
# -d xi_vert,$iminv,$imaxv -d eta_vert,$jminv,$jmaxv \ # if you have vertices
roms_file.nc -o smaller_roms_file.nc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment