Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
68 changes: 68 additions & 0 deletions etc/scripts/coord_mrcc5_idx.ncl
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
; Meteorological Data Processing Workflow
; Copyright (C) 2022, University of Saskatchewan
; Copyright (C) 2023, University of Calgary
;
; This file is part of Meteorological Data Processing Workflow
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.

; usage:
; ncl 'coord_file="./path/to/wrf/coordinate/file.nc"' \
; 'minlat=float' \
; 'maxlat=float' \
; 'minlon=float' \
; 'maxlon=float' \
; coord_wrf_idx.ncl;

;---suppress errors including fatal ones
err = NhlGetErrorObjectId()

setvalues err
"errPrint" : "False"
end setvalues

;---coordinate variable path and and name must be entered as input arguments
a = addfile(coord_file,"r")
glat2d = a->lat
glon2d = a->lon

;---variable names below should be defined as input arguments
; minlat
; maxlat
; minlon
; maxlon
; print("coord_file: "+coord_file)
; print("minlat: "+minlat)
; print("maxlat: "+maxlat)
; print("minlon: "+minlon)
; print("maxlon: "+maxlon)

;---Get xy indexes, and then use these to get lat/lon values back again.
opt = True
loc = region_ind (glat2d, glon2d, minlat, maxlat, minlon, maxlon)

;---print ERROR and exit of spatial index are out of range
# if (.not. all(loc)) then
# print("ERROR")
# exit
# end if

;---print the following box of data: [minlonidx, maxlonidx, minlatidx, maxlatidx]
minlonidx = loc(2)
maxlonidx = loc(3)
minlatidx = loc(0)
maxlatidx = loc(1)
print(minlonidx+","+maxlonidx)
print(minlatidx+","+maxlatidx)
;---END
6 changes: 2 additions & 4 deletions var/repos/builtin/recipes/ouranos-mrcc5-cmip6/mrcc5-cmip6.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,8 @@ shopt -s expand_aliases

# paths
root="$(echo $(dirname $0) | grep -Po '(.*)(?=((/.*?){5})$)')"
# daymet index scripts works on RDRSv2.1 grids as well
# and ESPO-G6-R2 has similar grid system as RDRSv2.1
coordIdxScript="$root/etc/scripts/coord_daymet_idx.ncl"
coordClosestIdxScript="$root/etc/scripts/coord_closest_daymet_idx.ncl"
# Ouranos MRCC5-CMIP6 index script
coordIdxScript="$root/etc/scripts/coord_mrcc5_idx.ncl"


# ==========================
Expand Down