Re: Error with dim_area_avg

From: Ipshita Majhi <ipmajhi_at_nyahnyahspammersnyahnyah>
Date: Wed Jul 23 2014 - 16:25:39 MDT

Thank you so much for the input!
I will definitely take it on!


On Wed, Jul 23, 2014 at 2:21 PM, Adam Phillips <asphilli@ucar.edu> wrote:

> Hi Ipshita,
> I think you might need to take a step back and really look at the data you
> are trying to read in. This should always be the first thing you do when
> constructing a program.
>
> - From your printVarSummary output your sce array is of type byte. In
> general you will almost always want to use the byte2flt function to convert
> the byte values to floats.
> http://www.ncl.ucar.edu/Document/Functions/Contributed/byte2flt.shtml
>
> - Again from the printVarSummary your data array is 2 dimensions, but you
> are specifying more than 2 dimensions when referring to sce.
>
> - Your data is also on a curvilinear grid, in that it has 2 dimensional
> latitudes and longitudes. Different syntax is needed when dealing with
> rectilinear data vs. curvilinear data. You cannot use coordinate
> subscripting on curvilinear data as you are doing here:
> z2 = sce({10:30},{40:60},:) ; select specific region
>
> You should try using region_ind to subset your data:
> http://www.ncl.ucar.edu/Document/Functions/Contributed/region_ind.shtml
> Note the warning on the page that not all curvilinear grids work with
> region_ind. You will want to make sure that the subsetting works but say
> drawing a quick plot of the resulting array.
>
> 2 final things:
> 1)If you haven't done so already please read through the NCL mini-language
> manual.
> http://www.ncl.ucar.edu/Document/Manuals/
>
> 2) Instead of immediately replying to every response that comes in via
> ncl-talk trying to help you, try to work through some things on your own.
> This is the best way to learn. Use the NCL website: Look at the examples,
> look up functions, etc. You can search past ncl-talk postings by using the
> search engine on the NCL website.
>
> If after applying what I say above you are still having issues with the
> script please do what Karin just requested: Send your complete script (as
> an attachment) along with the exact error messages that you are getting to
> ncl-talk so everyone can better assist you.
>
> Good luck,
> Adam
>
>
>
> On Wed, Jul 23, 2014 at 3:28 PM, Ipshita Majhi <ipmajhi@alaska.edu> wrote:
>
>> I don't know the thing is that I had a 2D file called snow cover extent
>> (sce), and then I added lat and lon to it
>> then the cooridinates of sce shows
>> latitude longitude time and snow cover extent
>>
>> I made the changes you requested still the errors persist!
>>
>>
>>
>> On Wed, Jul 23, 2014 at 1:20 PM, Alessandra Giannini <
>> alesall@iri.columbia.edu> wrote:
>>
>>>
>>> Hi Ipshita,
>>>
>>> I see an error in your very last script [but not in the prior version].
>>> Could it be so simple as the following:
>>>
>>> the last parenthesis in your definition of z2 should be a ")", not a "}"
>>> ??
>>>
>>> z2=sce({10:30},{40:60},:,:}
>>>
>>> should actually be
>>>
>>> z2=sce({10:30},{40:60},:,:)
>>>
>>> Ah, also in the previous script, I think you have an extra "}" at the
>>> end:
>>>
>>> > z2 = sce({10:30},{40:60},:,:})
>>>
>>> there shouldn't be a "}" before the last ")"
>>>
>>> i.e. it should read
>>>
>>> > z2 = sce({10:30},{40:60},:,:)
>>>
>>>
>>> best, alessandra
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Jul 23, 2014, at 5:13 PM, Ipshita Majhi <ipmajhi@alaska.edu> wrote:
>>>
>>> > Here are the error messages
>>> >
>>> > fatal: error in statement
>>> > fatal: syntax error : line 3 in file
>>> > area_avg_ims_sce.ncl
>>> >
>>> > *
>>> > ^
>>> > fatal : error in statement
>>> > fatal: syntax error :line 22 in file
>>> > area_avg_ims_sce.ncl before or near }
>>> >
>>> > z2=sce({10:30},{40:60},:,:}
>>> >
>>> > fatal:sytax error : line 32 in file area_avg_ims_sce.ncl before or
>>> near ; create
>>> > timeXlong array
>>> > z2ma=dim_avg_wrap(z2(time
>>> > fatal:syntax error: line -1 before or near
>>> > ^
>>> > fatal: error in statement
>>> >
>>> >
>>> > On Wed, Jul 23, 2014 at 12:48 PM, Karin Meier-Fleischer <
>>> meier-fleischer@dkrz.de> wrote:
>>> > Please send the complete error message.
>>> >
>>> >
>>> > Am 23.07.2014 um 22:32 schrieb Ipshita Majhi <ipmajhi@alaska.edu>:
>>> >
>>> >> Why is this not working? It says the synatax at Z2 is not correct
>>> >>
>>> >> ************************************************
>>> >> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>>> >> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>>> >> ;************************************************
>>> >> begin
>>> >> ;************************************************
>>> >> ; read in netCDF file
>>> >> ;************************************************
>>> >> a =addfile("~/Documents/Snow_cover_IMS/
>>> nhsce_v01r01_19661004_20140602.nc","r")
>>> >>
>>> >> sce=a->snow_cover_extent(0,:,:)
>>> >> lat=a->latitude
>>> >> lon=a->longitude
>>> >>
>>> >>
>>> >> ;Attaching latitude and longitude to sce
>>> >> sce@lat2d=lat
>>> >> sce@lon2d=lon
>>> >>
>>> >> z2 = sce({10:30},{40:60},:,:}) ; select specific region
>>> >> delete(sce)
>>> >> printVarSummary(z2)
>>> >>
>>> >> z2Area = wgt_areaave_Wrap(z2,1.0,1.0,0) ; create area-avg. timeseries
>>> >>
>>> >> printVarSummary(z2Area)
>>> >>
>>> >> z2_za = dim_avg_Wrap(z2) ; create time x lat array
>>> >>
>>> >> z2_ma = dim_avg_Wrap(z2(time|:,lon|:,lat|:) ; create time x lon array
>>> >>
>>> >> printVarSummary(z2_za)
>>> >> printVarSummary(z2_ma)
>>> >> _______________________________________________
>>> >> ncl-talk mailing list
>>> >> List instructions, subscriber options, unsubscribe:
>>> >> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>> >
>>> >
>>> > _______________________________________________
>>> > ncl-talk mailing list
>>> > List instructions, subscriber options, unsubscribe:
>>> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
>
> --
> Adam Phillips
> Associate Scientist, Climate and Global Dynamics Division, NCAR
> www.cgd.ucar.edu/staff/asphilli/ 303-497-1726
>
> <http://www.cgd.ucar.edu/staff/asphilli>
>

Received on Wed Jul 23 10:25:45 2014

This archive was generated by hypermail 2.1.8 : Fri Aug 01 2014 - 15:10:55 MDT