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

Hello,

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.

Code:

;**************************************************
; 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"
;**************************************************
begin

; --- Read Calipso Data ------------;
   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

   ; 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((lat.ge.minlat) .and. (lat.le.maxlat) .and. (lon.ge.minlon)
.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
CALIPSO plot
; 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
problem
   back!1 = "xcoord"
   back&xcoord = xcoord

;*************************
; 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 = 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)
   frame(wks)
end

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


_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

CALIPSO_plot_for_NCL_forum.GIF
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