Re: how to calculate average of seasonal means

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Fri Oct 22 2010 - 07:59:37 MDT

Wrrors such as

> fatal:Undefined identifier: (calculate_monthly_values) is undefined,

indicate that you have not loaded contributed.ncl

======
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"

D

On 10/21/10 9:54 AM, Vishali P. wrote:
> Hello Dennis,
> Sorry for the delay, I was on my exams.
>
>
> [1] Memory available on my computer is 2GB
>
>
> [2]
>
> Variable: w
> Type: float
> Total Size: 1043631360 bytes
> 260907840 values
> Number of Dimensions: 4
> Dimensions and sizes: [time | 1460] x [level | 17] x [lat | 73] x
> [lon | 144]
> Coordinates:
> time: [1735632..1744386]
> level: [1000..10]
> lat: [90..-90]
> lon: [ 0..357.5]
> Number Of Attributes: 16
> long_name : Wind Speed
> standard_name : eastward_wind
> units : m/s
> _FillValue : -32767
> valid_range : ( -140, 174.989990234375 )
> parent_stat : Other
> statistic : Individual Obs
> level_desc : Pressure Levels
> dataset : NCEP/DOE AMIP-II Reanalysis (Reanalysis-2)
> var_desc : u-wind
> GRIB_name : UGRD
> GRIB_id : 33
> least_significant_digit : 1
> precision : 2
> actual_range : ( -87.30000305175781, 129.5 )
> unpacked_valid_range : ( -140, 175 )
>
>
> [3] I've tried to run the script you suggested for monthly means. But I
> found errors. I also tried to make some changes to script to solve, but
> I found more errors. So... I preferred to keep your original script and
> print the output
>
>
> fatal:Undefined identifier: (calculate_monthly_values) is undefined,
> can't continue
> fatal:Execute: Error occurred at or near line 25 in file new file.ncl
>
> fatal:(time) is not a named dimension in variable (wMon).
> fatal:Execute: Error occurred at or near line 30 in file new file.ncl
>
>
>
> Variable: wMon
> Type: float
> Total Size: 60044544 bytes
> 15011136 values
> Number of Dimensions: 4
> Dimensions and sizes: [84] x [17] x [73] x [144]
> Coordinates:
> Number Of Attributes: 1
> _FillValue : 1e+20
> fatal:(time) is not a named dimension in variable (wMon).
> fatal:Execute: Error occurred at or near line 35 in file new file.ncl
>
>
>
> Variable: wMon
> Type: float
> Total Size: 60044544 bytes
> 15011136 values
> Number of Dimensions: 4
> Dimensions and sizes: [84] x [level | 17] x [73] x [144]
> Coordinates:
> level: [1000..10]
> Number Of Attributes: 1
> _FillValue : 1e+20
> fatal:Undefined identifier: (wgt_runave_n_Wrap) is undefined, can't continue
> fatal:Execute: Error occurred at or near line 42 in file new file.ncl
>
> fatal:Variable (wAllSea) is undefined
> fatal:Execute: Error occurred at or near line 43 in file new file.ncl
>
> fatal:Undefined identifier: (wAllSea) is undefined, can't continue
> fatal:Execute: Error occurred at or near line 45 in file new file.ncl
>
> fatal:Variable (wSea) is undefined
> fatal:Execute: Error occurred at or near line 46 in file new file.ncl
>
>
> Thanks
>
> Vp
>
>
>
>
> On Tue, Oct 19, 2010 at 9:06 PM, Dennis Shea <shea@ucar.edu
> <mailto:shea@ucar.edu>> wrote:
>
> [1]
> How much memory do you have available on your machine?
>
> [2]
> A single (leap) year will be: w(1464, 17, 73, 144)
> For type float, that will be 1464*17*73*144*4 = 1046490624 bytes
>
> You could just read a single file:
>
>
> diru ="/home/Vishali/Documents/dadosVentos/Speed/"
> filu = systemfunc("cd "+diru+" ; ls wind*nc")
> f = addfiles(diru+filu, "r")
>
> ListSetType (f, "cat") ; 'cat' (default) or 'join'
>
> w = f[0]->WSpeed ; read from the 1st file only
> printVarSummary(w)
>
> ---
>
> Currently, NCL can handle only 2GB variables. Obviously,
> 7 years of data will yield a variable of 7GB+.
>
> Note: The *next* release of NCL (v6.0.0) will be able to handle
> variables of this size.
>
> ================================================================
> If you have one file per year, try the following *untested*
> code (otherwise, change as necessary). Note: I am sure the CDO
> are computing the weighted means. The following computes the
> unweighted monthly means.
>
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>
> yrStrt = 1998
> yrLast = 2004
> nyrs = yrLast-yrStrt+1
> klev = 17
> nlat = 73
> mlon = 144
> ntim = 12*nyrs ; number of months
>
> wMon = new ( (/ntim,klev,nlat,mlon/), "float", 1e20)
> tMon = new ( ntim, "double", "No_FillValue")
>
>
> diru = "/home/Vishali/Documents/dadosVentos/Speed/"
> filu = systemfunc("cd "+diru+" ; ls wind*nc")
> nfilu = dimsizes(filu)
>
> ; calculate monthly means from 6hrly
> nmoStrt = 0
> nmoLast = 11
> do nf=0,nfilu-1
> f = addfile(diru+filu(nf), "r")
> w = f->WSpeed
> wMon(nmoStrt:nmoLast,:,:,:) = calculate_monthly_values(w,
> "avg",0, False)
> nmoStrt = nmoStrt+12
> nmoLast = nmoLast+12
> delete(w) ; may change size next iteration (leap yr)
> end do
> delete(wMon&time)
>
> printVarSummary(wMon) ; wMon(84,17,73,144)
>
> time = yyyymm_time(yrStrt, yrLast, "integer")
> wMon&time = time
>
> wMon!1 = "level" ; minor bug in "calculate_monthly_values"
> wMon&level = f->level
>
> printVarSummary(wMon)
> ; unweighted seasonal means
> wAllSea = wgt_runave_n_Wrap(wMon, 3, 0, 0)
> printVarSummary(wAllSea)
>
> wSea = wAllSea(::3,:,:,:) ; (28,14,73,144)
> printVarSummary(wSea)
>
>
>
>
>
>
> On 10/19/2010 12:45 PM, Vishali P. wrote:
>
> Hello, Ive tried with this script, but appears this error
>
> ;*************************************************
> ; wind.ncl (1998-2004)
> ;************************************************
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
> ;************************************************
> begin
> ;************************************************
> ; read in netCDF file
> ;************************************************
>
> diru ="/home/Vishali/Documents/dadosVentos/Speed/"
> filu = systemfunc("cd "+diru+" ; ls wind*nc")
> f = addfiles(diru+filu, "r")
>
> ListSetType (f, "cat") ; 'cat' (default) or 'join'
>
> w = f[:]->WSpeed
> printVarSummary(w)
>
> end
>
>
> ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
>
>
> *** glibc detected *** ncl: munmap_chunk(): invalid pointer:
> 0x7e702008 ***
> ======= Backtrace: =========
> /lib/libc.so.6[0x4cffe1]
> ncl(NclFree+0x22)[0x8101262]
> ncl[0x80ddbc5]
> ncl(_NclDestroyObj+0x73)[0x80eb513]
> ncl(CallLIST_READ_FILEVAR_OP+0xea8)[0x817e238]
> ncl(_NclExecute+0x6aa)[0x818096a]
> ncl(yyparse+0x762d)[0x809da2d]
> ncl(main+0x8bb)[0x8091a6b]
> /lib/libc.so.6(__libc_start_main+0xe6)[0x477cc6]
> ncl[0x8091111]
> ======= Memory map: ========
> 00101000-001b4000 r-xp 00000000 08:06 78990 /lib/libkrb5.so.3.3
> 001b4000-001ba000 rw-p 000b3000 08:06 78990 /lib/libkrb5.so.3.3
> 001bc000-001e6000 r-xp 00000000 08:06 78988
> /lib/libk5crypto.so.3.1
> .
> .
> .
> 06530000-06537000 rw-p 00000000 00:00 0
> 08043000-088b0000 r-xp 00000000 08:06 823 /usr/bin/nclAborted
> (core dumped)
>
>
>
>
>
>
> --
> ======================================================
> Dennis J. Shea tel: 303-497-1361 |
> P.O. Box 3000 fax: 303-497-1333 |
> Climate Analysis Section |
> Climate & Global Dynamics Div. |
> National Center for Atmospheric Research |
> Boulder, CO 80307 |
> USA email: shea 'at' ucar.edu <http://ucar.edu> |
> ======================================================
>
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Oct 22 07:59:42 2010

This archive was generated by hypermail 2.1.8 : Fri Oct 22 2010 - 12:21:46 MDT