<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Slight alternative to Karen's suggestion. Same basic idea but without the loop in the script it self.<div class=""><br class=""><div class=""><br class=""></div><div class=""><div class="">load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/cd_string.ncl"</div><div class="">begin</div><div class=""><br class=""></div><div class=""> f = addfile("vort_700hPa.nc","r") ;-- open file</div><div class=""><br class=""></div><div class=""> vr = f->vr ;-- read variable</div><div class=""> </div><div class=""> time = f->time ;-- read time</div><div class=""> ntimes = dimsizes(time) ;-- get size of time</div><div class=""><br class=""></div><div class="">;-- define sub-region</div><div class=""> lat0 = 7.5</div><div class=""> lat1 = 27.5</div><div class=""> lon0 = 11.0</div><div class=""> lon1 = 135.0</div><div class=""> </div><div class=""> vr_region = vr(:,{lat0:lat1},{lon0:lon1}) ;-- select the data of the sub-region</div><div class=""> printVarSummary(vr_region)</div><div class=""><br class=""></div><div class=""> threshold = 3e-5 ;-- define threshold</div><div class=""><br class=""></div><div class=""> vr_max = dim_max_n(vr_region, (/1,2/)) ;; max over lat/lon per time. </div><div class=""> time_inds = ind(vr_max .ge. threshold) ;; if the max isn’t greater than threshold then no values are. </div><div class=""><br class=""></div><div class=""> if(all(ismissing(time_inds)))</div><div class=""> print("No Times exceed threshold")</div><div class=""> status_exit(1)</div><div class=""> end if</div><div class=""><br class=""></div><div class=""> times = time(time_inds)</div><div class=""> print(cd_string(times, ""))</div><div class="">end</div><div class=""><br class=""></div><div class=""> </div><div class=""><br class=""></div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On 26 Apr 2017, at 12:20, Karin Meier-Fleischer <<a href="mailto:meier-fleischer@dkrz.de" class="">meier-fleischer@dkrz.de</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" class="">
<div bgcolor="#FFFFFF" text="#000000" class="">
Hi Lyndon,<br class="">
<br class="">
first you have to select the sub-region of your data and then get
the time indices where your data is greater equal than the
threshold.<br class="">
<br class="">
Your script should be looking like:<br class="">
<br class="">
<font color="#3333ff" class=""><tt class="">begin</tt></font><br class="">
<br class="">
<font color="#3333ff" class=""><tt class=""> f =
addfile("vort_700hPa.nc","r") ;-- open file</tt><tt class=""><br class="">
</tt><tt class=""><br class="">
</tt><tt class=""> vr = f->vr ;--
read variable</tt><tt class=""><br class="">
</tt><tt class=""> </tt><tt class=""><br class="">
</tt><tt class=""> time = f->time ;--
read time</tt><tt class=""><br class="">
</tt><tt class=""> ntimes = dimsizes(time) ;-- get
size of time</tt><tt class=""><br class="">
</tt><tt class=""><br class="">
</tt><tt class="">;-- define sub-region</tt><tt class=""><br class="">
</tt><tt class=""> lat0 = 7.5</tt><tt class=""><br class="">
</tt><tt class=""> lat1 = 27.5</tt><tt class=""><br class="">
</tt><tt class=""> lon0 = 11.0</tt><tt class=""><br class="">
</tt><tt class=""> lon1 = 135.0</tt><tt class=""><br class="">
</tt><tt class=""> </tt><tt class=""><br class="">
</tt><tt class=""> vr_region = vr(:,{lat0:lat1},{lon0:lon1}) ;--
select the data of the sub-region</tt><tt class=""><br class="">
</tt><tt class=""> printVarSummary(vr_region)</tt><tt class=""><br class="">
</tt><tt class=""><br class="">
</tt><tt class=""> threshold = 3e-5 ;--
define threshold</tt><tt class=""><br class="">
</tt><tt class=""><br class="">
</tt><tt class="">;-- loop over time to retrieve times where data is
greater equal threshold</tt><tt class=""><br class="">
</tt><tt class=""> j = 0</tt><tt class=""><br class="">
</tt><tt class=""> do i=0,ntimes-1</tt><tt class=""><br class="">
</tt><tt class=""> tmp := ndtooned(vr_region(i,:,:)) ;--
convert to 1d array</tt><tt class=""><br class="">
</tt><tt class=""> if(any(tmp .ge. threshold)) then</tt><tt class=""><br class="">
</tt><tt class=""> if(j .eq. 0) then</tt><tt class=""><br class="">
</tt><tt class=""> tt = time(i) ;-- first
time step where threshold is exceeded</tt><tt class=""><br class="">
</tt><tt class=""> else</tt><tt class=""><br class="">
</tt><tt class=""> tt := array_append_record (tt, time(i), 0)
;-- append next time step </tt></font><font color="#3333ff" class=""><tt class=""><font color="#3333ff" class=""><tt class="">where threshold is exceeded</tt></font></tt><tt class=""><br class="">
</tt><tt class=""> end if</tt><tt class=""><br class="">
</tt><tt class=""> j = j+1</tt><tt class=""><br class="">
</tt><tt class=""> end if </tt><tt class=""><br class="">
</tt><tt class=""> end do</tt><tt class=""><br class="">
</tt><tt class=""><br class="">
</tt><tt class="">;-- convert time to readable date string</tt><tt class=""><br class="">
</tt><tt class=""> utc_date = cd_calendar(tt,
0) ;-- convert date to UT-referenced
date</tt><tt class=""><br class="">
</tt><tt class=""> year =
sprinti("%0.4i",tointeger(utc_date(:,0))) ;-- get year as
integer value</tt><tt class=""><br class="">
</tt><tt class=""> mon =
sprinti("%0.2i",tointeger(utc_date(:,1))) ;-- get month as
integer value</tt><tt class=""><br class="">
</tt><tt class=""> day =
sprinti("%0.2i",tointeger(utc_date(:,2))) ;-- get day as
integer value</tt><tt class=""><br class="">
</tt><tt class=""> str_date =
year+"/"+mon+"/"+day ;-- yyyy/mm/dd</tt><tt class=""><br class="">
</tt><tt class=""> print(str_date)</tt></font><br class="">
<br class="">
<font color="#3333ff" class=""><tt class="">end</tt></font><br class="">
<br class="">
Hope this helps,<br class="">
Karin<br class="">
<br class="">
<br class="">
<div class="moz-cite-prefix">Am 26.04.17 um 07:09 schrieb Lyndon
Mark Olaguera:<br class="">
</div>
<blockquote cite="mid:CA+V+8dUd+Kp8M5X8bBAP1itUET+zaMWNqPCSc8CXQkyaZ331EQ@mail.gmail.com" type="cite" class="">
<div dir="ltr" class="">Dear fellow NCL users,
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">I would like to extract the "date" when any grid point in a
domain exceeds a threshold value using NCL (daily time steps).
I tried to create a netcdf file of daily vorticity using the
script below.</div>
<div class=""><br class="">
</div>
<div class="">I would like to add a line in this script that will extract
the date (day month year) whenever a grid point from this
domain is exceeded:</div>
<div class=""> LAT : 7.5N to 27.5N</div>
<div class=""> LON : 110E to 135E</div>
<div class=""><br class="">
</div>
<div class="">the threshold value that I am using is 3e-5 per second.</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">I am attaching the netcdf file and the image in this
email.
<div class="gmail_chip gmail_drive_chip" style="width:396px;height:18px;max-height:18px;background-color:rgb(245,245,245);padding:5px;color:rgb(34,34,34);font-family:arial;font-style:normal;font-weight:bold;font-size:13px;border:1px
solid rgb(221,221,221);line-height:1"><a moz-do-not-send="true" href="https://drive.google.com/file/d/0B9faET7Bc2o8RWRXcTdKZEx0YlE/view?usp=drive_web" target="_blank" style="display:inline-block;max-width:366px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-decoration:none;padding:1px
0;border:none" class=""><img moz-do-not-send="true" style="vertical-align: bottom; border: none;" src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png" class=""> <span dir="ltr" style="color:rgb(17,85,204);text-decoration:none;vertical-align:bottom" class="">test_2003_30.png</span></a><img moz-do-not-send="true" src="x-msg://ssl.gstatic.com/ui/v1/icons/common/x_8px.png" style="opacity: 0.55; cursor: pointer; float: right;
position: relative; top: -1px; display: none;" class=""></div>
</div>
<div class=""><br class="">
</div>
<div class="">Is this possible in NCL?</div>
<div class="">Is there any function in NCL that can extract values from
every gridpoint in a specified domain?</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">I'll appreciate if anyone can point me to the right
direction/functions to implement this in NCL.</div>
<div class=""><br class="">
</div>
<div class="">Many thanks in advance!</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">begin</div>
<div class="">;************************************************</div>
<div class="">; variable and file handling</div>
<div class="">;************************************************</div>
<div class=""> ufile = addfile("uwind_may_2003_700hPa.nc","r")
; open netcdf file</div>
<div class=""> u = ufile->uwnd(:,0,:,:)
; pull u off file</div>
<div class=""> lat = ufile->lat</div>
<div class=""> lon = ufile->lon</div>
<div class=""> vfile = addfile("vwind_may_2003_700hPa.nc","r")</div>
<div class=""> v = vfile->vwnd(:,0,:,:)
; pull v off file</div>
<div class="">;************************************************</div>
<div class="">; calculate vorticity on a Gaussian Grid</div>
<div class="">;************************************************
</div>
<div class=""> ;vrt = u ;
retain coordinates</div>
<div class=""> ;vrt = uv2vrG_Wrap(u,v)</div>
<div class=""> vr = uv2vr_cfd (u,v,lat,lon, 3)</div>
<div class=""> copy_VarMeta(u,vr)</div>
<div class=""> vr@long_name = "vorticity"</div>
<div class=""> vr@units = "per second"</div>
<div class="">;***********************************************</div>
<div class="">; save to a netcdf file</div>
<div class="">;***********************************************</div>
<div class=""> ncdf = addfile("vort_700hPa.nc","c")</div>
<div class=""> fAtt = True</div>
<div class=""> fAtt@title = "Vorticity at 700hPa"</div>
<div class=""> fAtt@source_file = "daily winds from NCEP-NCAR
Reanaysis"</div>
<div class=""> fAtt@Conventions = "None"</div>
<div class=""> fAtt@creation_date = systemfunc("date")</div>
<div class=""> fileattdef(ncdf,fAtt) ; copy file attributes</div>
<div class=""> filedimdef(ncdf,"time",-1,True)</div>
<div class=""> ncdf->vr = vr</div>
<div class="">end</div>
</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">
<div class="gmail_signature">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div class=""><font face="comic sans ms, sans-serif" class=""><b class=""><u class="">Lyndz</u></b></font></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br class="">
<fieldset class="mimeAttachmentHeader"></fieldset>
<br class="">
<pre wrap="" class="">_______________________________________________
ncl-talk mailing list
<a class="moz-txt-link-abbreviated" href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>
List instructions, subscriber options, unsubscribe:
<a class="moz-txt-link-freetext" href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a>
</pre>
</blockquote>
</div>
_______________________________________________<br class="">ncl-talk mailing list<br class=""><a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br class="">List instructions, subscriber options, unsubscribe:<br class="">http://mailman.ucar.edu/mailman/listinfo/ncl-talk<br class=""></div></blockquote></div><br class=""></div></div></body></html>