Re: Problem with coordinate variable

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed Sep 25 2013 - 08:53:08 MDT

If VAR1 and VAR2 are on rectilinear grids, NCL will automatically
associate *all* coordinate variables with the parent variable.
If the variables LON and LAT are one dimensional, they will become
part of the variable data structure

(eg, var1, var2) var1 = in1->VAR1
printVarSummary(var1) ; (?,LAT,LON)

var2 = in1->VAR1
printVarSummary(var2) ; (?,LAT,LON)

In this is the case, there is no need for you to manually
perform this task.

diff_var1_var2=(/var1-var2/)
copy_VarCoords(var1, diff_var1_var2)
diff_var1_var2@long_name = "..."
diff_var1_var2@units = var1@units
printVarSummary(diff_var1_var2)

========

There is nothing special about the dimension names "lat", "lon".
They are appear in many examples but that is only because
they are commonly used.

========
re: what you did that was missing, you did not use &

  var1!0="pct"
  var1!1="lat"
  var1!2="lon"

  var1&lat = lat

Again, this need not be done if the file variable LAT AND LON
ARE COORDINATE VARIABLES.

On 9/25/13 2:12 AM, 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 08:53:16 2013

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