Re: latGlobeFo question

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Mon May 10 2010 - 11:23:53 MDT

The 1st rule of data processing is to "look at the data"

If you do a

%> ncl_filedump 3B42.100331.21.6A.HDF

[SNIP]
    dimensions:
       scan = 1
       longitude = 1440
       latitude = 400
    variables:
       float precipitation ( scan, longitude, latitude )
          hdf_name : precipitation
[SNIP]

ori, in your NCL script

   x=addfile("3B42.100331.21.6A.HDF", "r")
   data=x->precipitation(0,:,:)
   printVarSummary(data)

Variable: data
Type: float
Total Size: 2304000 bytes
             576000 values
Number of Dimensions: 2
Dimensions and sizes: [longitude | 1440] x [latitude | 400]
Coordinates:
Number Of Attributes: 1
   hdf_name : precipitation

===
So, dimension 0 is longitude and dimension 1 is latitude.
The error message explicitly staes that the dimensions sizes
are not correct.

"fatal:Coordinate variables must be the same dimension as their dimension"

You should have

data!0 = "lon"
data!1 = "lat"
data&lat=lat
data&lon=lon

If you are planning to do any spatial graphics in NCL, the
gsn_* graphic functions require (lat,lon) order, hence you will have
to reorder

   prc = data(lat|:,lon|:)
   prc@units = "..."

A link you might find useful

http://www.ncl.ucar.edu/Applications/HiResPrc.shtml

On 05/10/2010 10:51 AM, Tong Qi wrote:
> Dennis,
>
> For some reason, this approach does not seem to work for HDF4 files. It
> had worked for an HDF-EOS2 file, but I get the error
> "fatal:Coordinate variables must be the same dimension as their
> dimension" when I try the assignments "data&lat=lat" and "data&lon=lon."
>
> Here's a snippet of my script:
>
> x=addfile("3B42.100331.21.6A.HDF", "r")
> data=x->precipitation(0,:,:)
> data!0="lat"
> data!1="lon"
>
> lon=lonGlobeFo(1440, "lon", "longitude", "degrees_east")
> lon=(/ lon - 180. /)
> lon&lon=lon
>
> lat=fspan(-49.75,49.75,400)
> lat=lat(::-1)
> lat!0="lat"
> lat@units="degrees_north"
> lat&lat=lat
>
> data&lat=lat
> data&lon=lon
>
>
> On Mon, May 10, 2010 at 11:03 AM, Dennis Shea <shea@ucar.edu
> <mailto:shea@ucar.edu>> wrote:
>
> Some variation
>
> latS = 15
> latN = 45.
> lonL = 95.
> lonR = 135.
>
>
> dlat = 0.25
> dlon = 0.25
>
> nlat = floattointeger((latN-latS)/dlat + 1 )
> mlon = floattointeger((lonR-lonL)/dlon + 1 )
>
> lat = fspan(latS,latN,nlat)
> lon = fspan(lonL,lonR,mlon)
> lat!0 = "lat"
> lon!0 = "lon"
> lat@units = "degrees_north"
> lon@units = "degrees_east"
> lat&lat = lat
> lon&lon = lon
>
>
> On 5/10/10 9:57 AM, Tong Qi wrote:
> > Hello ncl-talk,
> >
> > I was wondering if there was a way to set the latitude bounds of the
> > latGlobeFo function to 50N to 50S instead of its standard 90N to
> 90S. If
> > not, is there some other way to generate latitudes and associated
> > metadata for the smaller range?
> >
> > Thanks,
> > Tong
> >
> >
> >
> > _______________________________________________
> > 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
>
>

-- 
======================================================
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 |
======================================================
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon May 10 11:24:04 2010

This archive was generated by hypermail 2.1.8 : Thu May 13 2010 - 10:03:00 MDT