|
| 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 |
0 commit comments