[ncl-talk] Time Vs Lat/Lon

Adam Phillips asphilli at ucar.edu
Wed Oct 31 15:35:17 MDT 2018


Hi Kunal,
Note that I recommended using dim_minind/dim_maxind, and not minind/maxind.
Looking at the file you attached, you would pass your BCSMASS array into
those two functions, and operate on the time (0) dimension. As previously
stated, that will return a 2D array dimensioned lat x lon containing the
desired indices. Then you would apply the double do loop coding I sent to
form arrays of the times themselves.  Again, the time array in my example
coding needs to be set to something that is easily plotted, say the Hour.
You can set up an hour array for your data like this:
a = addfile("hourmean.nc","r")
arr = a->BCSMASS
timeT = cd_calendar(arr&time,-4)
time = timeT(:,3)

Adam

On Tue, Oct 30, 2018 at 12:02 PM Kunal Bali <kunal.bali9 at gmail.com> wrote:

> Thanks for this informations.
>
> I tried to get min mad max by using the link which you mentioned, but the
> error comes with fatal:Argument type mismatch on argument (0) of (maxind)
> can not coerce
>
> I also tried the code given below but facing the same error here.
> (version-NCL 6.4.0)
>
> dims = *dimsizes* <https://www.ncl.ucar.edu/Document/Functions/Built-in/dimsizes.shtml>(X)
>   x1d = *ndtooned* <https://www.ncl.ucar.edu/Document/Functions/Built-in/ndtooned.shtml>(X)      ; convert 2D array to 1D for use in maxind
>   inds = *ind_resolve* <https://www.ncl.ucar.edu/Document/Functions/Built-in/ind_resolve.shtml>(*maxind* (x1d), dims)    ; convert 1D array back to 2D
>   ilat = inds(0,0)        ; select the latitude index where the X array is at its' maximum
>   ilon = inds(0,1)        ; select the longitude index where the X array is at its' maximum
>   lat_max = X&lat(ilat)   ; insert the latitude index into the lat coordinate variable
>   lon_max = X&lon(ilon)   ; insert the longitude index into the lon coordinate variable
>   *print* <https://www.ncl.ucar.edu/Document/Functions/Built-in/print.shtml>("Maximum value located at "+lat_max+", "+lon_max)
>
> I also attached one sample file, in case if you need it.
>
>
> ---
> Kunal Bali
>
>
>
>
>
>
> On Tue, Oct 30, 2018 at 2:47 AM Adam Phillips <asphilli at ucar.edu> wrote:
>
>> Hi Kunal,
>> If I understand correctly what you are after, you'd like to plot the time
>> (at each grid point) where the maximum (or minimum) value occurs.
>> This will likely take some trial and error on your part. Here's what I
>> think you need to do:
>> 1) Use dim_minind and dim_maxind to isolate the index where the grid
>> point value is at its min/max.
>> https://www.ncl.ucar.edu/Document/Functions/Contributed/dim_maxind.shtml
>> https://www.ncl.ucar.edu/Document/Functions/Contributed/dim_minind.shtml
>>
>> This will result in a 2-D array (dimensioned lat x lon) containing the
>> minimum indices, and the same type of array containing the maximum indices.
>>
>> 2)  There might be a more elegant way to map the indexes onto the correct
>> times, but the following double do loop over the lat/lon dimensions will
>> work:
>>
>> ; time is an array of your times
>> time_min = arr_min    ; arr_min contains the indices that were the
>> minimum at each lat/lon point
>> time_max = arr_max
>> do gg = 0,dimsizes(arr_min&lat)-1
>>      do hh = 0,dimsizes(arr_min&lon)-1
>>           time_min(gg,hh) = time(arr_min(gg,hh))
>>           time_max(gg,hh) = time(arr_max(gg,hh))
>>      end do
>> end do
>>
>> You will want to make sure that your time array is in a format that is
>> conducive to being plotted. (18:30 doesn't work for instance, but 1830
>> would.)
>> I think that's it. Try starting with the above suggestions and see if you
>> can get things to work. If you have further questions about this subject
>> please reply to the ncl-talk email list.
>> Adam
>>
>>
>>
>> On Mon, Oct 29, 2018 at 6:57 AM Kunal Bali <kunal.bali9 at gmail.com> wrote:
>>
>>> Dear NCL users,
>>>
>>> I have one file (2000-2017) with time, latitude, longitude and
>>> variable. The time is given in hours(00:30 to 18:30). I need to plot a
>>> spatial map of hours values at each grid cells, the contour map of hours
>>> values should correspond to the variable values. So that I can see which
>>> hour has high and low-value on the map. Some examples are given for time vs
>>> latitude and time vs longitude, I don't need that.  I need to plot time vs
>>> latitude longitude.
>>>
>>> I hope you got my point.
>>> Any information on that?
>>>
>>> Thank You
>>> ---
>>> Kunal Bali
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>
>>
>> --
>> Adam Phillips
>> Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
>> www.cgd.ucar.edu/staff/asphilli/   303-497-1726
>>
>> <http://www.cgd.ucar.edu/staff/asphilli>
>>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>


-- 
Adam Phillips
Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
www.cgd.ucar.edu/staff/asphilli/   303-497-1726

<http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20181031/ed791d4b/attachment.html>


More information about the ncl-talk mailing list