Re: why can't I reorder the coordinates?

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed Oct 26 2011 - 15:45:00 MDT

Hi Ann

Your script has more code than it needs. Your "half_year_precip"
already contains coordinate arrays, and the gsn_csm_xxxxx scripts
will automatically look for these. You don't need to read them in
separately.

Also, you have some LAT2D/LON2D variables in your script, but your lat/
lon arrays are actually one-dimensional, so this is misleading.

Finally, you don't need to transpose your data array. The gsn_csm_xxxx
scripts expect the data to be lat x lon, which you already have.

I've attached a simpler version of your script (untested, of course).

--Mary

On Oct 26, 2011, at 3:21 PM, Aqua wrote:

> Hi,
>
> I have accumulated the NLDAS hourly data into half year total and
> output them in .nc files.Here is the variables inside this .nc file:
>
> netcdf halfyearPrecip1979 {
> dimensions:
> lat_110 = 224 ;
> lon_110 = 464 ;
> variables:
> float half_year_precip(lat_110, lon_110) ;
> half_year_precip:units = "mm" ;
> half_year_precip:long_name = "half year
> precipitation" ;
> half_year_precip:_FillValue = -999.f ;
> float lat_110(lat_110) ;
> lat_110:La1 = 25.063f ;
> lat_110:Lo1 = -124.938f ;
> lat_110:La2 = 52.938f ;
> lat_110:Lo2 = -67.063f ;
> lat_110:Di = 0.125f ;
> lat_110:Dj = 0.125f ;
> lat_110:units = "degrees_north" ;
> lat_110:GridType = "Cylindrical Equidistant
> Projection Grid" ;
> lat_110:long_name = "latitude" ;
> float lon_110(lon_110) ;
> lon_110:La1 = 25.063f ;
> lon_110:Lo1 = -124.938f ;
> lon_110:La2 = 52.938f ;
> lon_110:Lo2 = -67.063f ;
> lon_110:Di = 0.125f ;
> lon_110:Dj = 0.125f ;
> lon_110:units = "degrees_east" ;
>
> I am now using NCL to plot this data out but find I can't switch the
> X and Y coordinates where in my plots X is the Lat and Y is the Lon
> always.And there is also this 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'
>
> here is my scripts.
>
> ; ================================================;
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> begin
>
> ;*******************************************
> ; open file and read in data
> ;*******************************************
> f = addfile ("./archive/halfyearPrecip/halfyearPrecip1979.nc",
> "r")
> P = f->half_year_precip
> LAT2D= f->lat_110
> LON2D= f->lon_110
>
> P_transpose = transpose(P)
>
> P_transpose!0 = "lon_110"
> P_transpose!1 = "lat_110"
>
> P_transpose&lon_110 = LON2D
> P_transpose&lat_110 = LAT2D
>
> printVarSummary(P_transpose)
> printVarSummary(LAT2D)
> printVarSummary(LON2D)
>
> ;********************************************
> ; create plot
> ;********************************************
> wks = gsn_open_wks ("x11", "lcnative") ; open workstation
> gsn_define_colormap (wks,"gui_default") ; choose color map
>
> res = True ; plot mods desired
> res@cnFillOn = True ; color fill
> res@cnLinesOn = False ; no contour lines
> res@cnLineLabelsOn = False ; no contour labels
> res@gsnSpreadColors = True ; use total colormap
> res@gsnSpreadColorStart = 4
> res@gsnSpreadColorEnd = -1
> res@cnInfoLabelOn = False ; no contour info
> label
>
> res@mpGridLineDashPattern = 2 ; lat/lon lines as
> dashed
> res@pmTickMarkDisplayMode = "Always" ; turn on tickmarks
>
> res@tiMainString = "Native Lambert Conformal Grid"
> res@tiMainFontHeightF = 0.020 ; smaller title
> ; res@sfXArray = LON2D
> ; res@sfYArray = LAT2D
>
> ; res@gsnAddCyclic = False ; regional data
> ; !!!!! any plot of data that is on a native grid, must use the
> "corners"
> ; method of zooming in on map.
>
> res@mpLimitMode = "Corners" ; choose range of map
>
> res@mpLeftCornerLatF = LAT2D(0)
> res@mpLeftCornerLonF = LON2D(0)
> res@mpRightCornerLatF = LAT2D(dimsizes(LAT2D)-1)
> res@mpRightCornerLonF = LON2D(dimsizes(LON2D)-1)
>
> ; The following 4 pieces of information are REQUIRED to properly
> display
> ; data on a native lambert conformal grid. This data should be
> specified
> ; somewhere in the model itself.
>
> res@mpProjection = "LambertConformal"
> res@mpLambertParallel1F = 30.
> res@mpLambertParallel2F = 55.
> res@mpLambertMeridianF = 45.
>
> ; usually, when data is placed onto a map, it is TRANSFORMED to the
> specified
> ; projection. Since this model is already on a native lambert
> conformal grid,
> ; we want to turn OFF the tranformation.
>
> ; res@tfDoNDCOverlay = True
>
>
> plot = gsn_csm_contour_map(wks,P_transpose,res) ; Draw contours
> over a map.
> ; plot = gsn_csm_contour_map(wks,P,res) ; Draw contours over a
> map.
>
> end
> ______________________________________________________________________________
>
> and here is what printed on the screen with the above codes:
>
>
> Variable: P_transpose
> Type: float
> Total Size: 415744 bytes
> 103936 values
> Number of Dimensions: 2
> Dimensions and sizes: [lon_110 | 464] x [lat_110 | 224]
> Coordinates:
> lon_110: [-124.938..-67.063]
> lat_110: [25.063..52.938]
> Number Of Attributes: 3
> units : mm
> long_name : half year precipitation
> _FillValue : -999
>
>
> Variable: LAT2D
> Type: float
> Total Size: 896 bytes
> 224 values
> Number of Dimensions: 1
> Dimensions and sizes: [lat_110 | 224]
> Coordinates:
> lat_110: [25.063..52.938]
> Number Of Attributes: 9
> La1 : 25.063
> Lo1 : -124.938
> La2 : 52.938
> Lo2 : -67.063
> Di : 0.125
> Dj : 0.125
> units : degrees_north
> GridType : Cylindrical Equidistant Projection Grid
> long_name : latitude
>
>
> Variable: LON2D
> Type: float
> Total Size: 1856 bytes
> 464 values
> Number of Dimensions: 1
> Dimensions and sizes: [lon_110 | 464]
> Coordinates:
> lon_110: [-124.938..-67.063]
> Number Of Attributes: 9
> La1 : 25.063
> Lo1 : -124.938
> La2 : 52.938
> Lo2 : -67.063
> Di : 0.125
> Dj : 0.125
> units : degrees_east
> GridType : Cylindrical Equidistant Projection Grid
> long_name : longitude
>
> Thank you so much for any help!
>
> Best Regards,
> Ann
> _______________________________________________
> 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 Oct 26 15:45:09 2011

This archive was generated by hypermail 2.1.8 : Fri Oct 28 2011 - 10:52:03 MDT