[ncl-talk] 3 dimensions to 2 dimensions

Soma Roy somaroy892 at gmail.com
Wed May 1 07:18:55 MDT 2019


The question make no sense to me.

I think user is trying to plot hovmullar.
Otherwise, trying to make individual output files over lat-lon
corresponding to each time steps and save as desired file format.

User should use sum/avg. function available in ncl to implement the same
over any dimention..to reduce data from 3D to 2D.

Best,
Soma

On Wed, May 1, 2019, 09:35 Dennis Shea <shea at ucar.edu> wrote:

> Like Rick, I am finding your description(s) difficult  to follow. Maybe:
>
> *https://www.ncl.ucar.edu/Document/Functions/Built-in/reshape.shtml*
> <https://www.ncl.ucar.edu/Document/Functions/Built-in/reshape.shtml>
>
> TRMM(time,lat,lon)      ==> (ntim,nlat,mlon)
>
>   T2D = *reshape*(TRMM, (/ntim,nlat*mlon/))
>   *copy_VarCoords*(TRMM(:,0,0), T2D)
>   T2D!1 = "pts"
>   *printVarSummary*(T2D)
>
>  T2D_TimeLat = TRMM(:,:,0)
>  *printVarSummary*(T2D_TimeLat)
>
>  T2D_TimeLon = TRMM(:,0,:)
> * printVarSummary*(T2D)
>
>
>
> On Tue, Apr 30, 2019 at 9:27 PM Md. Jalal Uddin <dmjalal90 at gmail.com>
> wrote:
>
>> Is there any function that makes 3 dimensions to 2 dimensions array like
>> ndtooned
>>
>> On Wed, May 1, 2019 at 11:23 AM Md. Jalal Uddin <dmjalal90 at gmail.com>
>> wrote:
>>
>>> What is it you really intend here -- a sum over time, or an average?
>>>
>>> I don't want to sum or average. I want to take the whole temporal value
>>> at each lat and lon and make a two dimensions Rain from three dimensions
>>> TRMM.
>>>
>>> On Wed, May 1, 2019 at 11:17 AM Rick Brownrigg <brownrig at ucar.edu>
>>> wrote:
>>>
>>>> Well, there are still two problems with that innermost nested loop:
>>>>
>>>> i)  What is the value of the 1st (zero-th) index value into TRMM on the
>>>> first iteration of that loop?
>>>> do nt=0,ntim-1
>>>> Rain(nl,ml) = TRMM(nt-1,nl,ml)  ; Subscript out of range, error in
>>>> subscript #0
>>>>
>>>> ii) again, this loop is overwriting the value of Rain(nl,ml)
>>>> repeatedly, for "ntim" times, only to end up with Rain(nl,ml) containing
>>>> the value TRMM(ntim-1,nl,ml) by the time the innermost loop exits. What is
>>>> it you really intend here -- a sum over time, or an average?
>>>>
>>>> I really don't know at all about the second set of errors from
>>>> copy_VarMeta -- it seems like some dimensionality requirement between
>>>> copy_from and copy_to is getting violated, but I don't have the full
>>>> picture. See the docs for discussion on requirements on the "leftmost
>>>> dimensions":
>>>>
>>>> http://ncl.ucar.edu/Document/Functions/Contributed/copy_VarMeta.shtml
>>>>
>>>> Perhaps get that inner loop correct and the rest may sort itself out....
>>>>
>>>> Rick
>>>>
>>>>
>>>> On Tue, Apr 30, 2019 at 8:42 PM Md. Jalal Uddin <dmjalal90 at gmail.com>
>>>> wrote:
>>>>
>>>>> Hi Rick,
>>>>> Now, I am getting the following errors (Highlight in red color).
>>>>>
>>>>>   f = addfile("bob_vscs.nc","r")
>>>>>   time =f->time
>>>>>   lat =f->latitude
>>>>>   lon =f->longitude
>>>>>   ntim = dimsizes(time)
>>>>>   nlat = dimsizes(lat)
>>>>>   nlon = dimsizes(lon)
>>>>>   TRMM = f->pcp(:,{0:30},{75:100})        ;TRMM(time, latitude,
>>>>> longitude)
>>>>>
>>>>>   Rain =new((/nlat,nlon/),"float")
>>>>>
>>>>>     do nl=0,nlat-1
>>>>>      do ml=0,nlon-1
>>>>> do nt=0,ntim-1
>>>>> Rain(nl,ml) = TRMM(nt-1,nl,ml)  ; Subscript out of range, error in
>>>>> subscript #0
>>>>> end do
>>>>> end do
>>>>>     end do
>>>>>   copy_VarMeta(TRMM(0,:,:),Rain)    ; fatal:Coordinate variables must
>>>>> be the same dimension as their dimension    fatal:No coordinate variable
>>>>> exists for dimension (longitude) in variable (var_to)
>>>>>
>>>>> Variable: TRMM
>>>>> Type: float
>>>>> Total Size: 18720000 bytes
>>>>>             4680000 values
>>>>> Number of Dimensions: 3
>>>>> Dimensions and sizes:   [time | 390] x [latitude | 120] x [longitude |
>>>>> 100]
>>>>> Coordinates:
>>>>>             time: [   0..119208]
>>>>>             latitude: [0.125..29.875]
>>>>>             longitude: [75.125..99.875]
>>>>> Number Of Attributes: 7
>>>>>   long_name :   precipitation (mm/hr)
>>>>>   _FillValue :  -9999.9
>>>>>   missing_value :       -9999.9
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Tue, Apr 30, 2019 at 8:48 PM Rick Brownrigg <brownrig at ucar.edu>
>>>>> wrote:
>>>>>
>>>>>> HI,
>>>>>>
>>>>>> It looks like there may be several problems going here:
>>>>>>
>>>>>> i) I speculate you mean something more like this:
>>>>>>   time =f->time
>>>>>>   lat =f->latitude
>>>>>>   lon =f->longitude
>>>>>>   ntim = dimsizes(time)
>>>>>>   nlat = dimsizes(lat)
>>>>>>   nlon = dimsizes(lon)
>>>>>>
>>>>>> ii) I'm not sure the intent here:
>>>>>>
>>>>>>    Rain(nl,ml) = TRMM(nt,nl,ml)
>>>>>>
>>>>>> Each time through the inner loop, it will (re)assign the one by one
>>>>>> "nt" values of TRMM to the same element of Rain(nl, ml), exiting the loop
>>>>>> with it set to the "nt-1"th value. Its equivalent to foregoing the entire
>>>>>> inner loop and just saying Rain(nl,ml) = TRMM(nt-1,nl,ml)
>>>>>>
>>>>>> Hope that helps,
>>>>>> Rick
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Tue, Apr 30, 2019 at 4:00 AM Md. Jalal Uddin <dmjalal90 at gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>> Hi all,
>>>>>>>
>>>>>>> I have tried to take all rainfall data  for each latitude and
>>>>>>> longitude point and made 2 dimensions from 3 dimensions. I am getting the
>>>>>>> following errors.
>>>>>>> fatal:_NclBuildArray: each element of a literal array must have the
>>>>>>> same dimension sizes, at least one item doesn't
>>>>>>>
>>>>>>> The main code:
>>>>>>>
>>>>>>> f = addfile("bob_vscs.nc","r")
>>>>>>>   ntim =f->time
>>>>>>>   nlat =f->latitude
>>>>>>>   nlon =f->longitude
>>>>>>>   TRMM = f->pcp(:,{0:30},{75:100})        ;TRMM(time 390, latitude
>>>>>>> 120, longitude 100)
>>>>>>>
>>>>>>>   Rain =new((/nlat,nlon/),"float")
>>>>>>>
>>>>>>>     do nl=0,nlat-1
>>>>>>>      do ml=0,nlon-1
>>>>>>> do nt=0,ntim-1
>>>>>>> Rain(nl,ml) = TRMM(nt,nl,ml)
>>>>>>> end do
>>>>>>> end do
>>>>>>>     end do
>>>>>>>
>>>>>>> Could you help me to solve the problem, please?
>>>>>>>
>>>>>>> Best Regards,
>>>>>>> Jalal
>>>>>>> --
>>>>>>> *Md. Jalal Uddin*
>>>>>>> MSc in Applied Meteorology (English Language)
>>>>>>> Nanjing University of Information, Science and Technology, China
>>>>>>> B.Sc. in Disaster Management (Hons.)
>>>>>>> Patuakhali Science and Technology University, Bangladesh.
>>>>>>> Cell: +8613260859092, +8801792052662
>>>>>>> Web: www.dmjalal90.weebly.com
>>>>>>> Facebook: jalal.hossen.39
>>>>>>> LinkedIn: https://bd.linkedin.com/in/md-jalal-uddin-80a026b0
>>>>>>> Twitter: dmjalal90
>>>>>>> Skype: dmjalal90
>>>>>>> _______________________________________________
>>>>>>> ncl-talk mailing list
>>>>>>> ncl-talk at ucar.edu
>>>>>>> List instructions, subscriber options, unsubscribe:
>>>>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> *Md. Jalal Uddin*
>>>>> MSc in Applied Meteorology (English Language)
>>>>> Nanjing University of Information, Science and Technology, China
>>>>> B.Sc. in Disaster Management (Hons.)
>>>>> Patuakhali Science and Technology University, Bangladesh.
>>>>> Cell: +8613260859092, +8801792052662
>>>>> Web: www.dmjalal90.weebly.com
>>>>> Facebook: jalal.hossen.39
>>>>> LinkedIn: https://bd.linkedin.com/in/md-jalal-uddin-80a026b0
>>>>> Twitter: dmjalal90
>>>>> Skype: dmjalal90
>>>>>
>>>>
>>>
>>> --
>>> *Md. Jalal Uddin*
>>> MSc in Applied Meteorology (English Language)
>>> Nanjing University of Information, Science and Technology, China
>>> B.Sc. in Disaster Management (Hons.)
>>> Patuakhali Science and Technology University, Bangladesh.
>>> Cell: +8613260859092, +8801792052662
>>> Web: www.dmjalal90.weebly.com
>>> Facebook: jalal.hossen.39
>>> LinkedIn: https://bd.linkedin.com/in/md-jalal-uddin-80a026b0
>>> Twitter: dmjalal90
>>> Skype: dmjalal90
>>>
>>
>>
>> --
>> *Md. Jalal Uddin*
>> MSc in Applied Meteorology (English Language)
>> Nanjing University of Information, Science and Technology, China
>> B.Sc. in Disaster Management (Hons.)
>> Patuakhali Science and Technology University, Bangladesh.
>> Cell: +8613260859092, +8801792052662
>> Web: www.dmjalal90.weebly.com
>> Facebook: jalal.hossen.39
>> LinkedIn: https://bd.linkedin.com/in/md-jalal-uddin-80a026b0
>> Twitter: dmjalal90
>> Skype: dmjalal90
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190501/8f972f6e/attachment.html>


More information about the ncl-talk mailing list