[ncl-talk] grid_area_avg

Mary Haley haley at ucar.edu
Fri Oct 27 11:04:28 MDT 2017


Adrian,

Thanks for the information regarding CDO.  FTR, this particular file in
question is actually not a WRF file, but rather an HDF-EOS file (I
believe).  It is on a curvilinear grid, however, so hopefully CDO can
handle this correctly.

You're right that this kind of subsetting is not correct. I don't know if
you followed the whole thread, but either in an earlier message or a
separate message we were trying to point out that subsetting a lat/lon area
can be done in different ways, depending on what you are trying to do.

>From the script I just included, I was trying to visually show what it
means to select two corners of a lat/lon box, when you are dealing with a
curvilinear grid.

We also pointed to this example, which illustrates three kinds of
subsetting in a graphical fashion:

http://www.ncl.ucar.edu/Applications/latlon_subset.shtml#ex10
http://www.ncl.ucar.edu/Applications/Images/wrf_gsn_10_lg.png

As we are trying to point out, selecting a lat/lon box can have very
different meaning, depending on what you are trying to accomplish, and it
is up to the user to understand what they want. There's also the concept of
passing a lat/lon polygon of any shape, and using gc_inout to do the
subsetting.

When CDO does the subsetting of a curvilinear grid, what exactly is it
selecting? Is there a graphical illustration of what it's doing?

And you are correct there are special situations as you get closer to the
poles, but in this particular case it wasn't clear if the poles were going
to be an issue.

--Mary


On Fri, Oct 27, 2017 at 1:57 AM, Adrian Tompkins <tompkins at ictp.it> wrote:

