Re: Overlay plots

From: Mittal, Moti <mmittal_at_nyahnyahspammersnyahnyah>
Date: Fri, 8 May 2009 12:56:04 -0400

Mary,

I tried with removing the line res_at_tfDoNDCOverlay = True
but it did not make any difference.

I want to see the vector plots in the subarea only, if it is possible.
My wrfout.nc file is 244 Mb Hence I am not able to e-mail it to you.
Is there a place where I can write it by FTP. We do not have a pub FTP site

Moti
Professor, Department of Environment and Occupational Health
College of Public Health
University of South Florida
13201 Bruce B. Downs Blvd., MDC56
Tampa, Fl 33612-3805

Tel: (813) 974-9571
Fax: (813) 974-4986
Email: mmittal_at_health.usf.edu
________________________________________
From: Mary Haley [haley_at_ucar.edu]
Sent: Wednesday, May 06, 2009 6:47 PM
To: Mittal, Moti
Cc: ncl-talk_at_ucar.edu
Subject: RE: [ncl-talk] Overlay plots

Moti,

You are setting both:

   res_at_tfDoNDCOverlay = True

and:

   u_at_lat2d = lat2d
   u_at_lon2d = lon2d
   v_at_lat2d = lat2d
   v_at_lon2d = lon2d

The first setting should only be used if you know the exact map
projection that your data is on, and you don't want or need to use
lat/lon values to determine the location of your data on the map.

The second settings should be used if you don't know the exact map
projection. This method is slower.

Since you need to zoom in on the map area, you can't use the first
method. So, remove the line:

   res_at_tfDoNDCOverlay = True

This will hopefully get things working.

If not, it would be helpful if you can provide me with your
data file.

--Mary

On Wed, 6 May 2009, Mittal, Moti wrote:

