[ncl-talk] Dimension size mismatch

Md. Jalal Uddin dmjalal90 at gmail.com
Sun Aug 11 19:31:30 MDT 2019


It works now. Thank you, sir.

On Sat, 10 Aug 2019 at 17:10, Rashed Mahmood <rashidcomsis at gmail.com> wrote:

> I see, since the variable " * tc1_land_MASK* " is not being reassigned or
> deleted at the end of each loop iteration, I would expect that error since
> your lat and lon are likely to be different in each iteration, so simplest
> solution would be to use the reassignment operator ":=" for the variable
> *tc1_land_MASK*  and also for variable "lsmtc" .
> Second option would be to delete the variables that are not necessary
> after a loop iteration. e.g. just before end do line you could add:
> delete([/tc1_land_MASK, lsmtc/]),  you can possible add more variable to
> this separated by commas. I generally prefer this second option since
> deleting would release some memory next iteration.
>
> General comment: when using loops it is important to keep in mind what
> happens at successive iterations, especially when the variable dimension
> sizes are expected to change in subsequent iterations.
>
>
>
>
>
>
> On Sat, Aug 10, 2019 at 12:44 AM Md. Jalal Uddin <dmjalal90 at gmail.com>
> wrote:
>
>> do nr=0,nRadius-1
>>     do nc=0,nCenter-2
>>        poly_lat := clat(nc,nr,:)
>>        poly_lon := clon(nc,nr,:)
>>
>>        min_lat  = min(poly_lat)
>>        max_lat  = max(poly_lat)
>>        min_lon  = min(poly_lon)
>>        max_lon  = max(poly_lon)
>>
>> ;---Extract the desired rectangle of data
>>
>>        PRC  := tcavg98({min_lat:max_lat},{min_lon:max_lon})
>>
>> ;---Set points that are outside of the circle of data to missing
>>
>>        lat2d := conform(PRC, PRC&latitude, 0)
>>        lon2d := conform(PRC, PRC&longitude, 1)
>>
>>        latlon_circle := gc_inout(lat2d,lon2d, poly_lat,poly_lon)
>>        PRC    = where(latlon_circle,  PRC, PRC at _FillValue)
>>        ;printVarSummary(PRC)
>>
>>     if (nc.eq.0) then
>>
>>                 f_lsm    = addfile("$NCARG_ROOT/lib/ncarg/data/cdf/
>> landsea.nc","r")
>>
>>                      lsmtc   =
>> tobyte(landsea_mask(f_lsm->LSMASK,PRC&latitude,PRC&longitude))
>>                      lsmtc at long_name  = "Land-Sea Mask: TRMM 3B42"
>>                      copy_VarCoords(PRC, lsmtc)
>>
>>                 tc_land_MASK = where(lsmtc.eq.1 .or. lsmtc.eq.2, PRC, PRC at _FillValue)
>> ; Land only
>>                      copy_VarMeta(PRC, lsmtc)
>>                      print("tc_landgrid = "+tc_land_MASK)
>>
>>     else
>>
>>             f_lsm    = addfile("$NCARG_ROOT/lib/ncarg/data/cdf/landsea.nc","r")
>>
>>
>>                      lsmtc1   =
>> tobyte(landsea_mask(f_lsm->LSMASK,PRC&latitude,PRC&longitude))
>>                      lsmtc1 at long_name  = "Land-Sea Mask: TRMM 3B42"
>>                      copy_VarCoords(PRC, lsmtc1)
>>
>>                * tc1_land_MASK = where(lsmtc1.eq.1 .or. lsmtc1.eq.2,
>> PRC, PRC at _FillValue) ; Land only*
>>                      copy_VarMeta(PRC, lsmtc1)
>>                      print("tc1_landgrid = "+tc1_land_MASK)
>> end if
>>
>>     end do   ; nc
>> end do      ; nr
>>
>> From the above green line error has occurred. The full code in the
>> attachment.
>>
>> On Sat, 10 Aug 2019 at 14:27, Rashed Mahmood <rashidcomsis at gmail.com>
>> wrote:
>>
>>> Which line the error message occurs? Generally the printVarSummary() can
>>> be very useful for understanding the dimsize issues.
>>>
>>> On Fri, Aug 9, 2019 at 7:18 PM Md. Jalal Uddin <dmjalal90 at gmail.com>
>>> wrote:
>>>
>>>> Thank you, sir, for your kind suggestion, but it did not work.
>>>>
>>>> On Fri, 9 Aug 2019 at 18:25, Rashed Mahmood <rashidcomsis at gmail.com>
>>>> wrote:
>>>>
>>>>> Hi Jalal,
>>>>> I think the error message is likely related to the lines:
>>>>>
>>>>>   poly_lat = clat(nc,nr,:)
>>>>>   poly_lon = clon(nc,nr,:)
>>>>>
>>>>> Changed those to:
>>>>>   poly_lat * :=* clat(nc,nr,:)
>>>>>   poly_lon* :=* clon(nc,nr,:)
>>>>>
>>>>> hope that helps.
>>>>>
>>>>> Rashed
>>>>>
>>>>>
>>>>> On Thu, Aug 8, 2019 at 6:39 PM Md. Jalal Uddin via ncl-talk <
>>>>> ncl-talk at ucar.edu> wrote:
>>>>>
>>>>>>  do nr=0,nRadius-1
>>>>>>     do nc=0,nCenter-1
>>>>>>        poly_lat = clat(nc,nr,:)
>>>>>>        poly_lon = clon(nc,nr,:)
>>>>>>
>>>>>>        min_lat  = min(poly_lat)
>>>>>>        max_lat  = max(poly_lat)
>>>>>>        min_lon  = min(poly_lon)
>>>>>>        max_lon  = max(poly_lon)
>>>>>>
>>>>>> ;---Extract the desired rectangle of data
>>>>>>
>>>>>>        PRC  := jancont({min_lat:max_lat},{min_lon:max_lon})
>>>>>>
>>>>>> ;---Set points that are outside of the circle of data to missing
>>>>>>
>>>>>>        lat2d := conform(PRC, PRC&latitude, 0)
>>>>>>        lon2d := conform(PRC, PRC&longitude, 1)
>>>>>>
>>>>>>        latlon_circle := gc_inout(lat2d,lon2d, poly_lat,poly_lon)
>>>>>>        PRC    = where(latlon_circle,  PRC, PRC at _FillValue)
>>>>>> end do
>>>>>> end do
>>>>>>
>>>>>>
>>>>>> Here, when center lat changed (nc), the dimension size of PRC also
>>>>>> changed that means PRC has different size. Similar to
>>>>>> http://www.ncl.ucar.edu/Applications/Scripts/polyg_29.ncl
>>>>>>
>>>>>> I tried to mask overland for PRC data but failed because of different
>>>>>> dimension sizes.
>>>>>>
>>>>>> How can I make PRC as the same size? Any suggestions would be
>>>>>> appreciated.
>>>>>>
>>>>>> Jalal
>>>>>> --
>>>>>> *Md. Jalal Uddin*
>>>>>> MSc in Applied Meteorology
>>>>>> 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
>>>>>> _______________________________________________
>>>>>> 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
>>>> 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
>>>>
>>>
>>
>> --
>> *Md. Jalal Uddin*
>> MSc in Applied Meteorology
>> 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
>>
>

-- 
*Md. Jalal Uddin*
MSc in Applied Meteorology
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190812/45152a25/attachment.html>


More information about the ncl-talk mailing list