[ncl-talk] Time Vs Lat/Lon

Kunal Bali kunal.bali9 at gmail.com
Thu Nov 1 13:30:42 MDT 2018


Dear Phillips Sir,
Thanks for all the suggestions.
I tried your suggestion but still not sorted out.
and
according to the given link
https://www.ncl.ucar.edu/Document/Language/error_messages.shtml#AssignMismatch

it's a common error and can be remove using reassignment operator, or *delete
<https://www.ncl.ucar.edu/Document/Functions/Built-in/delete.shtml> *
 So, I tried this but still getting the same error.

---
Kunal Bali






On Fri, Nov 2, 2018 at 12:20 AM Adam Phillips <asphilli at ucar.edu> wrote:

> Hi Kunal,
> The error message is telling you what the issue is.
> Assignment type mismatch, right hand side can't be coerced to type of left
> hand side.
> Looking at the offending line: time_min(gg,hh)  = time(arr_min(gg,hh))
> the error message is saying you are attempting to pass (say) a double
> value from the right side into an array of type float on the left hand
> side.
>
> To fix this sort of thing you can use the to* functions, so taking my
> example above:
> time_min(gg,hh)  = (/ tofloat(time(arr_min(gg,hh))) /)
>
> Note though that you will have to look at your own data and verify what
> the situation is for each array.
> Adam
>
> On Thu, Nov 1, 2018 at 12:06 PM Kunal Bali <kunal.bali9 at gmail.com> wrote:
>
>> I tried as
>>
>>     arr_min = *dim_minind* ( arr(time|:, lat|:, lon|:),0 )
>>     printVarSummary(arr_min)
>>     printMinMax(arr_min,0)
>>
>>     arr_max = *dim_minind* ( arr(time|:, lat|:, lon|:),0 )
>>     printVarSummary(arr_max)
>>     printMinMax(arr_max,0)
>>
>>     time_min = arr_min    ; arr_min contains the indices that were the
>> minimum at each lat/lon point
>>     time_max = arr_max
>>     printVarSummary(time_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
>>
>> error comes at red line
>>
>> Assignment type mismatch, right hand side can't be coerced to type of
>> left hand side
>>
>>
>> ---
>> Kunal Bali
>>
>>
>>
>>
>>
>> On Thu, Nov 1, 2018 at 9:13 PM Adam Phillips <asphilli at ucar.edu> wrote:
>>
>>> Hi Kunal,
>>> In NCL v6.5.0 you can specify -4 as the 2nd option in cd_calendar. It
>>> returns results that are the same as if you specify 0, so try specifying 0.
>>>
>>> Again, you need to use dim_minind
>>> <https://www.ncl.ucar.edu/Document/Functions/Contributed/dim_minind.shtml>
>>> and dim_maxind
>>> <https://www.ncl.ucar.edu/Document/Functions/Contributed/dim_maxind.shtml> to
>>> return the index of the minimum (/maximum) value, and not dim_max/dim_min.
>>> The latter two functions return the minimum and maximum values. You the
>>> indices to plug them into your time array within the double do loop I sent
>>> earlier.
>>> Adam
>>>
>>> On Thu, Nov 1, 2018 at 12:31 AM Kunal Bali <kunal.bali9 at gmail.com>
>>> wrote:
>>>
>>>> I tried this but not working
>>>>
>>>>     arr    = a->BCSMASS
>>>>     lat    = a->lat
>>>>     lon    = a->lon
>>>>
>>>>     printVarSummary(arr)
>>>>     timeT = cd_calendar(arr&time,-4)   [==> *getting a warning*:cd_calendar:
>>>> Unknown option, defaulting to 0.]
>>>>     time = timeT(:,3)
>>>>
>>>>     ;arr_min = dim_min( arr(lat|:, lon|:, time|:) )
>>>>     ;printVarSummary(arr_min)
>>>>     ;printMinMax(arr_min,0)
>>>>
>>>>     ;arr_max = dim_max( arr(lat|:, lon|:, time|:) )
>>>>     ;printVarSummary(arr_max)
>>>>     ;printMinMax(arr_max,0)
>>>>
>>>>     ;time_min = arr_min    ; arr_min contains the indices that were the
>>>> minimum at each lat/lon point
>>>>     ;time_max = arr_max
>>>>     ;printVarSummary(time_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
>>>>
>>>> ---
>>>> Kunal Bali
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Thu, Nov 1, 2018 at 3:05 AM Adam Phillips <asphilli at ucar.edu> wrote:
>>>>
>>>>> 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>
>>>>>
>>>> _______________________________________________
>>>> 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/20181102/5a95d768/attachment.html>


More information about the ncl-talk mailing list