Re: Irregular coordinate array: Plotting CALIPSO data, X-Axis latitude and longitude values

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Wed Aug 28 2013 - 19:30:03 MDT

Hi Mike,
The message is telling you that the array you are using for the 2nd dimension of the data variable (used for the X Axis, i.e.:

 lat(:,0)
assigned as
 back!1 = "lat"
 back&lat = lat(:,0)

is non-monotonic. (It increases in some places and decreases in others.) NCL cannot handle non-monotonic 1d coordinates. The other problem is that you are trying to assign the tmXBValues resource using a string array.
I would suggest that you make the X coordinate array a simple array of ascending integers and then use it for tmXBValues.

xcoord = ispan(0,dimsizes(lat(:,0)) - 1,1)

back!1 = "xcoord"
back&xccord = xcoord

….

res@tmXBMode = "Explicit"
res@tmXBValues = xcoord(::stride,0)
res@tmXBLabels = xlabel(::stride,0)


Obviously I can't test this so it may need a little tweaking.
 -dave

On Aug 28, 2013, at 6:33 PM, James Madden <jmmadden@alaska.edu> wrote:

> Hello,
>
> I am experiencing trouble plotting the x-axis latitude and longitude coordinates.
>
> It seems that the x-axis latitude and longitude values are crunched to the bottom left of the plot. Additionally, a message is accompanied: "warning:ScalarFieldSetValues: irregular coordinate array sfXArray non-monotonic: defaulting sfXArray."
>
> I have looked for help in this forum, but the help doesn't seem to be applicable to my situation. I am a little confused - what am I missing? I have altered the TickMark resources several times, but I don't seem to be making progress.
>
> I have attached the code below, and a picture of the current plot is attached.
>
> Thanks in advance.
>
> Code:
>
> ;**************************************************
> ; This program intends to plot CALIPSO data.
> ; Author: Cory Wolff from UCAR (thank him in thesis), edits by J. Madden
> ;**************************************************
> 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"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/ut_string.ncl"
> load "color_map.ncl"
>
> ;**************************************************
>
> begin
>
> ; --- Read Calipso------------;
> f = addfile("/import/archive/u1/uaf/jmmadden/WILDFIRE2009/CALIPSOdata/HDF/CAL_LID_L1-ValStage1-V3-01.2009-06-20T21-33-08ZD.hdf","r")
>
> back1 = f->Total_Attenuated_Backscatter_532
> dims = getvardims(back1)
>
> ; Reverse the vertical array
> back1 = back1(:,::-1)
>
> ; Reorder using string dimension names
> back = back1($dims(1)$|:,$dims(0)$|:)
> back@_FillValue = -9999
> back@units = "km~S~-1~NN~ sr~S~-1~NN~"
>
> ; Get the lat and lon arrays for the x-axis
> lat = f->Latitude
> lon = f->Longitude
> xlabel = sprintf("%.2f",lat)+"~C~"+sprintf("%.2f",lon)
>
> ; Work with the time fields to get a valid time string
> time = f->Profile_Time
> time@units = "seconds since 1993-01-01 00:00"
> tstring = ut_string(time(:,0), "%Y-%N-%D %H:%M:%S")
> tstring2 = ut_string(time(:,0), "%Y-%N-%D_%H-%M-%S")
>
>
> ; Set stride intervals for x-axis
> stride = dimsizes(tstring)/15
>
> ; Get the altitude values.
> hgt = asciiread("lidar_altitudes.txt", -1, "float")
> hgt = hgt(::-1) ; Reverse this array too
> hgt!0 = "hgt"
>
> hgt@long_name = "Altitude, km"
> hgt@units = "km"
>
> ; Assign new dimensions and attributes
> back!0 = "hgt"
> back&hgt = hgt
> back!1 = "lat"
> back&lat = lat(:,0)
>
> ; Get the surface elevation
> topo = f->Surface_Elevation(:,0)
> topo!0 = "lat"
> topo&lat = lat(:,0)
>
> ;*************************
> ; create plot
> ;*************************
>
> wks = gsn_open_wks("x11", "backscatter")
>
> cmap = new((/36,3/), float)
> gen_backscatter_cmap(cmap)
> setvalues wks
> "wkColorMap" : cmap
> end setvalues
>
> setvalues NhlGetWorkspaceObjectId()
> "wsMaximumSize": 300000000
> end setvalues
>
> res = True
> res@cnFillOn = True ; color plot desired
> res@cnLinesOn = False
> res@cnRasterModeOn = True
>
> res@gsnSpreadColors = True ; use all colors
> res@gsnAddCyclic = False
> res@gsnMaximize = True
> res@gsnLeftString = "UTC: "+tstring(0)+" to "+tstring(dimsizes(tstring)-1)
>
> res@tiMainString = "Total Attenuated Backscatter"
> res@tiMainFontHeightF = 0.025
> res@tiYAxisFontHeightF = 0.02
>
> res@cnLevelSelectionMode = "ExplicitLevels"
> res@cnLevels = (/0.0001,0.0002,0.0003,0.0004,0.0005,0.0006,0.0007,0.0008,0.0009,0.001,0.0015,0.002,0.0025,0.003,0.0035,0.004,0.0045,0.005,0.0055,0.006,0.0065,0.007,0.0075,0.008,0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.1/)
>
> res@tmXTOn = False
> res@tmXBMode = "Explicit"
> res@tmXBValues = xlabel(::stride,0)
> res@tmXBLabels = xlabel(::stride,0)
> res@tmXBLabelFontHeightF = 0.015
>
> res@lbLabelFontHeightF = 0.015
> res@lbLabelAngleF = -90.0
>
> res@vpWidthF = 1.0
>
> res@gsnDraw = True
> res@gsnFrame = False
>
> plot = gsn_csm_contour(wks,back,res)
> frame(wks)
> end
>
> --
> Mike Madden
> Graduate Research Assistant
> Department of Atmospheric Sciences
> University of Alaska Fairbanks
> IARC 338N
> Office: (907) 474-7618
> ---------------------------------------------------------------------
> "Buy the ticket, take the ride." Hunter S. Thompson
> <CALIPSO Plot for NCL forum.GIF>_______________________________________________
> 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 Aug 28 19:30:13 2013

This archive was generated by hypermail 2.1.8 : Fri Aug 30 2013 - 14:04:57 MDT