Isolating Latitude and Longitude from full CALIPSO Scan to Plot Domain of Interest - Ind function; Sprintf; X-axis

From: James Madden <jmmadden_at_nyahnyahspammersnyahnyah>
Date: Thu Aug 29 2013 - 15:57:40 MDT


I have plotted a full CALIPSO scan. However, I now want to plot only a
certain region of it.

What makes this equally as challenging is that the latitude and longitude
coordinates at the x-axis must also reflect that change.

I have attempted to use the 'ind' function to extract the wanted latitude
and longitude parts. I have also used 'region_ind'.

I then placed the subscripts within the formatted parts (xlabel) and the
backscatter (back), but that has been unsuccessful. The formatting becomes
disrupted and the plot just remains the same.

I then understood that the backscatter information actually doesn't possess
latitude and longitude information. I have attempted to combine this
information, but I have been unsuccessful.

I have also attempted to use XBValues, and that has worked... but it gives
me a really awful, inaccurate, "smeared" plot.

There is a better way to do this... what am I missing?

Thank you in advance.

The code is below. I locate the problem within the comments. I have also
attached a picture of the full CALIPSO scan for reference.

I posted earlier in regard to a similar matter, which has been solved. I
apologize for annoyingly posting back-to-back questions; CALIPSO has been
giving me trouble recently.


; This will plot CALIPSO data for your domain
; 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"

; --- Read Calipso Data ------------;
   f =

   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

   ; However you also want the values within your own domain. Input max and
min lat/lon values.
   minlat = 63.696
   maxlat = 67.4163
   minlon = -154.725
   maxlon = -142.875

   ; THE PROBLEM IS HERE. Coupling latitude and longitude changes with the
backscatter information.

; ii = ind(( .and. (lat.le.maxlat) .and. (
.and. (lon.le.maxlon)) ; this disrupts the formatting
; ii = region_ind(lat,lon,minlat,maxlat,minlon,maxlon) ;this gives odd
lat/lon values

    xlabel = sprintf("%.2f",lat)+"~C~"+sprintf("%.2f",lon) ;for full
; xlabel = sprintf("%.2f",ii)+"~C~"+sprintf("%.2f",ii)

   ; 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
; stride = dimsizes(tstring)

   ; 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
   xcoord = ispan(0,dimsizes(lat(:,0)) - 1,1) ; to solve non-monotonic
   back!1 = "xcoord"
   back&xcoord = xcoord

; create plot

 wks = gsn_open_wks("x11", "backscatter")

   cmap = new((/36,3/), float)
   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
   res@tiMainString = "Total Attenuated Backscatter"
   res@tiMainFontHeightF = 0.025
   res@tiYAxisFontHeightF = 0.02
   res@cnLevelSelectionMode = "ExplicitLevels"
   res@cnLevels =

   res@tmXTOn = False
   res@tmXBMode = "Explicit"
   res@tmXBValues = xcoord(::stride)
   res@tmXBLabels = xlabel(::stride,0)
   res@tmXBLabelFontHeightF = 0.01
   res@lbLabelFontHeightF = 0.01
   res@lbLabelAngleF = -90.0
   res@vpWidthF = 1.0

   res@gsnDraw = True
   res@gsnFrame = False

   plot = gsn_csm_contour(wks,back,res)

*Mike Madden
*Office:  (907) 474-7618
* "Buy the ticket, take the ride."  Hunter S. Thompson

ncl-talk mailing list
List instructions, subscriber options, unsubscribe:

Received on Thu Aug 29 15:57:55 2013

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