Skip to content

Commit

Permalink
Iss12 (#15)
Browse files Browse the repository at this point in the history
* Daymet dataset added,
* Bumping version to `v0.2.0`.
  • Loading branch information
kasra-keshavarz authored May 5, 2023
1 parent 03d742f commit 6aa35ec
Show file tree
Hide file tree
Showing 10 changed files with 1,326 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
.git
.ipynb_checkpoints
.DS_Store

*.swp
13 changes: 13 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Changelog
=========

[v0.2.0] - May 5th, 2023

# Added
* `Daymet` dataset based on https://daymet.ornl.gov/overview.

# Changed
* not applicable

# Fixed
* not applicable
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.0
0.2.0
66 changes: 66 additions & 0 deletions assets/coord_closest_daymet_idx.ncl
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
; 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)

;---building arrays for getind_latlon2d () function
lat = (/ minlat, maxlat /)
lon = (/ minlon, maxlon /)

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

;---print the following array: [minlonidx, maxlonidx, minlatidx, maxlatidx]
minlonidx = min(loc(:, 1))
maxlonidx = max(loc(:, 1))
minlatidx = min(loc(:, 0))
maxlatidx = max(loc(:, 0))
print(minlonidx+","+maxlonidx)
print(minlatidx+","+maxlatidx)
;---END
68 changes: 68 additions & 0 deletions assets/coord_daymet_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
Loading

0 comments on commit 6aa35ec

Please sign in to comment.