Re: Problem with Y-Axis on WRF Cross-Section; trYCoordPoints; trYAxisType; Wrong Resources?

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Sep 16 2013 - 17:57:54 MDT

Hi Mike,

I think you can get the Y axis that you want simply by setting:

  res@gsnYAxisIrregular2Linear = True

See "axes_1.ncl" at:

http://www.ncl.ucar.edu/Applications/axes.shtml

You shouldn't need the trXXX resource.

--Mary

On Sep 16, 2013, at 2:24 PM, James Madden <jmmadden@alaska.edu> wrote:

> Hello everybody,
>
> I have a simple problem with my Y-axis label. In my code, I locate the problem by commenting "MY PROBLEM IS HERE" just for ease. I have also attached pictures of what my current plot is (WRF Y-Axis.gif) and what I want the y-axis to be (Ideal Y-Axis.gif).
>
> I have an irregular y-axis issue. My file, "lidar_altitudes.txt", lists irregularly-spaced height values that are representative of CALIPSO's range gates. I would like for the y-axis on my WRF cross-section to be representative of those height values.
>
> However, I get the error message: "warning:trYCoordPoints is not a valid resource in WRF Cross Section_contour at this time", and my plot remains the same.
>
> What am I missing? I have looked for additional resources, but none of those offerings have helped.
>
> Thank you much, my code is below.
>
> Mike
>
> Code:
> ; This script will take a cross section of your WRF data, with specified
> ; latitude and longitude coordinates.
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.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
>
> type = "x11"
> wks = gsn_open_wks(type,"WRF Cross Section")
> gsn_define_colormap(wks,"BlAqGrYeOrReVi200")
>
> ; Load CALIPSO latitude and longitude data
>
> b = addfile("/import/archive/u1/uaf/jmmadden/WILDFIRE2009/CALIPSOdata/SUBSETS/CAL_LID_L1-ValStage1-V3-01.2009-06-21T12-23-05ZD.hdf_Subset.hdf","r")
>
> ; Work with the time fields to get a valid time string
> time = (/b->Profile_Time/)
> time@units = "seconds since 1993-01-01 00:00"
> tstring = ut_string(time(:,0), "%Y-%N-%D %H:%M:%S")
>
> xlat = (/b->Latitude/)
> xlon = (/b->Longitude/)
> xlabel = sprintf("%.2f",xlat)+"~C~"+sprintf("%.2f",xlon)
>
> asciiwrite("xlabel",xlabel)
> n = dimsizes(xlat(:,0)) ; n is 1319 (1318 in some files, that's ok
> nn = dimsizes(xlon(:,0)) ; n is 1319 (1318 in some files, that's ok
>
> minlat = xlat(n-1,0)
> maxlat = xlat(0,0) ; this is 67.xxx
> minlon = xlon(nn-1,0)
> maxlon = xlon(0,0) ; this is -150.xxx
>
> lats = (/maxlat,minlat/)
> lons = (/maxlon,minlon/)
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ; GET SPECIAL CALIPSO RANGE GATES (FOR Y-AXIS)
>
> 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"
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> ; READ WRF OUTPUT FILE
>
> a = addfile("/import/archive/u1/uaf/jmmadden/WILDFIRE2009/WRFouts/wrfout_d01_2009-06-21_00:00:00"+".nc","r")
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> times = wrf_user_getvar(a,"times",-1) ; get times in the file
> ntimes = dimsizes(times) ; number of times in the file
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> ; Set some basic resources
> res = True
> res@MainTitle = "REAL-TIME WRF"
> res@Footer = False
>
> pltres = True
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> ; HOURLY LOOP OF PARTICULATE MATTER
>
> do it = 12,14 ; loop over 24 hours
>
> print("Working on time: " + times(it) )
> res@TimeLabel = times(it) ; Set Valid time to use on plots
>
> ; First get the variables we will need
> tc = wrf_user_getvar(a,"tc",it) ; T in C
> z = wrf_user_getvar(a, "z",it) ; grid point height
> pm = a->PM10(it,:,:,:)
> pm@description = "PM10 Dry Mass"
>
> loc = wrf_user_latlon_to_ij(a,lats,lons)
>
> ys = loc(0,0) ; Starting y (j) location
> ye = loc(1,0) ; Ending y (j) location
> xs = loc(0,1) ; Starting x (i) location
> xe = loc(1,1) ; Ending x (i) location
>
>
> ; Interpolate WRF Model data vertically
> angle = 0
> opts = False ; start and end points not specified
>
>
> ; Establish starting and end points in domain
> plane = new(4,float)
> plane = (/ xs,ys, xe,ye /) ; start x;y & end x;y point
> pm_plane = wrf_user_intrp3d(pm,z,"v",plane,angle,opts)
> xcoord = ispan(0,dimsizes(pm_plane(0,:)) - 1, 1) ; xcoord is 157
> tc_plane = wrf_user_intrp3d(tc,z,"v",plane,angle,opts)
>
>
> ; Plotting Options for PM
> opts_pm = res
> opts_pm@cnLevelSelectionMode = "ExplicitLevels"
> Levels = (/3.,3.5,4.,4.5,5.,5.5,6.,6.5,7.,8.,9.,11.,13.,15./)
> opts_pm@cnFillOn = True
> opts_pm@cnFillMode = "RasterFill"
> opts_pm@cnRasterSmoothingOn = True
> opts_pm@cnLinesOn = False ; turn off contour lines
> opts_pm@cnLineLabelsOn = False ; turn off contour labels
> opts_pm@tiYAxisOn = True
> opts_pm@tiYAxisString = "Altitude, km"
> opts_pm@tiXAxisString = "Latitude & Longitude"
> opts_pm@tmXTOn = False
> opts_pm@tmYROn = False
> opts_pm@tmXBMode = "Explicit"
> opts_pm@tmXBValues = xcoord(::15)
> opts_pm@tmXBLabels = xlabel(::130,0)
> opts_pm@tmXBLabelFontHeightF = 0.001
> opts_pm@gsnMaximize = True
> opts_pm@vpXF = 0.105
> opts_pm@vpWidthF = 0.8551
> opts_pm@vpYF = 0.84355
> opts_pm@vpHeightF = 0.51
>
>
> ; MY PROBLEM IS HERE
> opts_pm@trYAxisType = "IrregularAxis"
> opts_pm@trYCoordPoints = hgt
> opts_pm@trYMinF = min(hgt)
> opts_pm@trYMaxF = max(hgt)
>
>
> ; PLOTTING OPTIONS FOR TEMPERATURE
> opts_tc = res
> opts_tc@ContourParameters = (/ 5. /)
> opts_tc@gsnMaximize = True
> opts_tc@vpXF = 0.105
> opts_tc@vpWidthF = 0.8551
> opts_tc@vpYF = 0.84355
> opts_tc@vpHeightF = 0.51
> opts_tc@trYMinF = min(hgt)
> opts_tc@trYMaxF = max(hgt)
>
> contour_pm = wrf_contour(a,wks,pm_plane,opts_pm)
> contour_tc = wrf_contour(a,wks,tc_plane,opts_tc)
>
>
> ; RESOURCES FOR FINAL OVERLAY PLOT
> pltres@gsnMaximize = True
> pltres@vpXF = 0.105
> pltres@vpWidthF = 0.8551
> pltres@vpYF = 0.84355
> pltres@vpHeightF = 0.51
>
> plot = wrf_overlays(a,wks,(/contour_pm,contour_tc/),pltres)
> end do
> end
>
> --
> Mike Madden
> Graduate Research Assistant
> Department of Atmospheric Sciences
> University of Alaska Fairbanks
> IARC 338N
> Office: (907) 474-7618
> Cell: (417) 439-2830
> ---------------------------------------------------------------------
> "Buy the ticket, take the ride." Hunter S. Thompson
> <Ideal Y-Axis.GIF><WRF Y-Axis.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 Mon Sep 16 17:58:07 2013

This archive was generated by hypermail 2.1.8 : Wed Sep 18 2013 - 17:07:30 MDT