Re: Downsizing a ncdf file

From: Dennis Shea (shea AT cgd.ucar.edu)
Date: Mon Feb 14 2005 - 09:17:35 MST

  • Next message: Sylvia Murphy: "goodby"

    >I have model output ncdf files (lat,lon,time,levels and parameters),
    >on say 5x5 minute grid (limited domain).
    >I want to calculate area mean values for eg. 15x15 grid.
    >I know ncks, extracts for example every third lat x lon,
    >but I want the mean values. So I didn't find a way
    >to do it with nco.
    >(E.g extracting 3 times with ncks (shifted start) and
    >averaging with ncea the 3 files, gives the mean values, but
    >the coordinates are not averaged, further the handling of missing values
    >creates another problem)
    >
    >Does anybody know code from NCL or..
    >which would perform just this and may be general enough to
    >be applied on rather arbitrary (my) ncdf files.

    Umm, I think that it is possible to use the NCO to accomplish
    this task. I will ask someone who does this type of thing.

    ---
    

    As far as NCL is concerned, there are numerous approaches depending upon what your objective is.

    Let x(time,lev,lat,lon) where each dimension is a classical netCDF coordinate variable [ie: one-dimensional and monotonically {in/de}creasing]. If missing values are present the _FillValue attribute should be associated with the variable x.

    see: http://ngwww.ucar.edu/ngdoc/ng/ref/ncl/functions/wareaave.html

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

    latS = 20. ; 15 x 15 area latN = 35. lonL = 190. lonR = 205. opt = ; 0 or 1 (see write-up of wgt_areaave)

    f = addfile ("foo.nc" , "r") x = f->SomeVariable(:,:,{latS:latN},{lonL:lonR} ; (time,lev,lat,lon) lat = x&lat ; extract latitudes associated with x clat = cos(lat*0.01745329) ; cos latitude wgting xAreaAve = wgt_areaave_Wrap(x, clat, 1., opt) ; ==> (time,lev) printVarSummary(xAreaAve)

    ---- If your lat/lon are 2D see http://ngwww.ucar.edu/ngdoc/ng/ref/ncl/functions/wareaave2.html

    ---- Cheers!

    _______________________________________________ ncl-talk mailing list ncl-talk@ucar.edu http://mailman.ucar.edu/mailman/listinfo/ncl-talk



    This archive was generated by hypermail 2b29 : Mon Feb 14 2005 - 10:54:53 MST