Re: Problem with coordinate variable

From: <wanda7_at_nyahnyahspammersnyahnyah>
Date: Wed Sep 25 2013 - 19:32:06 MDT

Hi Will,

This advice did the trick. Not sure why I've never had to do this before
(give the variables lat and lon their own units and long names....). Perhaps
a problem with the original data going in to the .nc files I use in this
script. But at least the script works perfectly now.

Thanks for your help!

Wanda

On Thu, Sep 26th, 2013 at 9:12 AM, Will Hobbs <Will.Hobbs@utas.edu.au> wrote:

> Wanda
>
> In your script you read in the lat/lon arrays. Assuming that the lat/lon
> arrays don't have units attributes, try this:
>
> >lat@long_name = "latitude"
> >lat@units = "degrees_north"
>
> >lon@long_name="longitude"
> >lon@units = "degrees_east"
>
> >var1&lat = lat
> >var1&lon = lon
>
> This should replace the lines
>
> >var1&lat@units = "degrees north"
> >var1&lon@units = "degrees east"
>
>
> I don't thinkl that in your script var1 has define coord arrays, and even
> if they did you have to assign attributes to the coord arrays BEFORE you
> link them to your variable array (as in my example), rather than once
> they
> are already linked as in your script.
>
> Let me know if that works
>
> Will
>
> On 25/09/13 10:57 PM, "wanda7@tpg.com.au" <wanda7@tpg.com.au> wrote:
>
> >
> >Hi,
> >
> >The script doesn't get to printVarSummary(var1) -it crashes at the line:
> >
> >var1&lat@units = "degrees north"
> >
> >But if I put the printVarSummary(var1) above this line, then the output
> >is:
> >
> >Variable: var1
> >Type: float
> >Total Size: 17625600 bytes
> > 4406400 values
> >Number of Dimensions: 3
> >Dimensions and sizes: [pct | 15] x [lat | 360] x [lon | 720]
> >Coordinates:
> >Number Of Attributes: 3
> > _FillValue : 9.96921e+36
> > long_name : percent_veg
> > units : unitless
> >
> >(I can't understand why this is happening - lat (and lon) print out just
> >fine
> >(i.e. correct values), lat is obviously a dimension of var1, but
> whenever
> >I
> >try to label the lat units as "degrees north", for any of the variables
> >I am
> >reading in or creating (i.e. the difference of the two), I get this
> error.
> >When I don't have
> >
> >var1&lat@units = "degrees north" (as well as the similar command for
> >lon), I
> >get these error messages:
> >
> >(0) check_for_y_lat_coord: Warning: Data either does not contain a
> >valid
> >latitude coordinate array or doesn't contain one at all.
> >(0) A valid latitude coordinate array should have a 'units'
> attribute
> >equal to one of the following values:
> >(0) 'degrees_north' 'degrees-north' 'degree_north' 'degrees
> north'
> >'degrees_N' 'Degrees_north' 'degree_N' 'degreeN' 'degreesN' 'deg north'
> >(0) check_for_lon_coord: Warning: Data either does not contain a
> valid
> >longitude coordinate array or doesn't contain one at all.
> >(0) A valid longitude coordinate array should have a 'units'
> attribute
> >equal to one of the following values:
> >(0) 'degrees_east' 'degrees-east' 'degree_east' 'degrees east'
> >'degrees_E' 'Degrees_east' 'degree_E' 'degreeE' 'degreesE' 'deg east'
> >
> >Using ncdump to look at the .nc files I open in this script, the output
> >is as
> >expected, all the right variables with the right dimensions, the values
> of
> >the var1 variable in the ncdump look fine.
> >
> >Any suggestions would be welcome.
> >
> >Thanks
> >
> >Wanda
> >
> >
> >
> >
> >On Wed, Sep 25th, 2013 at 6:16 PM, Will Hobbs <Will.Hobbs@utas.edu.au>
> >wrote:
> >
> >> Wanda
> >>
> >> What is the output from 'printVarSummary(var1)'?
> >>
> >> Will
> >>
> >> On 25/09/13 6:12 PM, "wanda7@tpg.com.au" <wanda7@tpg.com.au> wrote:
> >>
> >> >
> >> >Hi,
> >> >
> >> >I keep getting error messages related to longitude not being a
> >> coordinate
> >> >variable of another variable, and I've done everything that I usually
> >>do
> >> >to
> >> >solve this problem, but just can't seem to get it right (I've done
> lots
> >> of
> >> >this sort of script before -in fact I pretty much copied and pasted
> >>from
> >> a
> >> >script that actually works)...I'm using NCL 6.1.0b...(the script is
> >> >below...)
> >> >
> >> >Can anyone suggest something that I might be overlooking? I've looked
> >>at
> >> >previous ncl-talk posts and tried various things but so far haven't
> >> found
> >> >a
> >> >solution.
> >> >
> >> >The error messages are:
> >> >
> >> >fatal:No coordinate variable exists for dimension (lat) in variable
> >> (var1)
> >> >fatal:(lat) is not coordinate variable in variable(var1).
> >> >fatal:["Execute.c":7556]:Execute: Error occurred at or near line 31
> in
> >> >file
> >> >diff_plot_var1var2.ncl
> >> >
> >> >Thank you for your advice...
> >> >
> >> >Wanda
> >> >
> >>
> >>>;***********************************************************************
> >>>**
> >> >***********
> >> >
> >> >begin
> >> >
> >> >load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> >> >
> >> >load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> >> >
> >> >load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> >> >
> >> >load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
> >> >
> >> >
> >> >
> >> >setfileoption("nc","SuppressClose",False)
> >> >
> >> >in1 = addfile("sim1.nc","r")
> >> >
> >> >var1 = in1->VAR1
> >> >
> >> >lon = in1->LON
> >> >lat = in1->LAT
> >> >
> >> >landmask = in1->LANDMASK
> >> >
> >> >var1 = mask(var1,landmask,1)
> >> >
> >> >var1!0="pct"
> >> >var1!1="lat"
> >> >var1!2="lon"
> >> >
> >> >var1&lat@units = "degrees north"
> >> >var1&lon@units = "degrees east"
> >> >
> >> >printVarSummary(var1)
> >> >
> >> >
> >> >in2 = addfile("sim2.nc","r")
> >> >
> >> >var2 = in2->VAR2
> >> >
> >> >var2 = mask(var2,landmask,1)
> >> >
> >> >var2!0="pct"
> >> >var2!1="lat"
> >> >var2!2="lon"
> >> >
> >> >var2&lat@units = "degrees north"
> >> >var2&lon@units = "degrees east"
> >> >
> >> >printVarSummary(var2)
> >> >printVarSummary(lon)
> >> >printVarSummary(lat)
> >> >
> >> >
> >> >;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> >> >
> >> >;;; Difference of var1 and var2
> >> >
> >> >
> >> >diff_var1_var2=(/var1-var2/)
> >> >
> >> >diff_var1_var2!0="pct"
> >> >diff_var1_var2!1="lat"
> >> >diff_var1_var2!2="lon"
> >> >
> >> >copy_VarCoords(var1, diff_var1_var2)
> >> >diff_var1_var2&lat@units = "degrees north"
> >> >diff_var1_var2&lon@units = "degrees east"
> >> >printVarSummary(diff_var1_var2)
> >> >
> >> >....
> >> >
> >> >end
> >> >_______________________________________________
> >> >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
Received on Wed Sep 25 19:32:22 2013

This archive was generated by hypermail 2.1.8 : Tue Oct 01 2013 - 14:41:43 MDT