Skip to content

Commit ee79769

Browse files
Covering region rather than satisfying lat/lon limits (#76)
This commit resolves the issue of spatial subsetting to include a region of interest, rather than simply satisfying the lat/lon limits of a region. Signed-off-by: Kasra Keshavarz <[email protected]>
1 parent 1d1132a commit ee79769

File tree

2 files changed

+70
-4
lines changed

2 files changed

+70
-4
lines changed

etc/scripts/coord_mrcc5_idx.ncl

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
; Meteorological Data Processing Workflow
2+
; Copyright (C) 2022, University of Saskatchewan
3+
; Copyright (C) 2023, University of Calgary
4+
;
5+
; This file is part of Meteorological Data Processing Workflow
6+
;
7+
; This program is free software: you can redistribute it and/or modify
8+
; it under the terms of the GNU General Public License as published by
9+
; the Free Software Foundation, either version 3 of the License, or
10+
; (at your option) any later version.
11+
;
12+
; This program is distributed in the hope that it will be useful,
13+
; but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
; GNU General Public License for more details.
16+
;
17+
; You should have received a copy of the GNU General Public License
18+
; along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
20+
; usage:
21+
; ncl 'coord_file="./path/to/wrf/coordinate/file.nc"' \
22+
; 'minlat=float' \
23+
; 'maxlat=float' \
24+
; 'minlon=float' \
25+
; 'maxlon=float' \
26+
; coord_wrf_idx.ncl;
27+
28+
;---suppress errors including fatal ones
29+
err = NhlGetErrorObjectId()
30+
31+
setvalues err
32+
"errPrint" : "False"
33+
end setvalues
34+
35+
;---coordinate variable path and and name must be entered as input arguments
36+
a = addfile(coord_file,"r")
37+
glat2d = a->lat
38+
glon2d = a->lon
39+
40+
;---variable names below should be defined as input arguments
41+
; minlat
42+
; maxlat
43+
; minlon
44+
; maxlon
45+
; print("coord_file: "+coord_file)
46+
; print("minlat: "+minlat)
47+
; print("maxlat: "+maxlat)
48+
; print("minlon: "+minlon)
49+
; print("maxlon: "+maxlon)
50+
51+
;---Get xy indexes, and then use these to get lat/lon values back again.
52+
opt = True
53+
loc = region_ind (glat2d, glon2d, minlat, maxlat, minlon, maxlon)
54+
55+
;---print ERROR and exit of spatial index are out of range
56+
# if (.not. all(loc)) then
57+
# print("ERROR")
58+
# exit
59+
# end if
60+
61+
;---print the following box of data: [minlonidx, maxlonidx, minlatidx, maxlatidx]
62+
minlonidx = loc(2)
63+
maxlonidx = loc(3)
64+
minlatidx = loc(0)
65+
maxlatidx = loc(1)
66+
print(minlonidx+","+maxlonidx)
67+
print(minlatidx+","+maxlatidx)
68+
;---END

var/repos/builtin/recipes/ouranos-mrcc5-cmip6/mrcc5-cmip6.sh

+2-4
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,8 @@ shopt -s expand_aliases
137137

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

145143

146144
# ==========================

0 commit comments

Comments
 (0)