> dear all,
>
> Sorry to push my nose in here, but I just noticed this discussion chain
> and the advice to average over a set of points using the "avg" function.
>  Mary also suggested early to do this with the following piece of code :
>
>   lats = (/ min_lat, max_lat /)
>   lons = (/ min_lon, max_lon /)
>   nm   = getind_latlon2d (lat2d, lon2d, lats, lons)
>   ilt1 = nm(0,0)  ; start lat index
>   ilt2 = nm(1,0)  ; start lon index
>   iln1 = nm(0,1)  ; end lat index
>   iln2 = nm(1,1)  ; end lon index
>   var_subset = var(ilt1:ilt2,iln1:iln2)
>   var_subset_avg = avg(var_subset)
>
> I just wanted to point out that it is not correct to do this unless you
> have a small area Cartesian grid with regular spacing.  If WRF is being
> used with a lat-lon grid of any kind you need to take account of the
> differing grid sizes as you move towards the poles.  For Kunal's chosen
> area this wouldn't matter as the region desired is very small, but for
> larger regions this is important.
>
> Kunal, to be honest I generally do this kind of operation outside of NCL
> with CDO and then use NCL to make the plots as then you don't need to
> worry about the grid.
>
> For example to extract an area and then average it as you ask to do, you
> could simple do this from the command line:
>
> cdo fldmean -sellonlatbox,lon1,lon2,lat1,lat2 infile.nc outfile.nc
>
> where the lon and lat describe the corners of the box you want to
> select.  Then move to NCL to make the plots...
>
> best wishes, Adrian
>
>
>
>
> On 10/25/17 12:16, Barry Lynn wrote:
> > Kunal:
> >
> > Why don't you extract the grid elements you want and then use the NCL
> > average function to find the mean of those grid points?  You can extract
> > a grid of the size you want or just the points.
> >
> > Barry
> >
> > On Wed, Oct 25, 2017 at 10:07 AM, Kunal Bali <kunal.bali9 at gmail.com
> > <mailto:kunal.bali9 at gmail.com>> wrote:
> >
> >     Thanks for the information. I did not include the time variable. So
> >
> >     I changed aot_subset(ilt1:ilt2,iln1:iln2) =
> >     data(ilt1:ilt2,iln1:iln2) to aot_subset(*:,*ilt1:ilt2,iln1:iln2) =
> >     data(*:,*ilt1:ilt2,iln1:iln2)
> >
> >     AND it worked.
> >
> >
> >     But from the given script, I am not getting the mean value of the
> >     grid box. It producing the values of every grid separately. As given
> >     below
> >
> >     (0)    22.17971308103524   69.17124237598317
> >     (0)         -28672
> >     (1)         0.208
> >     (0)    -----
> >     (0)    24.55800304046942   79.47472902537179
> >     (0)         -28672
> >     (1)         -28672
> >     (0)    -----
> >
> >
> >     I need to extract the data of square box and mean it. so that I can
> >     get the values with every time steps.
> >
> >       latv = (/ 13, 25/)     ; for extracting grid box data
> >       lonv = (/ 72, 85 /)
> >
> >     The script is
> >
> >
> >     ;-----------------------------------------------------------
> -----------
> >     ; Main code
> >     ;-----------------------------------------------------------
> -----------
> >       dir    = "./"
> >       fnames = systemfunc("ls " + dir + "maiactaot*.nc")
> >       print(fnames)
> >       a      = addfile(fnames,"r")
> >       data   = short2flt(a->Optical_Depth_055_grid1km)
> >     printVarSummary (data)
> >     printMinMax (data, 0)
> >     print("-----")
> >       nFill  = num(ismissing(data))
> >     print("nFill="+nFill)
> >     print("-----")
> >
> >       lat2d  = a->GridLat_grid1km
> >       lon2d  = a->GridLon_grid1km
> >     printMinMax (lat2d, 0)
> >     printMinMax (lon2d, 0)
> >     print("-----")
> >
> >     ;---grid points of interest
> >     ;---http://www.ncl.ucar.edu/Document/Functions/
> Contributed/getind_latlon2d.shtml
> >     <http://www.ncl.ucar.edu/Document/Functions/
> Contributed/getind_latlon2d.shtml>
> >      ; latv = (/22, 24.0, 24.0, 22.0, 22.0/)
> >      ; lonv = (/76, 76.0, 78.0, 78.0, 76.0/)
> >
> >       latv = (/ 13, 25/)     ; for extracting grid box data
> >       lonv = (/ 72, 85 /)
> >       nm   = getind_latlon2d (lat2d, lon2d, latv, lonv)
> >       ilt1 = nm(0,0)  ; start lat index
> >       ilt2 = nm(1,0)  ; start lon index
> >       iln1 = nm(0,1)  ; end lat index
> >       iln2 = nm(1,1)  ; end lon index
> >       lat_subset = lat2d(ilt1:ilt2,iln1:iln2)
> >       lon_subset = lon2d(ilt1:ilt2,iln1:iln2)
> >       aot_subset := data
> >       aot_subset = aot_subset at _FillValue
> >       aot_subset(:,ilt1:ilt2,iln1:iln2) = data(:,ilt1:ilt2,iln1:iln2)
> >
> >
> >
> >       printVarSummary(aot_subset)
> >       print("ilt1 = " + ilt1)
> >       print("ilt2 = " + ilt2)
> >       print("iln1 = " + iln1)
> >       print("iln2 = " + iln2)
> >
> >      ; aot_avg = avg(data)
> >       aot_subset_avg = avg(data)
> >
> >       ;print(nm)
> >       print("-----")
> >
> >       do k=0,dimsizes(latv)-1
> >          n = nm(k,0)
> >          m = nm(k,1)
> >          print(lat2d(n,m)+"   "+lon2d(n,m))
> >          print("     "+data(:,n,m))                   ; nearest grid
> >     point at all time steps
> >          print("-----")
> >       end do
> >
> >
> >
> >
> >
> >
> >     Kunal Bali
> >
> >
> >
> >
> >
> >     On Wed, Oct 25, 2017 at 12:25 PM, Barry Lynn <barry.h.lynn at gmail.com
> >     <mailto:barry.h.lynn at gmail.com>> wrote:
> >
> >         Kunal:
> >
> >         The error message says that you have used three subscripts on a
> >         variables with only two dimensions.
> >
> >         You need to fix this error for your script to proceed to the
> >         next step.
> >
> >         Barry
> >
> >         On Wed, Oct 25, 2017 at 8:59 AM, Kunal Bali
> >         <kunal.bali9 at gmail.com <mailto:kunal.bali9 at gmail.com>> wrote:
> >
> >             It also shows an error if I replaced := with = in 38 line of
> >             the given script (attached earlier), even though variable is
> >             in 2D array.
> >
> >             fatal:["Execute.c":7950]:Number of subscripts on
> >             right-hand-side do not match
> >                         number of dimensions of variable: (2),
> >             Subscripts used: (3)
> >
> >             fatal:["Execute.c":8640]:Execute: Error occurred at or near
> >             line 38 in file extract1.ncl
> >
> >
> >
> >             Kunal Bali
> >
> >
> >
> >
> >
> >
> >
> >             On Tue, Oct 24, 2017 at 4:46 PM, Helen Macintyre
> >             <Helen.Macintyre at phe.gov.uk
> >             <mailto:Helen.Macintyre at phe.gov.uk>> wrote:
> >
> >                 You are trying to delete a variable that has not been
> >                 assigned.____
> >
> >                 __ __
> >
> >                 Using “:=” tries to delete aot_subset when it doesn’t
> >                 exist yet. ____
> >
> >                 __ __
> >
> >                 More info here:____
> >
> >                 http://www.ncl.ucar.edu/Document/Language/varb_assign.
> shtml
> >                 <http://www.ncl.ucar.edu/Document/Language/varb_assign.
> shtml>____
> >
> >                 __ __
> >
> >                 __ __
> >
> >                 __ __
> >
> >                 *From:*ncl-talk [mailto:ncl-talk-bounces at ucar.edu
> >                 <mailto:ncl-talk-bounces at ucar.edu>] *On Behalf Of *Kunal
> >                 Bali
> >                 *Sent:* 24 October 2017 06:28
> >                 *To:* ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
> >                 *Subject:* Re: [ncl-talk] grid_area_avg____
> >
> >                 __ __
> >
> >                 I am not able to sort out the query regarding
> >
> >                 fatal:Variable (aot_subset) is undefined
> >                 fatal:["Execute.c":8640]:Execute: Error occurred at or
> >                 near line 38 in file extract1.ncl____
> >
> >                 I have attached my script. please let me know how to
> >                 solve it (the file regarding this script is attached in
> >                 the previous mail). ____
> >
> >                 __ __
> >
> >                 sorry for the inconvenience/. /____
> >
> >                 __ __
> >
> >                 __ __
> >
> >                 regards
> >                 ____
> >
> >                 Kunal Bali____
> >
> >                 __ __
> >
> >                 __ __
> >
> >                 __ __
> >
> >                 __ __
> >
> >                 On Sat, Oct 21, 2017 at 1:53 PM, Kunal Bali
> >                 <kunal.bali9 at gmail.com <mailto:kunal.bali9 at gmail.com>>
> >                 wrote:____
> >
> >                 thanks for providing this information. I am positive
> >                 that the given variable in the data is a 2D array and
> >                 the error is coming on 38 line as I mentioned earlier.
> ____
> >
> >                 I am trying to debug this problem accordingly as you
> >                 mentioned. ____
> >
> >                 However, I have attached the data (size =30mb, tried via
> >                 ftp but facing some error while uploading) and the full
> >                 script for extracting the grid box mean value.  ____
> >
> >                 __ __
> >
> >                 Thank You for all the support.  ____
> >
> >                 ​____
> >
> >                 * maiactaot.h00v02.20010040635-20011550640.nc.bz2
> >                 <https://drive.google.com/file/d/0B6MS-
> JLMHECwaVh3QVVHUU1Wazg/view?usp=drive_web>____*
> >
> >                 ​____
> >
> >
> >                 ____
> >
> >                 Kunal Bali____
> >
> >                 __ __
> >
> >                 __ __
> >
> >                 __ __
> >
> >                 __ __
> >
> >                 __ __
> >
> >                 On Fri, Oct 20, 2017 at 9:14 PM, Mary Haley
> >                 <haley at ucar.edu <mailto:haley at ucar.edu>> wrote:____
> >
> >                 Kunal,____
> >
> >                 __ __
> >
> >                 Multiple people have tried to help you, but you continue
> >                 to post error messages without trying to debug them
> >                 yourself. If you don't make an effort, people are likely
> >                 to stop trying to help. You are including code snippets,
> >                 but this is not always enough for us to help you debug
> >                 the problem. You need to include full scripts, output
> >                 from print/printVarSummary commands, AND all error
> >                 messages.____
> >
> >                 __ __
> >
> >                 For example, you originally included this code:____
> >
> >                 __ __
> >
> >                   latv = (/ 18, 24/)     ; for extracting grid box
> data ____
> >
> >                   lonv = (/ 74, 78 /)____
> >
> >                   nm   = getind_latlon2d (lat2d, lon2d, latv, lonv)____
> >
> >                   ilt1 = nm(0,0)  ; start lat index____
> >
> >                   ilt2 = nm(1,0)  ; start lon index____
> >
> >                   iln1 = nm(0,1)  ; end lat index____
> >
> >                   iln2 = nm(1,1)  ; end lon index____
> >
> >                   lat_subset  := lat2d(ilt1:ilt2,iln1:iln2)____
> >
> >                   lon_subset := lon2d(ilt1:ilt2,iln1:iln2)____
> >
> >                   aot_subset := data____
> >
> >                   aot_subset(ilt1:ilt2,iln1:iln2) := data(ilt1:ilt2,
> >                 iln1:iln2)____
> >
> >                   ____
> >
> >                   ;printVarSummary(aot_subset)____
> >
> >                   aot_avg = avg(data)____
> >
> >                   aot_subset_avg = avg(aot_subset)____
> >
> >                 __ __
> >
> >                 and then said that you were getting an error about
> >                 aot_subset being undefined. From the perspective of
> >                 somebody who is just looking at the code snippet above
> >                 and doesn't have access to your full script, we are
> >                 going to wonder about this line:____
> >
> >                 __ __
> >
> >                   aot_subset := data____
> >
> >                 __ __
> >
> >                 Since this appears to be the first time aot_subset is
> >                 set, our next question is going to be "is data defined"?
> >                 In the code snippet you included, we don't see where
> >                 "data" is defined, so we have no way to help. This is
> >                 where a "printVarSummary(data)" line would have
> helped.____
> >
> >                 __ __
> >
> >                 In your last email, in which you did include some
> >                 information about "data", things are still not making
> >                 any sense. You said you were subsetting data as a 2D
> >                 array with:____
> >
> >                 __ __
> >
> >                 aot_subset(ilt1:ilt2,iln1:iln2) =
> >                 data(ilt1:ilt2,iln1:iln2)____
> >
> >                 __ __
> >
> >                 which you said was causing this error:____
> >
> >                 __ __
> >
> >                 fatal:["Execute.c":7950]:Number of subscripts on
> >                 right-hand-side do not match____
> >
> >                             number of dimensions of variable: (2),
> >                 Subscripts used: (3)____
> >
> >                 __ __
> >
> >                 This error doesn't seem possible, because it's saying
> >                 that you are using 3 subscripts, but the line only has 2
> >                 subscripts being used in both arrays. Are you positive
> >                 that this error is coming from this line?____
> >
> >                 __ __
> >
> >                 I have to ask you again to please include your *full
> >                 script* next time and *all error messages* and *all
> >                 printed output*, so people can see exactly what line
> >                 numbers in your script the errors correspond with and
> >                 what your data looks like. But don't do this until you
> >                 have shown that you tried to debug the problem yourself.
> >                 Use "print" and "printVarSummary" *before* the locations
> >                 where the error messages are occurring, so you can see
> >                 what might be causing the error.____
> >
> >                 __ __
> >
> >                 For example, if the error says ____
> >
> >                 __ __
> >
> >                  number of dimensions of variable: (2), Subscripts used:
> >                 (3)____
> >
> >                 __ __
> >
> >                 then this means you are subscripting a variable as if it
> >                 were a 2D array, when it is actually a 3D array. Add
> >                 *printVarSummary* statements on ALL subscripted
> >                 variables that occur in that line, so you can be sure
> >                 you are doing things correctly.  For example, if the
> >                 error occurs on this line:____
> >
> >                 __ __
> >
> >                   aot_subset(ilt1:ilt2,iln1:iln2) := data(ilt1:ilt2,
> >                 iln1:iln2)____
> >
> >                 __ __
> >
> >                 then do this:____
> >
> >
> >                   printVarSummary(data)____
> >
> >                   printVarSummary(aot_subset)____
> >
> >                   aot_subset(ilt1:ilt2,iln1:iln2) := data(ilt1:ilt2,
> >                 iln1:iln2)____
> >
> >                 __ __
> >
> >                 It may also help to print the il* variables:____
> >
> >                 __ __
> >
> >                   printVarSummary(data)____
> >
> >                   printVarSummary(aot_subset)____
> >
> >                   print("ilt1 = " + ilt1)____
> >
> >                   print("ilt2 = " + ilt2)____
> >
> >                   print("iln1 = " + iln1)____
> >
> >                   print("iln2 = " + iln2)____
> >
> >                   aot_subset(ilt1:ilt2,iln1:iln2) := data(ilt1:ilt2,
> >                 iln1:iln2)____
> >
> >                 __ __
> >
> >                 __ __
> >
> >                 Moving forward, you *must* show that you are making some
> >                 effort to debug your problem.____
> >
> >                 __ __
> >
> >                 Thank you for your consideration.____
> >
> >                 __ __
> >
> >                 --Mary____
> >
> >                 __ __
> >
> >                 __ __
> >
> >                 __ __
> >
> >                 On Wed, Oct 18, 2017 at 12:23 AM, Kunal Bali
> >                 <kunal.bali9 at gmail.com <mailto:kunal.bali9 at gmail.com>>
> >                 wrote:____
> >
> >                 printVarSummary(aot_subset), shows that aot_subset is
> >                 undefined, which I am unable to fix this problem yet.____
> >
> >                 If I used aot_subset(ilt1:ilt2,iln1:iln2) *=*
> >                 data(ilt1:ilt2,iln1:iln2) *instead of
> >                 *aot_subset(ilt1:ilt2,iln1:iln2)*:=***data(ilt1:ilt2,
> iln1:iln2)____
> >
> >
> >                 then the error appeared as
> >
> >                 *fatal:["Execute.c":7950]:Number of subscripts on
> >                 right-hand-side do not match
> >                             number of dimensions of variable: (2),
> >                 Subscripts used: (3)*____
> >
> >                 basically, the data summary is
> >
> >                 Variable: fnames
> >                 Type: string
> >                 Total Size: 8 bytes
> >                             1 values
> >                 Number of Dimensions: 1
> >                 Dimensions and sizes:    [1]
> >                 Coordinates:
> >                 (0)    ./maiactaotE.h00v03.20000550525-20003660700.nc
> >                 <http://maiactaotE.h00v03.20000550525-20003660700.nc>
> >
> >                 Variable: data
> >                 Type: float
> >                 Total Size: 2545920000 <tel:(254)%20592-0000> bytes
> >                             636480000 values
> >                 Number of Dimensions: 3
> >                 Dimensions and sizes:    *[time | 442] x [YDim_grid1km |
> >                 1200] x [XDim_grid1km | 1200]*
> >                 Coordinates:
> >                             time: [1301.416666666686..8767]
> >                 Number Of Attributes: 8
> >                   coordinates :    GridLat_grid1km, GridLon_grid1km
> >                   hdfeos_name :    Optical_Depth_055
> >                   projection :    Albers Conical Equal_Area
> >                   unit :    None
> >                   long_name :    AOT at 0.55 micron
> >                   _FillValue_original :    -28672
> >                   _FillValue :    -28672
> >                   valid_range :    ( -0.1,  5 )
> >                 (0)    latitude (degrees_north) : min=11.2940312768897
> >                 max=24.54921980985786
> >                 (0)    longitude (degrees_east) :
> >                 min=68.08003670367275   max=81.63171349927691
> >                 *fatal:["Execute.c":7776]:aot_subset is undefined, can
> >                 not subscript an undefined variable
> >                 fatal:["Execute.c":8640]:Execute: Error occurred at or
> >                 near line 38 in file test_extract.ncl*____
> >
> >                 *38 line is *
> >                 *aot_subset(ilt1:ilt2,iln1:iln2) =
> >                 data(ilt1:ilt2,iln1:iln2)*____
> >
> >                 *fatal:Variable (aot_subset) is undefined*____
> >
> >                 __ __
> >
> >                 __ __
> >
> >                 __ __
> >
> >                 __ __
> >
> >                 __ __
> >
> >                 __ __
> >
> >                 regards
> >                 ____
> >
> >                 Kunal Bali____
> >
> >                 __ __
> >
> >                 __ __
> >
> >                 __ __
> >
> >                 __ __
> >
> >                 __ __
> >
> >                 On Tue, Oct 17, 2017 at 3:05 PM, Guido Cioni
> >                 <guidocioni at gmail.com <mailto:guidocioni at gmail.com>>
> >                 wrote:____
> >
> >                 Why did you comment this line ?____
> >
> >                 __ __
> >
> >                       ;printVarSummary(aot_subset)____
> >
> >                 __ __
> >
> >                 That would have helped you in debugging the error on
> >                 your own.____
> >
> >                 __ __
> >
> >                 You are using the re-assignment operator ":=". This
> >                 means that every time you make an assignment the
> >                 variable is created again. Thus, you cannot make this
> >                 assignment ____
> >
> >                 __ __
> >
> >                      * aot_subset(ilt1:ilt2,iln1:iln2) :=
> >                     data(ilt1:ilt2, iln1:iln2)*____
> >
> >                 __ __
> >
> >                 as NCL has no way to know the shape of aot_subset
> >                 beforehand. ____
> >
> >                 __ __
> >
> >                 The following should be used instead (notice the
> >                 assignment with "=" in the second line).____
> >
> >                 __ __
> >
> >                   aot_subset := data____
> >
> >                   aot_subset = aot_subset at _FillValue
> >                   aot_subset(ilt1:ilt2,iln1:iln2) *=* data(ilt1:ilt2,
> >                 iln1:iln2)____
> >
> >                 __ __
> >
> >                 Notice that this will (1) create an array which is
> >                 shaped like data (2) fill it with fill values as you
> >                 only want to compute the average over the subset (3)
> >                 populate the array only in the lat-lon box provided.
> >                 However I don't see why you would want to use such a
> >                 complicated syntax when the following code would produce
> >                 the same result____
> >
> >                 __ __
> >
> >                 aot_subset_avg=avg(data(ilt1:ilt2, iln1:iln2))____
> >
> >                 __ __
> >
> >                 If you have the right coordinate attributes you can even
> >                 jump the first 7 lines and do ____
> >
> >                 __ __
> >
> >                 aot_subset_avg=avg(data({18:24},{74:78})____
> >
> >                 __ __
> >
> >                 but I don't know your data. ____
> >
> >                 __ __
> >
> >                 As it was already suggested by Mary and others, PLEASE
> >                 take time to debug the errors on your own. ____
> >
> >                 __ __
> >
> >                 Regards,____
> >
> >                 __ __
> >
> >                     On 17. Oct 2017, at 11:25, Kunal Bali
> >                     <kunal.bali9 at gmail.com
> >                     <mailto:kunal.bali9 at gmail.com>> wrote:____
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     I did the following changes but still getting an
> >                     error of *aot_subset* which is undefined. ____
> >
> >                     please let me know that how to fix or defined the
> >                     *aot_subset *this problem.____
> >
> >
> >
> >
> >                       latv = (/ 18, 24/)     ; for extracting grid box
> data
> >                       lonv = (/ 74, 78 /)
> >                       nm   = getind_latlon2d (lat2d, lon2d, latv, lonv)
> >                       ilt1 = nm(0,0)  ; start lat index
> >                       ilt2 = nm(1,0)  ; start lon index
> >                       iln1 = nm(0,1)  ; end lat index
> >                       iln2 = nm(1,1)  ; end lon index
> >                       lat_subset  := lat2d(ilt1:ilt2,iln1:iln2)
> >                       lon_subset := lon2d(ilt1:ilt2,iln1:iln2)
> >                       aot_subset := data
> >                      *aot_subset(ilt1:ilt2,iln1:iln2) := data(ilt1:ilt2,
> >                     iln1:iln2)*
> >
> >                       ;printVarSummary(aot_subset)
> >                       aot_avg = avg(data)
> >                       aot_subset_avg = avg(*aot_subset*)
> >
> >                       ;print(nm)
> >                       print("-----")
> >
> >                       do k=0,dimsizes(latv)-1
> >                          n = nm(k,0)
> >                          m = nm(k,1)
> >                          print(lat2d(n,m)+"   "+lon2d(n,m))
> >                          print("     "+data(:,n,m))                   ;
> >                     nearest grid point at all time steps
> >                          print("-----")
> >                       end do
> >
> >
> >                     ____
> >
> >                     __ __
> >
> >                     regards
> >                     ____
> >
> >                     Kunal Bali____
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     On Tue, Oct 17, 2017 at 12:41 PM, Kunal Bali
> >                     <kunal.bali9 at gmail.com
> >                     <mailto:kunal.bali9 at gmail.com>> wrote:____
> >
> >                     I have sent the ncl script and data to the incoming
> >                     dir with the given names as
> >
> >                     data =
> >                     maiactaotE.h00v03.20003660525-20003660700.nc.bz2____
> >
> >                     ncl_script = extract_iiserb.ncl____
> >
> >                     __ __
> >
> >                     I am not able to define the var_subset in the given
> >                     script.  ____
> >
> >                     please let me know if you have received the data and
> >                     script?
> >
> >                     ____
> >
> >                     __ __
> >
> >
> >                     ____
> >
> >                     Kunal Bali____
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     On Mon, Oct 16, 2017 at 11:07 PM, Mary Haley
> >                     <haley at ucar.edu <mailto:haley at ucar.edu>> wrote:____
> >
> >                     Kunal,____
> >
> >                     __ __
> >
> >                     You must make an effort to debug some of these
> >                     problems on your own. The error is telling you that
> >                     something is wrong around line 34 and it is telling
> >                     you exactly what the problem is. Please try to fix
> >                     this error.____
> >
> >                     __ __
> >
> >                     If you continue to have problems after fixing this
> >                     error, then I need to ask you to provide the full
> >                     script and data via ftp:____
> >
> >                     __ __
> >
> >                     http://www.ncl.ucar.edu/ftp_files.shtml
> >                     <http://www.ncl.ucar.edu/ftp_files.shtml>____
> >
> >                     __ __
> >
> >                     However, make sure you debug any other new problems
> >                     that come up, instead of just emailing them to
> >                     ncl-talk.  We have a page to help you understand
> >                     some of NCL's errors, and what causes them:____
> >
> >                     __ __
> >
> >                     http://www.ncl.ucar.edu/Document/Language/error_
> messages.shtml
> >                     <http://www.ncl.ucar.edu/Document/Language/error_
> messages.shtml>____
> >
> >                     __ __
> >
> >                     The particular error you're seeing can be found
> >                     here:____
> >
> >                     __ __
> >
> >                     http://www.ncl.ucar.edu/Document/Language/error_
> messages.shtml#NumSubRHS
> >                     <http://www.ncl.ucar.edu/Document/Language/error_
> messages.shtml#NumSubRHS>____
> >
> >                     __ __
> >
> >                     As a side note, you are running a 3-year old version
> >                     of NCL. I suggest that you upgrade to NCL V6.4.0.____
> >
> >                     __ __
> >
> >                     --Mary____
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     On Mon, Oct 16, 2017 at 12:52 AM, Kunal Bali
> >                     <kunal.bali9 at gmail.com
> >                     <mailto:kunal.bali9 at gmail.com>> wrote:____
> >
> >                     I simply include the code (which you mentioned) were
> >                     I was taking the avg of the data as given below
> >                     (please correct me if I did wrong)
> >
> >
> >                     ;-----------------------------
> -----------------------------------------
> >                     ; Main code
> >                     ;-----------------------------
> -----------------------------------------
> >                       dir    = "./"
> >                       fnames = systemfunc("ls " + dir + "maiactaot*.nc")
> >                     print(fnames)
> >                       a      = addfile(fnames,"r")
> >                       data   = short2flt(a->Optical_Depth_055_grid1km)
> >                     printVarSummary (data)
> >                     printMinMax (data, 0)
> >                     print("-----")
> >                       nFill  = num(ismissing(data))
> >                     print("nFill="+nFill)
> >                     print("-----")
> >
> >                       lat2d  = a->GridLat_grid1km
> >                       lon2d  = a->GridLon_grid1km
> >                     printMinMax (lat2d, 0)
> >                     printMinMax (lon2d, 0)
> >                     print("-----")
> >
> >                     ;---grid points of interest
> >                     ;---http://www.ncl.ucar.edu/Document/Functions/
> Contributed/getind_latlon2d.shtml
> >                     <http://www.ncl.ucar.edu/Document/Functions/
> Contributed/getind_latlon2d.shtml>
> >                      ; latv = (/22, 24.0, 24.0, 22.0, 22.0/)
> >                      ; lonv = (/76, 76.0, 78.0, 78.0, 76.0/)
> >
> >                       *latv = (/ 22, 24/)
> >                       lonv = (/ 76, 78 /)
> >                       nm   = getind_latlon2d (lat2d, lon2d, latv, lonv)
> >                       ilt1 = nm(0,0)  ; start lat index
> >                       ilt2 = nm(1,0)  ; start lon index
> >                       iln1 = nm(0,1)  ; end lat index
> >                       iln2 = nm(1,1)  ; end lon index
> >                       var_subset = var(ilt1:ilt2,iln1:iln2)
> >                       var_subset_avg = avg(var_subset)*
> >
> >                       print(nm)
> >                       print("-----")
> >
> >                       do k=0,dimsizes(latv)-1
> >                          n = nm(k,0)
> >                          m = nm(k,1)
> >                          print(lat2d(n,m)+"   "+lon2d(n,m))
> >                          print("     "+data(:,n,m))                   ;
> >                     nearest grid point at all time steps
> >                          print("-----")
> >                       end do
> >
> >
> >
> >
> >                     ____
> >
> >                     *But still not getting the desired output as a
> >                     single square box mean value . It is showing the
> >                     errors as*
> >
> >                     kunal at kunal-Vostro-1015:/media/Local
> >                     Disk_/IIT_DELHI/2001/MAIACTAOT_TIME$ ncl
> extract1.ncl
> >                      Copyright (C) 1995-2014 - All Rights Reserved
> >                      University Corporation for Atmospheric Research
> >                      NCAR Command Language Version 6.2.1
> >                      The use of this software is governed by a License
> >                     Agreement.
> >                      See http://www.ncl.ucar.edu/ for more details.
> >
> >
> >                     Variable: fnames
> >                     Type: string
> >                     Total Size: 4 bytes
> >                                 1 values
> >                     Number of Dimensions: 1
> >                     Dimensions and sizes:    [1]
> >                     Coordinates:
> >                     (0)    ./maiactaot.h00v02.20010040635-20011550640.nc
> >                     <http://maiactaot.h00v02.20010040635-20011550640.nc/
> >
> >
> >                     Variable: data
> >                     Type: float
> >                     Total Size: 40320000 bytes
> >                                 10080000 values
> >                     Number of Dimensions: 3
> >                     Dimensions and sizes:    [time | 7] x [YDim_grid1km
> >                     | 1200] x [XDim_grid1km | 1200]
> >                     Coordinates:
> >                                 time: [8862.583333333314..12486.
> 66666666669]
> >                     Number Of Attributes: 8
> >                       coordinates :    GridLat_grid1km, GridLon_grid1km
> >                       hdfeos_name :    Optical_Depth_055
> >                       projection :    Albers Conical Equal_Area
> >                       unit :    None
> >                       long_name :    AOT at 0.55 micron
> >                       _FillValue_original :    -28672
> >                       _FillValue :    -28672
> >                       valid_range :    ( -0.1,  5 )
> >                     (0)    AOT at 0.55 micron: min=0   max=3.924
> >                     (0)    -----
> >                     (0)    nFill=6285271
> >                     (0)    -----
> >                     (0)    latitude: min=21.86737357453027
> >                     max=34.99855492029426
> >                     (0)    longitude: min=64.23634233372005
> >                     max=79.4747290253718
> >                     (0)    -----
> >                     fatal:["Execute.c":7863]:Number of subscripts on
> >                     right-hand-side do not match
> >                                 number of dimensions of variable: (2),
> >                     Subscripts used: (3)
> >
> >                     fatal:["Execute.c":8578]:Execute: Error occurred at
> >                     or near line 34 in file extract1.ncl
> >
> >                     fatal:Variable (var_subset) is undefined
> >                     fatal:["Execute.c":8578]:Execute: Error occurred at
> >                     or near line 35 in file extract1.ncl
> >
> >
> >
> >
> >                     Variable: nm
> >                     Type: integer
> >                     Total Size: 16 bytes
> >                                 4 values
> >                     Number of Dimensions: 2
> >                     Dimensions and sizes:    [2] x [2]
> >                     Coordinates:
> >                     Number Of Attributes: 1
> >                       long_name :    indices closest to specified
> >                     LAT/LON coordinate pairs
> >                     (0,0)    1199
> >                     (0,1)    792
> >                     (1,0)    1199
> >                     (1,1)    1041
> >                     (0)    -----
> >                     (0)    23.76603307545667   75.53995171540016
> >                     (0)         0.179
> >                     (1)         0.142
> >                     (2)         -28672
> >                     (3)         0.169
> >                     (4)         -28672
> >                     (5)         -28672
> >                     (6)         -28672
> >                     (0)    -----
> >                     (0)    24.26559325846936   77.93996773594735
> >                     (0)         -28672
> >                     (1)         0.393
> >                     (2)         -28672
> >                     (3)         0.156
> >                     (4)         0.313
> >                     (5)         -28672
> >                     (6)         -28672
> >                     (0)    -----____
> >
> >
> >
> >
> >
> >
> >
> >                       ____
> >
> >
> >                     ____
> >
> >                     Kunal Bali____
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     On Sat, Oct 14, 2017 at 12:24 AM, Mary Haley
> >                     <haley at ucar.edu <mailto:haley at ucar.edu>> wrote:____
> >
> >                     Kunal,____
> >
> >                     __ __
> >
> >                     Please include the code where you are actually
> >                     taking the average of your data using the
> >                     information returned from getind_latlon2d.____
> >
> >                     __ __
> >
> >                     It's important to note that getind_latlon2d simply
> >                     returns the individual index values that are closest
> >                     to each of the lat/lon pairs that you gave it. It
> >                     doesn't work in such a way that you give it a
> >                     lat/lon box and it returns all the values in that
> >                     box.    ____
> >
> >                     __ __
> >
> >                     That's what I was trying to illustrate with the
> >                     wrf_gsn_10.ncl I created.  I gave the function two
> >                     corners of the box, and then using the two pairs of
> >                     index values I got back, I was able to get all the
> >                     values inside the box area of interest:____
> >
> >                     __ __
> >
> >                       lats = (/ min_lat, max_lat /)____
> >
> >                       lons = (/ min_lon, max_lon /)____
> >
> >                       nm   = getind_latlon2d (lat2d, lon2d, lats,
> lons)____
> >
> >                       ilt1 = nm(0,0)  ; start lat index____
> >
> >                       ilt2 = nm(1,0)  ; start lon index____
> >
> >                       iln1 = nm(0,1)  ; end lat index____
> >
> >                       iln2 = nm(1,1)  ; end lon index
> >                       var_subset = var(ilt1:ilt2,iln1:iln2)____
> >
> >                       var_subset_avg = avg(var_subset)____
> >
> >                     __ __
> >
> >                     --Mary____
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     On Thu, Oct 12, 2017 at 1:19 PM, Kunal Bali
> >                     <kunal.bali9 at gmail.com
> >                     <mailto:kunal.bali9 at gmail.com>> wrote:____
> >
> >                     Dear Haley Ma'am,____
> >
> >                     __ __
> >
> >                     Thanks for providing the information and
> example. ____
> >
> >                     But if I follow the getind_latlon2d function as I
> >                     did, then it seems like I followed the same
> >                     procedure as given in the example
> >                     http://www.ncl.ucar.edu/Document/Functions/
> Contributed/getind_latlon2d.shtml
> >                     <http://www.ncl.ucar.edu/Document/Functions/
> Contributed/getind_latlon2d.shtml>____
> >
> >                     __ __
> >
> >                     But still I am not getting the mean of the grid box
> >                     on every time step or am I reading incorrectly the
> >                     result ?____
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     regards____
> >
> >                     Kunal Bali____
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     On Fri, Oct 13, 2017 at 12:11 AM, Mary Haley
> >                     <haley at ucar.edu <mailto:haley at ucar.edu>> wrote:____
> >
> >                     Kunal,____
> >
> >                     __ __
> >
> >                     I created an example for you, showing three ways you
> >                     can subset a WRF grid (since I already had a similar
> >                     example).  It shows how to use the getind_latlon2d
> >                     function.____
> >
> >                     __ __
> >
> >                     You have to be careful with subsetting curvilinear
> >                     data, because specifying a lat/lon box to take an
> >                     average over can mean two different things. You will
> >                     be able to see the difference when you look at the
> >                     graphic.____
> >
> >                     __ __
> >
> >                     See example wrf_gsn_10.ncl at:____
> >
> >                     __ __
> >
> >                     http://www.ncl.ucar.edu/
> Applications/wrfgsn.shtml#ex10
> >                     <http://www.ncl.ucar.edu/
> Applications/wrfgsn.shtml#ex10>____
> >
> >                     __ __
> >
> >                     --Mary____
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     On Wed, Oct 11, 2017 at 12:03 PM, Kunal Bali
> >                     <kunal.bali9 at gmail.com
> >                     <mailto:kunal.bali9 at gmail.com>> wrote:____
> >
> >                         Dear NCL users,____
> >
> >
> >                         Single point coordinates values of 23.0 N and
> >                         77.0 E is extracted or print by using the script
> >                         below
> >
> >                         ------------------------------
> ----------------------------------------
> >                         ; Main code
> >                         ;-----------------------------
> -----------------------------------------
> >                           dir    = "./"
> >                           fnames = systemfunc("ls " + dir +
> "maiactaot*.nc")
> >                         print(fnames)
> >                           a      = addfile(fnames,"r")
> >                           data   = short2flt(a->Optical_Depth_
> 055_grid1km)
> >                           nFill  = num(ismissing(data))
> >                           lat2d  = a->GridLat_grid1km
> >                           lon2d  = a->GridLon_grid1km
> >
> >                         ;---grid points of interest
> >                           latv = (/23.0/)
> >                           lonv = (/77.0 /)
> >
> >                           nm = getind_latlon2d (lat2d,lon2d, latv, lonv)
> >
> >                           do k=0,dimsizes(latv)-1
> >                              n = nm(k,0)
> >                              m = nm(k,1)
> >                              print(lat2d(n,m)+"   "+lon2d(n,m))   ; grid
> >                         point location
> >                              print("
> >                         "+data(:,n,m))                   ; nearest grid
> >                         point at all time steps
> >                              print("-----")
> >                           end do____
> >
> >
> >                         NOW, I want to extract the square grid box of
> >                         100 km around the coordinates (23N,77E) such as
> >                            latv = (/22, 24.0, 24.0, 22.0, 22.0/)
> >                            lonv = (/76, 76.0, 78.0, 78.0, 76.0 /)
> >
> >
> >                         after that I want to do the area mean of the
> >                         grid box. So that I can get one single point
> >                         value of that grid box.____
> >
> >                         So when I replacing
> >                           latv = (/23.0/)
> >                           lonv = (/77.0/)____
> >
> >                         __ __
> >
> >                         with
> >
> >                            latv = (/22, 24.0, 24.0, 22.0, 22.0/)
> >                            lonv = (/76, 76.0, 78.0, 78.0, 76.0 /)____
> >
> >                         then It's not giving mean of the square grid
> >                         box. ____
> >
> >                         It shows the something like that (given below),
> >                         which is incorrect. So please let me know how
> >                         can I get the square grid box mean and then
> >                         extract as asciiwrite or print?
> >
> >                         (0)    23.76603307545667   75.53995171540016
> >                         (0)         0.179
> >                         (1)         0.142
> >                         (2)         -28672
> >                         (3)         0.169
> >                         (4)         -28672
> >                         (5)         -28672
> >                         (6)         -28672
> >                         (0)    -----
> >                         (0)    24.00322458681621   75.99551564353467
> >                         (0)         0.171
> >                         (1)         0.16
> >                         (2)         -28672
> >                         (3)         0.17
> >                         (4)         -28672
> >                         (5)         -28672
> >                         (6)         -28672____
> >
> >                         etc..etc..____
> >
> >
> >
> >                         ____
> >
> >                         regards
> >                         ____
> >
> >                         Kunal Bali____
> >
> >                         __ __
> >
> >                         __ __
> >
> >                         __ __
> >
> >                         __ __
> >
> >                         _______________________________________________
> >                         ncl-talk mailing list
> >                         ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
> >                         List instructions, subscriber options,
> unsubscribe:
> >                         http://mailman.ucar.edu/
> mailman/listinfo/ncl-talk <http://mailman.ucar.edu/
> mailman/listinfo/ncl-talk>____
> >
> >                     __ __
> >
> >                     __ __
> >
> >
> >                     _______________________________________________
> >                     ncl-talk mailing list
> >                     ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
> >                     List instructions, subscriber options, unsubscribe:
> >                     http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >                     <http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >____
> >
> >                     __ __
> >
> >                     __ __
> >
> >
> >                     _______________________________________________
> >                     ncl-talk mailing list
> >                     ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
> >                     List instructions, subscriber options, unsubscribe:
> >                     http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >                     <http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >____
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     __ __
> >
> >                     _______________________________________________
> >                     ncl-talk mailing list
> >                     ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
> >                     List instructions, subscriber options, unsubscribe:
> >                     http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >                     <http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >____
> >
> >                 __ __
> >
> >
> >                 Guido Cioni____
> >
> >                 http://guidocioni.altervista.org____
> >
> >                 __ __
> >
> >                 __ __
> >
> >
> >                 _______________________________________________
> >                 ncl-talk mailing list
> >                 ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
> >                 List instructions, subscriber options, unsubscribe:
> >                 http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >                 <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>____
> >
> >                 __ __
> >
> >                 __ __
> >
> >                 __ __
> >
> >
> >                 ******************************
> ********************************************
> >                 The information contained in the EMail and any
> >                 attachments is confidential and intended solely and for
> >                 the attention and use of the named addressee(s). It may
> >                 not be disclosed to any other person without the express
> >                 authority of Public Health England, or the intended
> >                 recipient, or both. If you are not the intended
> >                 recipient, you must not disclose, copy, distribute or
> >                 retain this message or any part of it. This footnote
> >                 also confirms that this EMail has been swept for
> >                 computer viruses by Symantec.Cloud, but please re-sweep
> >                 any attachments before opening or saving.
> >                 http://www.gov.uk/PHE
> >                 ******************************
> ********************************************
> >
> >
> >
> >             _______________________________________________
> >             ncl-talk mailing list
> >             ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
> >             List instructions, subscriber options, unsubscribe:
> >             http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >             <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
> >
> >
> >
> >
> >         --
> >         Barry H. Lynn, Ph.D
> >         Senior Lecturer,
> >         The Institute of the Earth Science,
> >         The Hebrew University of Jerusalem,
> >         Givat Ram, Jerusalem 91904, Israel
> >         Tel: 972 547 231 170
> >         Fax: (972)-25662581
> >
> >         C.E.O, Weather It Is, LTD
> >         Weather and Climate Focus
> >         http://weather-it-is.com
> >         Jerusalem, Israel
> >         Local: 02 930 9525
> >         Cell: 054 7 231 170
> >         Int-IS: x972 2 930 9525
> >         US 914 432 3108 <tel:091443%2023108>
> >
> >
> >
> >
> >
> > --
> > Barry H. Lynn, Ph.D
> > Senior Lecturer,
> > The Institute of the Earth Science,
> > The Hebrew University of Jerusalem,
> > Givat Ram, Jerusalem 91904, Israel
> > Tel: 972 547 231 170
> > Fax: (972)-25662581
> >
> > C.E.O, Weather It Is, LTD
> > Weather and Climate Focus
> > http://weather-it-is.com
> > Jerusalem, Israel
> > Local: 02 930 9525
> > Cell: 054 7 231 170
> > Int-IS: x972 2 930 9525
> > US 914 432 3108
> >
> >
> > _______________________________________________
> > ncl-talk mailing list
> > ncl-talk at ucar.edu
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >
>
> --
> Adrian Tompkins          | Earth System Physics
> +39 040 2240579 (office) | ICTP
> +39 040 22407579 (fax)   | Strada Costiera 11
> www.ictp.it/~tompkins    | 34151 Trieste, Italy
>
> _______________________________________________
> 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/20171027/7b0150d6/attachment-0001.html>


More information about the ncl-talk mailing list