trouble with longitude coordinate variable

From: Erik N <nobleeu_at_nyahnyahspammersnyahnyah>
Date: Fri Oct 21 2011 - 20:06:12 MDT

Dear NCL,

I extract variables from a grib file using NCL.
When I extract a "longitude" variable from the file, I notice the that
coordinate range reads as lon: [324.251..35.749].

This minor little detail causes problems for me in later scripts,
which results with errors:
fatal:NclOneDValGetRangeIndex: Non-monotonic coordinate value being
used, can't complete coordinate subscript
fatal:Could not obtain coordinate indexes, unable to perform subscript

I need it to be basically be lon: [-35..35]. How do I do this?
Thank you for your time.
-Erik

; NCL Code
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/wrf/WRF_contributed.ncl"

 ;***************************************************************
 ; Change these parts
 ;***************************************************************
 DATADir = "./" ;input directory
 Files = "WRFPRS_d01*" ;input files
 ncdiro = "./" ;output directory
 NCFILE1 = "pressure" ;output file
;***************************************************************
; Read in post-processed Files
;***************************************************************
 ;files = systemfunc (" ls -1 "+ Files) ; file paths
  FILES = systemfunc (" ls " + Files) ; file paths
  print(FILES)
  numFILES = dimsizes(FILES)
  o = addfile(FILES(0)+".grb","r")
  ;dimt = getfilevardimsizes(a,"U_GRD_GDS1_ISBL")
  dimt = getfilevardimsizes(o,"U_GRD_GDS1_ISBL")
  print(dimt)
  lat = o->g1_lat_0
  lat!0 = "lat"
  lon = o->g1_lon_1
  lon!0 = "lon"
  printVarSummary(lon)
  printVarSummary(lon({-35:35}))

; Terminal Output

[eunoble@dali08] post_Experiment_01 $ time ncl test_10_21_2011.ncl
 Copyright (C) 1995-2011 - All Rights Reserved
 University Corporation for Atmospheric Research
 NCAR Command Language Version 6.0.0
 The use of this software is governed by a License Agreement.
 See http://www.ncl.ucar.edu/ for more details.

Variable: FILES
Type: string
Total Size: 776 bytes
            97 values
Number of Dimensions: 1
Dimensions and sizes: [97]
Coordinates:
(0) WRFPRS_d01.000
<snip>
.
.
.
Variable: dimt
Type: integer
Total Size: 12 bytes
            3 values
Number of Dimensions: 1
Dimensions and sizes: [3]
Coordinates:
(0) 25
(1) 311
(2) 393

Variable: lat
Type: float
Total Size: 1244 bytes
            311 values
Number of Dimensions: 1
Dimensions and sizes: [lat | 311]
Coordinates:
            lat: [-18.402..35.335]
Number Of Attributes: 10
  long_name : latitude
  GridType : Mercator Projection Grid
  units : degrees_north
  Dj : 20
  Di : 20
  Latin : 9.5
  Lo2 : 35.749
  La2 : 35.335
  Lo1 : -35.749
  La1 : -18.402

Variable: lon
Type: float
Total Size: 1572 bytes
            393 values
Number of Dimensions: 1
Dimensions and sizes: [lon | 393]
Coordinates:
            lon: [324.251..35.749]
Number Of Attributes: 10
  long_name : longitude
  GridType : Mercator Projection Grid
  units : degrees_east
  Dj : 20
  Di : 20
  Latin : 9.5
  Lo2 : 35.749
  La2 : 35.335
  Lo1 : -35.749
  La1 : -18.402
fatal:NclOneDValGetRangeIndex: Non-monotonic coordinate value being
used, can't complete coordinate subscript
fatal:Could not obtain coordinate indexes, unable to perform subscript
fatal:Execute: Error occurred at or near line 30 in file test_10_21_2011.ncl
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Oct 21 21:05:37 2011

This archive was generated by hypermail 2.1.8 : Mon Oct 24 2011 - 09:29:35 MDT