Re: Coordinate variables must be the same dimension as their dimension

From: H.Dang <danghy_at_nyahnyahspammersnyahnyah>
Date: Fri Dec 21 2012 - 08:35:40 MST

Hi Dave,

Yeah you're right. I reversed some lat and lon - the code works now. Thank
you!

Have a great holiday.

Hongyan
On Thu, Dec 20, 2012 at 8:51 PM, Dave Allured - NOAA Affiliate <
dave.allured@noaa.gov> wrote:

> Be careful. SWCF and v_swf_cloud are correct the way they are. The
> problem is the way you are subscripting into them. You have the lat
> and lon subscripts reversed in many places. nx (144) is associated
> with longitudes, and ny (96) is associated with latitudes.
>
> For example, on line 17 you have this:
>
> v_cloud_yr(ilat,jlon) = avg(v_swf_cloud(ilat,jlon,:))
>
> But I think you mean this:
>
> v_cloud_yr(ilat,jlon) = avg(v_swf_cloud(jlon,ilat,:))
>
> Now back on line 14, you might want new((/96,144/),double) instead of
> new((/144,96/),double). The dim sizes in lines 15 and 16 should be
> switched. And so on. Please start at line 14 and make sure every
> following line is using subscripts consistently.
>
> --Dave
>
> On Thu, Dec 20, 2012 at 6:19 PM, H.Dang <danghy@gmail.com> wrote:
> > Hi Dave,
> >
> > Thanks for your message! The head of the nc file is short:
> >
> > dimensions:
> > nx = 144 ;
> > ny = 96 ;
> > time = 12 ;
> > variables:
> > double lon(nx) ;
> > lon:long_name = "longitude" ;
> > lon:units = "degrees_east" ;
> > double lat(ny) ;
> > lat:long_name = "latitude" ;
> > lat:units = "degrees_north" ;
> > double gw(ny) ;
> > gw:long_name = "gauss weights" ;
> > double time(time) ;
> > time:long_name = "month" ;
> > double SWCF(nx, ny, time) ;
> > SWCF:long_name = "Short wave cloud forcing" ;
> > SWCF:units = "W/m2" ;
> > double LWCF(nx, ny, time) ;
> > LWCF:long_name = "Long wave cloud forcing" ;
> > LWCF:units = "W/m2" ;
> >
> > So I want to change the "nx" and "ny" in v_swf_cloud (SWCF) to latitude
> and
> > longitude. I don't know if nx and ny influences. Thanks again.
> >
> > Hongyan
> >
> > On Thu, Dec 20, 2012 at 7:20 PM, Dave Allured - NOAA Affiliate
> > <dave.allured@noaa.gov> wrote:
> >>
> >> I think you might have reversed the correct meaning of lat and lon
> >> subscripts in line 17. What is the result of printVarSummary
> >> (v_swf_cloud)?
> >>
> >> --Dave
> >>
> >> On Thu, Dec 20, 2012 at 4:35 PM, H.Dang <danghy@gmail.com> wrote:
> >> > Hello,
> >> >
> >> > I met some problem when defining coordinate variables, the error
> message
> >> > is:
> >> >
> >> > fatal:Coordinate variables must be the same dimension as their
> dimension
> >> > fatal:No coordinate variable exists for dimension (V_lat) in variable
> >> > (v_cloud_yr)
> >> > fatal:["Execute.c":7556]:Execute: Error occurred at or near line 33 in
> >> > file
> >> > cloud_cor.ncl
> >> >
> >> > My code is:
> >> >
> >> > 1 ;*******************************************
> >> > 2 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> >> > 3 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> >> > 4 begin
> >> > 5
> >> > 6 f1 = addfile("cld_int.nc","r")
> >> > 7 V_swf_cloud = f1->SWCF
> >> > 8 V_lat = f1->lat
> >> > 9 V_lon = f1->lon
> >> > 10 v_swf_cloud = V_swf_cloud(:,:,:)
> >> > 11 lat_cloud = V_lat(:)
> >> > 12 lon_cloud = V_lon(:)
> >> > 13
> >> > 14 v_cloud_yr = new((/144,96/),double)
> >> > 15 do ilat = 0,144-1
> >> > 16 do jlon = 0,96-1
> >> > 17 v_cloud_yr(ilat,jlon) = avg(v_swf_cloud(ilat,jlon,:))
> >> > 18 end do ; jlon
> >> > 19 end do ; ilat
> >> > 20
> >> > 21 lat_cloud!0 = "V_lat"
> >> > 22 lat_cloud&V_lat = lat_cloud
> >> > 23 lon_cloud!0 = "V_lon"
> >> > 24 lon_cloud&V_lon = lon_cloud
> >> > 25 printVarSummary(lat_cloud)
> >> > 26 printVarSummary(lon_cloud)
> >> > 27
> >> > 28 printVarSummary(v_cloud_yr)
> >> > 29 v_cloud_yr!0 = "V_lat" ;"lat"
> >> > 30 v_cloud_yr!1 = "V_lon" ;"lon"
> >> > 31 printVarSummary(v_cloud_yr)
> >> > 32
> >> > 33 v_cloud_yr&V_lat= lat_cloud
> >> > 34 v_cloud_yr&V_lon= lon_cloud
> >> > 35
> >> > 36 end
> >> >
> >> > Could you please give some suggestion about the line 33? Thanks.
> >> >
> >> > Hongyan
> >> >
> >> > P.S. Following is all the information on screen:
> >> >
> >> > Variable: lat_cloud
> >> > Type: double
> >> > Total Size: 768 bytes
> >> > 96 values
> >> > Number of Dimensions: 1
> >> > Dimensions and sizes: [V_lat | 96]
> >> > Coordinates:
> >> > V_lat: [ -90..89.99999999999999]
> >> > Number Of Attributes: 2
> >> > units : degrees_north
> >> > long_name : latitude
> >> >
> >> > Variable: lon_cloud
> >> > Type: double
> >> > Total Size: 1152 bytes
> >> > 144 values
> >> > Number of Dimensions: 1
> >> > Dimensions and sizes: [V_lon | 144]
> >> > Coordinates:
> >> > V_lon: [ 0..357.5]
> >> > Number Of Attributes: 2
> >> > units : degrees_east
> >> > long_name : longitude
> >> >
> >> > Variable: v_cloud_yr
> >> > Type: double
> >> > Total Size: 110592 bytes
> >> > 13824 values
> >> > Number of Dimensions: 2
> >> > Dimensions and sizes: [144] x [96]
> >> > Coordinates:
> >> > Number Of Attributes: 1
> >> > _FillValue : 9.969209968386869e+36
> >> >
> >> > Variable: v_cloud_yr
> >> > Type: double
> >> > Total Size: 110592 bytes
> >> > 13824 values
> >> > Number of Dimensions: 2
> >> > Dimensions and sizes: [V_lat | 144] x [V_lon | 96]
> >> > Coordinates:
> >> > Number Of Attributes: 1
> >> > _FillValue : 9.969209968386869e+36
> >> > fatal:Coordinate variables must be the same dimension as their
> dimension
> >> > fatal:No coordinate variable exists for dimension (V_lat) in variable
> >> > (v_cloud_yr)
> >> > fatal:["Execute.c":7556]:Execute: Error occurred at or near line 33 in
> >> > file
> >> > cloud_cor.ncl
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Dec 21 08:36:33 2012

This archive was generated by hypermail 2.1.8 : Fri Dec 21 2012 - 10:43:23 MST