Re: mm52ncdf

From: Sylvia Murphy (murphys AT cgd.ucar.edu)
Date: Mon Nov 01 2004 - 11:50:01 MST

  • Next message: Paulo de Melo Gonçalves: "lonFLIP"

    ben,

    how you make plots using data that has 2D lat/lon info is different.
    see
    http://www.cgd.ucar.edu/csm/support/CSM_Graphics/popscal.shtml
    for an example.

    sylvia

    On Mon, 1 Nov 2004, Benjamin Lamptey wrote:

    > Thanks Dennis,
    > I think what you suggested below is what I did to write my variables
    > to the output netcdf file. But I could not make plots. Below is the
    > output from ncdump -h for my ncdf file;
    >
    > netcdf runmodi {
    > dimensions:
    > time = 60 ;
    > lev = 5 ;
    > layer = 6 ;
    > NLAT = 64 ;
    > MLON = 46 ;
    > LAT = 64 ;
    > LON = 46 ;
    > variables:
    > int time(time) ;
    > time:units = "yyyymm" ;
    > time:long_name = "time" ;
    > time:_FillValue = -999 ;
    > float lev(lev) ;
    > lev:units = "hPa" ;
    > lev:long_name = "pressure" ;
    > float layer(layer) ;
    > layer:units = "metres" ;
    > layer:long_name = "mid-point of soil layer" ;
    > float lat(NLAT, MLON) ;
    > lat:units = "degrees_north" ;
    > lat:long_name = "latitude" ;
    > float lon(NLAT, MLON) ;
    > lon:units = "degrees_east" ;
    > lon:long_name = "longitude" ;
    > float U(time, lev, LAT, LON) ;
    > float V(time, lev, LAT, LON) ;
    > float T(time, lev, LAT, LON) ;
    > float Q(time, lev, LAT, LON) ;
    > float RH(time, lev, LAT, LON) ;
    > float Z(time, lev, LAT, LON) ;
    > float SOILT1(time, layer, LAT, LON) ;
    > float SOILM1(time, layer, LAT, LON) ;
    > float SLP1(time, LAT, LON) ;
    > float TSA(time, LAT, LON) ;
    > float TG1(time, LAT, LON) ;
    > float TSS1(time, LAT, LON) ;
    > float TSA2(time, LAT, LON) ;
    > float QSA2(time, LAT, LON) ;
    > float RAINC1(time, LAT, LON) ;
    > float RAINNC1(time, LAT, LON) ;
    > float RAINTOT1(time, LAT, LON) ;
    > float SNOWD1(time, LAT, LON) ;
    > float CLD1(time, LAT, LON) ;
    > float HFX1(time, LAT, LON) ;
    > float QFX1(time, LAT, LON) ;
    > float GSW1(time, LAT, LON) ;
    > float GLW1(time, LAT, LON) ;
    > float OSW1(time, LAT, LON) ;
    > float OLW1(time, LAT, LON) ;
    > float TA2MAX1(time, LAT, LON) ;
    > float TA2MIN1(time, LAT, LON) ;
    > float TGMAX1(time, LAT, LON) ;
    > float TGMIN1(time, LAT, LON) ;
    > float GRUNOF1(time, LAT, LON) ;
    > float GDRAIN1(time, LAT, LON) ;
    > float SNOWF1(time, LAT, LON) ;
    > float WPUD1(time, LAT, LON) ;
    > float WIPUD1(time, LAT, LON) ;
    > float LAIT1(time, LAT, LON) ;
    > float Z0LEN1(time, LAT, LON) ;
    > float ALBS1(time, LAT, LON) ;
    > float SOLA1(time, LAT, LON) ;
    > float HG(LAT, LON) ;
    > float XMASK(LAT, LON) ;
    > float URBAN(LAT, LON) ;
    > float VEGDS(LAT, LON) ;
    > float VEGMM(LAT, LON) ;
    > }
    > 2) Note that my lat is actually lat2d.
    > 3) I did not assign coordinate variables to them
    >
    > Below is the error message when I tried to make a plot
    >
    >
    > Copyright (C) 1995-2004 - All Rights Reserved
    > University Corporation for Atmospheric Research
    > NCAR Command Language Version 4.2.0.a031
    > The use of this software is governed by a License Agreement.
    > See http://ngwww.ucar.edu/ncl/ for more details.
    > (0)
    > (0) ==========> printVarInfo: lat
    >
    >
    > Variable: x (parameter)
    > Type: float
    > Total Size: 11776 bytes
    > 2944 values
    > Number of Dimensions: 2
    > Dimensions and sizes: [NLAT | 64] x [MLON | 46]
    > Coordinates:
    > Number Of Attributes: 2
    > units : degrees_north
    > long_name : latitude
    > (0) Minimum: 34.8703 Maximum: 50.3709
    > (0)
    > (0)
    > (0) ==========> printVarInfo: lon
    >
    >
    > Variable: x (parameter)
    > Type: float
    > Total Size: 11776 bytes
    > 2944 values
    > Number of Dimensions: 2
    > Dimensions and sizes: [NLAT | 64] x [MLON | 46]
    > Coordinates:
    > Number Of Attributes: 2
    > units : degrees_east
    > long_name : longitude
    > (0) Minimum: -90.0246 Maximum: -57.9754
    > (0)
    > fatal:Coordinate variables must have one dimension only
    >
    > fatal:No coordinate variable exists for dimension (LAT) in variable (raintot1A_DJF)
    >
    > Thanks
    > Ben
    >
    >
    > On Mon, Nov 01, 2004 at 09:49:59AM -0700, Dennis Shea wrote:
    > > Ben
    > >
    > > >I am trying to convert the variable x(nyear, nmon,kp,mjx,mix)
    > > >where nyear, nmon, kp, mjx, mix are all scalars, like
    > > >
    > > >ua1 = fbinrecread (infile,2, (/nyear,nmon,kp,mjx,mix/),"float")
    > > >
    > > >to a variable xNew = onedtond( ndtooned(X), (/ntim,nlev,nlat,mlon/))
    > > >where nlat = dimsizes(lat2d) and mlon= dimsizes(lon2d).
    > > >
    > > > lat2d = fbinrecread (infile,0, (/mjx,mix/),"float")
    > > > lon2d = fbinrecread (infile,1, (/mjx,mix/),"float")
    > > >
    > > >I shall appreciate any ideas on how to do that since
    > > >xNew = onedtond( ndtooned(X), (/ntim,nlev,nlat,mlon/)) is wrong
    > > >because nlat and mlon are 2D while ntim and nlev are 1D?
    > >
    > >
    > > Presumably, the variable "ua1" is on the same grid as the
    > > lat2d/lon2d variables. Ie: for each year/month/level the
    > > mjx=nlat and the mix=mlon. Then
    > >
    > > ua1New = onedtond( ndtooned(ua1), (/ntim,nlev,nlat,mlon/))
    > >
    > > --- Something like
    > >
    > > dimensions:
    > > time = 120 ;
    > > nlon = 360 ;
    > > nlat = 240 ;
    > > lev = 40 ; ; kp
    > >
    > > integer time(time) ;
    > > time:long_name = "time"
    > > time:units = "yyyymm"
    > > float lev(lev) ;
    > > lev:long_name = "pressure level"
    > > lev:units = "hPa"
    > >
    > > float LAT2D(nlat, nlon)
    > > LAT2D:long_name = "array of latitudes"
    > > LAT2D:units = "degrees_north"
    > > float LON2D(nlat, nlon)
    > > LON2D:long_name = "array of longitudes"
    > > LON2D:units = "degrees_east"
    > >
    > > float UA1(time, lev, nlat, nlon)
    > > UA1:long_name = "Whatever UA1 is"
    > > UA1:units = "?"
    > > UA1:_FillValue = 1e+20f
    > > TEMP:missing_value = 1e+20f
    > > ==========================================================
    > >
    > > >
    > > >Note that I cannot read lat2d and lon2d into 1D variables because
    > > >they do not repeat themselves.
    > >
    > > You can put lat2d and lon2d into 1D variables. That is not the
    > > problem. By definition, a netCDF *coordinate variable* is
    > > a one dimensional array that contains monotonically
    > > increasing or decreasing values. If you tried to assign
    > > the one dimensional versions of LAT2D and LON2D as
    > > coordinate variables the underlying netCDF software which
    > > NCL uses would reject them because they are not monotonic.
    > >
    > > good luck
    > > D
    > >
    > > _______________________________________________
    > > ncl-talk mailing list
    > > ncl-talk@ucar.edu
    > > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
    >
    > --
    >
    >
    > Benjamin L. Lamptey Phone: (814) 865-9911 (office)
    > Pennstate (EMS Environment Institute) (814) 237-8193 (home)
    > 2217 Earth-Engineering Sciences Bldg Fax : (814) 865-3191
    > University Park, PA 16802 WWW:http://www.essc.psu.edu/~lamptey
    >
    >
    >
    > _______________________________________________
    > ncl-talk mailing list
    > ncl-talk@ucar.edu
    > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
    >

    ******************************************************
    Sylvia Murphy EML: murphys@ucar.edu
    NCAR CGD/CSEG PHN: 303-497-1720
    1850 Table Mesa Drive FAX: 303-497-1333
    Boulder CO 80305

    WEB: http://www.cgd.ucar.edu/csm/support/
         http://www.cgd.ucar.edu/csm/support/CSM_Graphics/
    ******************************************************

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



    This archive was generated by hypermail 2b29 : Mon Nov 01 2004 - 14:26:24 MST