> Mary,
>
> Thank you very much. Now moti.ncl runs without giving any errors.
>
> The vector plot is for the full range of latitude and longitudes but the contour plot is for a sub area (as I desired and used " nres_at_mpMinLatF = 12.5" etc.
> How do I get the vector plot also for the same sub area?
>
> I appreciate your advice.
>
> Moti
> Professor, Department of Environment and Occupational Health
> College of Public Health
> University of South Florida
> 13201 Bruce B. Downs Blvd., MDC56
> Tampa, Fl 33612-3805
>
> Tel: (813) 974-9571
> Fax: (813) 974-4986
> Email: mmittal_at_health.usf.edu
> ________________________________________
> From: Mary Haley [haley_at_ucar.edu]
> Sent: Wednesday, May 06, 2009 4:20 PM
> To: Mittal, Moti
> Cc: ncl-talk_at_ucar.edu
> Subject: Re: Overlay plots
>
>> Mary,
>>
>> Thank you for your very useful suggestion.
>> Now I am not getting any errors but warnings:
>>
>> warning:vcRefAnnoOrthogonalPosF is not a valid resource in WRF_po_contour at this time
>> warning:vcMinDistanceF is not a valid resource in WRF_po_contour at this time
>> warning:vcRefLengthF is not a valid resource in WRF_po_contour at this time
>> warning:vcRefMagnitudeF is not a valid resource in WRF_po_contour at this time
>
> Moti,
>
> You are setting some vector resources right before you end the
> first do loop, and these resources are still set when you
> enter the loop the second time and start doing the contour plot.
>
> Since these resources are being set to the same values inside the
> loop, and since it is inefficient to have lots of code inside a do
> loop, I suggest moving the resources settings to outside both loops, and
> giving them their own names. See the attached sample script.
>
>> I could overlay the vectors over the contour map but I am not sure if still there is some other error.
>> The vector plot which I print before the overlay does not resemble the overlayed vectors on the contour plots.
>>
>> I am attaching the modified script for your possible review. If you advice, I can e-mail the postscript file of the plots.
>
> That would be helpful, especially if you can provide both frames with
> just the vector plot, and then with the vectors overlaid. But, first
> try your script with the resources cleaned up.
>
> --Mary
>
>
>> Thank you again for your help.
>> Moti
>>
>> Script:
>>
>> 1 ;*************************************************
>> 2 ; WRF: color over map with lat/lon labels
>> 3 ;************************************************
>> 4 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>> 5 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>> 6 load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
>> 7 load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
>> 8 begin
>> 9 ;************************************************
>> 10 ; open file and read in data
>> 11 ;************************************************
>> 12 f = addfile ("/home/mmittal/CHENNAI/CHEM/WRFOUT/MAY/wrfout_d01_2007-05-03_06:00:00.n c", "r")
>> 13 ;************************************************
>> 14 ; Read character variable Times; Convert to string for plots
>> 15 ; Read vertical coordinate for plot labels
>> 16 ;************************************************
>> 17 times = chartostring(f->Times) ; built-in function
>> 18 znu = f->ZNU(0,:) ; (Time, bottom_top)
>> 19 lat2d = f->XLAT(0,:,:)
>> 20 lon2d = f->XLONG(0,:,:)
>> 21 U = f->U
>> 22 V = f->V
>> 23 ;************************************************
>> 24 ; U and V are on different grids
>> 25 ; determine the size of the "west_east_stag" dimension
>> 26 ; determine the size of the "south_north_stag" dimension
>> 27 ;************************************************
>> 28 dimU = dimsizes(U) ; demo "dimsizes"
>> 29 mlonU = dimU(3) ; number of "west_east_stag" longitudes
>> 30
>> 31 dimV = dimsizes(V)
>> 32 nlatV = dimV(2) ; number of "south_north_stag" latitudes
>> 33
>> 34
>> 35
>> 36 ;************************************************
>> 37 ; Read ozone at all times and levels
>> 38 ;************************************************
>> 39 x = f->o3 ; (Time, bottom_top, south_north, west_eas t)
>> 40 x = x*1000
>> 41 x_at_units = "ppbv"
>> 42 x_at_description = "O3 concentration"
>> 43
>> 44 ;************************************************
>> 45 ; create plots
>> 46 ;************************************************
>> 47 wks = gsn_open_wks("x11" ,"WRF_po") ; ps,pdf,x11,ncgm,eps
>> 48 ;wks = gsn_open_wks("x11" ,"gsn_vec_scal") ; ps,pdf,x11,ncgm,eps
>> 49 gsn_define_colormap(wks,"BlAqGrYeOrReVi200") ; select color map
>> 50 ;************************************************
>> 51
>> 52 dimx = dimsizes(x) ; dimensions of x
>> 53 ntim = dimx(0) ; number of time steps
>> 54 klev = dimx(1) ; number of "bottom_top" levels
>> 55
>> 56 do nt=0,ntim-1 ; uncomment for loop
>> 57 do kl=0,1
>> 58 res = True ; plot mods desired
>> 1,1 Top
>>
>> 60 res_at_gsnSpreadColors = True ; use full range of colormap
>> 61 res_at_cnFillOn = True ; color plot desired
>> 62 res_at_cnLinesOn = False ; turn off contour lines
>> 63 res_at_cnLineLabelsOn = True ; turn off contour labels
>> 64 res_at_lbLabelAutoStride = True ; Control labelbar spacing
>> 65 res_at_cnLevelSelectionMode = "ManualLevels"
>> 66 res_at_cnMinLevelValF = 25.
>> 67 res_at_cnMaxLevelValF = 35.
>> 68 res_at_cnLevelSpacingF = 2.
>> 69
>> 70 ;************************************************
>> 71 ; Use WRF_contributed procedure to set map resources
>> 72 ;************************************************
>> 73 ; WRF_map_c (f, res, 0)
>> 74 ;************************************************
>> 75 ; set True for native projection (faster)
>> 76 ;************************************************
>> 77 res_at_tfDoNDCOverlay = True
>> 78 ;************************************************
>> 79 res_at_mpMinLatF = 12.5
>> 80 res_at_mpMaxLatF = 13.5
>> 81 res_at_mpMinLonF = 79.5
>> 82 res_at_mpMaxLonF = 80.5
>> 83 x_at_lat2d = lat2d
>> 84 x_at_lon2d = lon2d
>> 85
>> 86
>> 87 ;************************************************
>> 88 ; Turn on lat / lon labeling
>> 89 ;************************************************
>> 90 res_at_pmTickMarkDisplayMode = "Always" ; turn on tickmarks
>> 91
>> 92 ;************************************************
>> 93 ; Loop over all times and levels ( uncomment )
>> 94 ; Demo: one arbitrarily closen time and level
>> 95 ;************************************************
>> 96 ;************************************************
>> 97 ; associate the 2-dimensional coordinates to the variable for plotting
>> 98 ; only if not a native projection [ res_at_tfDoNDCOverlay = False ]
>> 99 ;************************************************
>> 100 res_at_tiMainString = times(nt)
>> 101 res_at_gsnLeftString = x_at_description+" z="+znu(kl)
>> 102
>> 103 plot2 = gsn_csm_contour_map(wks,x(nt,kl,:,:),res)
>> 104 ; now change the size of the tickmark labels
>> 105 res_at_tmXBLabelFontHeightF = 0.02 ; resize tick labels
>> 106 res_at_tmYLLabelFontHeightF = 0.02
>> 107 ;***********************************************
>> 108 u = 0.5*(U(nt,kl,:,0:mlonU-2)+U(nt,kl,:,1:mlonU-1))
>> 109 v = 0.5*(V(nt,kl,0:nlatV-2,:)+V(nt,kl,1:nlatV-1,:))
>> 110 u_at_lat2d = lat2d
>> 111 u_at_lon2d = lon2d
>> 112 v_at_lat2d = lat2d
>> 113 v_at_lon2d = lon2d
>> 114 ;***********************************************
>> 115
>> 116 delete(res)
>> 117 res = True
>> 118
>> 119 res_at_vcRefMagnitudeF = 1. ; define vector ref mag
>> 120 res_at_vcRefLengthF = 0.0080 ; define length of vec ref
>> 121 res_at_vcRefAnnoOrthogonalPosF = -1.0 ; move ref vector
>> 122 res_at_vcMinDistanceF = 0.001 ; larger means sparser
>> 123 ;res_at_vcLineArrowHeadMaxSizeF = 0.0075 ; default: 0.05 (LineArrow), 0.012 (CurlyVe ctor)
>> 124 ;res_at_vcGlyphStyle = "LineArrow" ; default: "LineArrow"
>> 125
>> 126 ;plot1 = gsn_csm_vector_map(wks,u, v, res)
>> 127
>> 128 plot1 = gsn_csm_vector(wks,u, v, res)
>> 129
>> 130
>> 131 ;***********************************************
>> 132 overlay(plot2,plot1)
>> 133 psres =True
>> 134 maximize_output(wks,psres)
>> 135 end do
>> 136 end do
>> 137 end
>> 138
>>
>> Professor, Department of Environment and Occupational Health
>> College of Public Health
>> University of South Florida
>> 13201 Bruce B. Downs Blvd., MDC56
>> Tampa, Fl 33612-3805
>>
>> Tel: (813) 974-9571
>> Fax: (813) 974-4986
>> Email: mmittal_at_health.usf.edu
>> ________________________________________
>> From: Mary Haley [haley_at_ucar.edu]
>> Sent: Tuesday, May 05, 2009 9:46 AM
>> To: Mittal, Moti
>> Cc: ncl-talk_at_ucar.edu
>> Subject: Re: Overlay plots
>>
>> Moti,
>>
>> The error message is occuring because you are trying to overlay a map
>> plot on a map plot. You can't overlay maps on other maps, but you can
>> overlay vectors and contours on maps.
>>
>> At the least, you need to change:
>>
>> plot1 = gsn_csm_vector_map(wks,u, v, res)
>>
>> to
>>
>> plot1 = gsn_csm_vector(wks,u, v, res)
>>
>> Also, I didn't look at your whole script, but I did notice that you
>> are sharing resources between the two plot calls.
>>
>> Since one plot is for contours and the other is for vectors, you
>> should use different resource lists, or make sure you call:
>>
>> delete(res)
>>
>> once you are finished with the first plot. This way you start with a
>> clean resource list and you aren't trying to apply contour resources
>> to a vector plot (or vice versa).
>>
>> --Mary
>>
>> _______________________________________________
>> 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 Fri May 08 2009 - 10:56:04 MDT

This archive was generated by hypermail 2.2.0 : Mon May 11 2009 - 09:43:46 MDT