-
Notifications
You must be signed in to change notification settings - Fork 2
/
cont.ncl
77 lines (52 loc) · 1.47 KB
/
cont.ncl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
;;; NCL script to check for gaps in time coordinate
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
function ut_date(time[1])
local date, result
begin
date = ut_calendar(time,-5)
result = ""+date(0,0)+"/"+date(0,1)+"/"+date(0,2)+" "+date(0,3)+":"+date(0,4)+":"+date(0,5)
return(result)
end
;; Arguments:
;; infile (mandatory): name of input file
;; step: timestep length (defaults to 1)
;; delta: tolerance for deviation from step size (defaults to 0)
;; terse: silent if ok, output filename only if gap found (defaults to False)
;; ncl -Q -n infile=\"table6/prtot_CRCM_climatology.nc\" step=1 delta=1.0/1440 cont.ncl
tab = " "
if (.not. isvar("step")) then
step = 1.0
end if
if (.not. isvar("delta")) then
delta = 0.0
end if
if (.not. isvar("terse")) then
terse = False
end if
;; open file
fin = addfile(infile, "r")
time = fin->time
nt = dimsizes(time)
if(.not. terse) then
print(""+infile)
end if
do i=0,nt-2
dt = time(i+1)-time(i)
if (abs(dt - step) .gt. delta) then
if(terse) then
print(""+infile)
exit
end if
print("----")
print (""+i+tab+time(i)+tab+ut_date(time(i)))
print (""+(i+1)+tab+time(i+1)+tab+ut_date(time(i+1)))
print (tab+dt)
end if
end do
print("====")
print("")
exit
;; Copyright 2009-2012 Univ. Corp. for Atmos. Research
;; Author: Seth McGinnis, [email protected]