<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. &nbsp;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="">&nbsp; f = addfile("vort_700hPa.nc","r") &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;-- open file</div><div class=""><br class=""></div><div class="">&nbsp; vr = f-&gt;vr &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;-- read variable</div><div class="">&nbsp;&nbsp;</div><div class="">&nbsp; time = f-&gt;time &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;-- read time</div><div class="">&nbsp; ntimes = dimsizes(time) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;-- get size of time</div><div class=""><br class=""></div><div class="">;-- define sub-region</div><div class="">&nbsp; lat0 = &nbsp; 7.5</div><div class="">&nbsp; lat1 = &nbsp;27.5</div><div class="">&nbsp; lon0 = &nbsp;11.0</div><div class="">&nbsp; lon1 = 135.0</div><div class="">&nbsp;&nbsp;</div><div class="">&nbsp; vr_region = vr(:,{lat0:lat1},{lon0:lon1}) &nbsp; &nbsp; &nbsp;;-- select the data of the sub-region</div><div class="">&nbsp; printVarSummary(vr_region)</div><div class=""><br class=""></div><div class="">&nbsp; threshold = 3e-5 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;-- define threshold</div><div class=""><br class=""></div><div class="">&nbsp; vr_max = dim_max_n(vr_region, (/1,2/)) &nbsp; &nbsp; ;; max over lat/lon per time.&nbsp;</div><div class="">&nbsp; time_inds = ind(vr_max .ge. threshold) &nbsp; &nbsp; &nbsp; ;; &nbsp;if the max isn’t greater than threshold then no values are.&nbsp;</div><div class=""><br class=""></div><div class="">&nbsp; if(all(ismissing(time_inds)))</div><div class="">&nbsp; &nbsp; print("No Times exceed threshold")</div><div class="">&nbsp; &nbsp; status_exit(1)</div><div class="">&nbsp; end if</div><div class=""><br class=""></div><div class="">&nbsp; times = time(time_inds)</div><div class="">&nbsp; print(cd_string(times, ""))</div><div class="">end</div><div class=""><br class=""></div><div class="">&nbsp;&nbsp;</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 &lt;<a href="mailto:meier-fleischer@dkrz.de" class="">meier-fleischer@dkrz.de</a>&gt; 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="">&nbsp; f =
        addfile("vort_700hPa.nc","r")&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;-- open file</tt><tt class=""><br class="">
      </tt><tt class=""><br class="">
      </tt><tt class="">&nbsp; vr = f-&gt;vr&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;--
        read variable</tt><tt class=""><br class="">
      </tt><tt class="">&nbsp; </tt><tt class=""><br class="">
      </tt><tt class="">&nbsp; time = f-&gt;time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;--
        read time</tt><tt class=""><br class="">
      </tt><tt class="">&nbsp; ntimes = dimsizes(time)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;-- 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="">&nbsp; lat0 =&nbsp;&nbsp; 7.5</tt><tt class=""><br class="">
      </tt><tt class="">&nbsp; lat1 =&nbsp; 27.5</tt><tt class=""><br class="">
      </tt><tt class="">&nbsp; lon0 =&nbsp; 11.0</tt><tt class=""><br class="">
      </tt><tt class="">&nbsp; lon1 = 135.0</tt><tt class=""><br class="">
      </tt><tt class="">&nbsp; </tt><tt class=""><br class="">
      </tt><tt class="">&nbsp; vr_region = vr(:,{lat0:lat1},{lon0:lon1})&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;--
        select the data of the sub-region</tt><tt class=""><br class="">
      </tt><tt class="">&nbsp; printVarSummary(vr_region)</tt><tt class=""><br class="">
      </tt><tt class=""><br class="">
      </tt><tt class="">&nbsp; threshold = 3e-5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;--
        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="">&nbsp; j = 0</tt><tt class=""><br class="">
      </tt><tt class="">&nbsp; do i=0,ntimes-1</tt><tt class=""><br class="">
      </tt><tt class="">&nbsp;&nbsp;&nbsp;&nbsp; tmp := ndtooned(vr_region(i,:,:))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;--
        convert to 1d array</tt><tt class=""><br class="">
      </tt><tt class="">&nbsp;&nbsp;&nbsp;&nbsp; if(any(tmp .ge. threshold)) then</tt><tt class=""><br class="">
      </tt><tt class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(j .eq. 0) then</tt><tt class=""><br class="">
      </tt><tt class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tt = time(i)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;-- first
        time step where threshold is exceeded</tt><tt class=""><br class="">
      </tt><tt class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else</tt><tt class=""><br class="">
      </tt><tt class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tt := array_append_record (tt, time(i), 0)&nbsp;
        ;-- 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="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end if</tt><tt class=""><br class="">
      </tt><tt class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; j = j+1</tt><tt class=""><br class="">
      </tt><tt class="">&nbsp;&nbsp;&nbsp;&nbsp; end if </tt><tt class=""><br class="">
      </tt><tt class="">&nbsp; 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="">&nbsp; utc_date&nbsp;&nbsp; = cd_calendar(tt,
        0)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;-- convert date to UT-referenced
        date</tt><tt class=""><br class="">
      </tt><tt class="">&nbsp; year&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
        sprinti("%0.4i",tointeger(utc_date(:,0)))&nbsp;&nbsp; ;-- get year as
        integer value</tt><tt class=""><br class="">
      </tt><tt class="">&nbsp; mon&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
        sprinti("%0.2i",tointeger(utc_date(:,1)))&nbsp;&nbsp; ;-- get month as
        integer value</tt><tt class=""><br class="">
      </tt><tt class="">&nbsp; day&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
        sprinti("%0.2i",tointeger(utc_date(:,2)))&nbsp;&nbsp; ;-- get day as
        integer value</tt><tt class=""><br class="">
      </tt><tt class="">&nbsp; str_date&nbsp;&nbsp; =
        year+"/"+mon+"/"+day&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;-- yyyy/mm/dd</tt><tt class=""><br class="">
      </tt><tt class="">&nbsp; 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="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LAT : 7.5N to 27.5N</div>
        <div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 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="">&nbsp;<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="">&nbsp; ufile &nbsp;= addfile("uwind_may_2003_700hPa.nc","r") &nbsp; &nbsp; &nbsp;
            ; open netcdf file</div>
          <div class="">&nbsp; u &nbsp; = ufile-&gt;uwnd(:,0,:,:) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            &nbsp; ; pull u off file</div>
          <div class="">&nbsp; lat = ufile-&gt;lat</div>
          <div class="">&nbsp; lon = ufile-&gt;lon</div>
          <div class="">&nbsp; vfile &nbsp;= addfile("vwind_may_2003_700hPa.nc","r")</div>
          <div class="">&nbsp; v &nbsp; = vfile-&gt;vwnd(:,0,:,:) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            &nbsp; ; pull v off file</div>
          <div class="">;************************************************</div>
          <div class="">; calculate vorticity on a Gaussian Grid</div>
          <div class="">;************************************************ &nbsp; &nbsp; &nbsp;
            &nbsp;&nbsp;</div>
          <div class="">&nbsp; ;vrt &nbsp; = u &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;
            retain coordinates</div>
          <div class="">&nbsp; ;vrt &nbsp; = uv2vrG_Wrap(u,v)</div>
          <div class="">&nbsp; vr = uv2vr_cfd (u,v,lat,lon, 3)</div>
          <div class="">&nbsp; copy_VarMeta(u,vr)</div>
          <div class="">&nbsp; vr@long_name = "vorticity"</div>
          <div class="">&nbsp; vr@units &nbsp; &nbsp; = "per second"</div>
          <div class="">;***********************************************</div>
          <div class="">; save to a netcdf file</div>
          <div class="">;***********************************************</div>
          <div class="">&nbsp; ncdf = addfile("vort_700hPa.nc","c")</div>
          <div class="">&nbsp; fAtt = True</div>
          <div class="">&nbsp; fAtt@title &nbsp; &nbsp; &nbsp; &nbsp; = "Vorticity at 700hPa"</div>
          <div class="">&nbsp; fAtt@source_file &nbsp; = "daily winds from NCEP-NCAR
            Reanaysis"</div>
          <div class="">&nbsp; fAtt@Conventions &nbsp; = "None"</div>
          <div class="">&nbsp; fAtt@creation_date = systemfunc("date")</div>
          <div class="">&nbsp; fileattdef(ncdf,fAtt) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;; copy file attributes</div>
          <div class="">&nbsp; filedimdef(ncdf,"time",-1,True)</div>
          <div class="">&nbsp; ncdf-&gt;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>