[ncl-talk] Averaging over time dimension

Adam Phillips asphilli at ucar.edu
Thu Mar 8 12:06:50 MST 2018


Hi Soma,
Malloc errors usually mean you are running out of memory on your machine.
Your printVarSummary statement shows that the variable is 1GB in size, and
is of type short. You will want to convert this to type float to process
and/or to plot it, but when you do that the size of your array will double. You
might not be able to read multiple variables into NCL at once due to the
size of your machine. One thing you can do though is read in a variable,
convert it to float, and average across the time dimension all at once:
T=dim_avg_n_Wrap(short2flt(in->t),0)     ; temperature

I am honestly not sure whether it is good practice to do all that upon read
in, someone else can possibly chime in here. If not, one can do this:
Tt = in->T
T = dim_avg_n_Wrap(short2flt(Tt),0)     ; temperature
delete(Tt)

and then repeat for U and V the same way. Again though, it comes down to
whether your machine is big enough memory wise to handle the size of these
arrays. If it is not, you will have to chunk your data read-ins in either
time or lat x lon.

Hope that helps. If not, please respond to the ncl-talk email list.
Adam


On Thu, Mar 8, 2018 at 8:35 AM, Soma Roy <somaroy892 at gmail.com> wrote:

> Hi,
>
> I am trying to access multiple variables from a file and need to average
> over time for each variables.
>
> I am running the following codes:
>
>    fn  = "ERA_Plev.nc"                      ; define filename
>    in  = addfile(fn,"r")                         ; open netcdf file
>    printVarSummary(in)
>
> T=in->t       ; temperature
> U=in->u      ; U wind
> V=in->v      ; V wind
>
> printVarSummary(T)
> printVarSummary(U)
> printVarSummary(V)
>
> ;T1 = dim_avg_n(T,0)
> ;T at units = "K"
> end
>
> Summary of the file is like below;
>
> Variable: in
> Type: file
> File path: ERA_Plev.nc
> Number of global attributes:     2
> Number of dimensions:    4
> Number of variables:     18
> fatal:NclMalloc Failed:[errno=12]
> Segmentation fault (core dumped)
>
> When I am calling only Temperature using the codes below;
>
> fn  = "ERA_Plev.nc"               ; define filename
> in  = addfile(fn,"r")                         ; open netcdf file
>    printVarSummary(in)
>
> T=in->t     ; temperature
> ;U=in->u     ; U wind
> ;V=in->v     ; V wind
>
> printVarSummary(T)
> ;printVarSummary(U)
> ;printVarSummary(V)
>
> ;T1 = dim_avg_n(T,0)
> ;T at units = "K"
> end
>
> It shows
>
> Variable: T
> Type: short
> Total Size: 1042566000 bytes
>             521283000 values
> Number of Dimensions: 4
> Dimensions and sizes:   [time | 120] x [level | 25] x [latitude | 721] x
> [longitude | 241]
> Coordinates:
>             time: [994176..994890]
>             level: [50..125]
>             latitude: [90..-90]
>             longitude: [60..120]
> Number Of Attributes: 7
>   scale_factor :        0.00218919045579553
>   add_offset :  252.4797479951041
>   _FillValue :  -32767
>   missing_value :       -32767
>   units :       K
>   long_name :   Temperature
>   standard_name :       air_temperature
>
>
> I have to call several other variables from this file (14 GB) and I need
> to average over time such that 'Dimensions' of each variables will be like
> below;
>
> [time | 1]* [level | 25] x [latitude | 721] x [longitude | 241]
>
> Which function I have to use in this case?
>
>
> When I am trying to call  other variables from the file I am getting the
> error message as;
>
> Variable: in
> Type: file
> File path: ERA_Plev.nc
> Number of global attributes:     2
> Number of dimensions:    4
> Number of variables:     18
> fatal:NclMalloc Failed:[errno=12]
> Segmentation fault (core dumped)
>
> Please kindly inform me how to resolve this issue.
>
>
> Thank you,
> Soma
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>


-- 
Adam Phillips
Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
www.cgd.ucar.edu/staff/asphilli/   303-497-1726

<http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180308/d226cb1c/attachment.html>


More information about the ncl-talk mailing list