Re: Curly vector problem

From: Gerald Creager <gerry.creager_at_nyahnyahspammersnyahnyah>
Date: Thu Oct 20 2011 - 14:25:22 MDT

Noted. I'll give it a try and report back.

Thanks, Mary!
gerry

On 10/20/2011 03:22 PM, Mary Haley wrote:
> Hi Gerry,
>
> My mailer couldn't seem to display all of your email correctly, so I
> couldn't see the image.
>
> One thing you might try (I have to run to a meeting and can't look at
> script in full detail) is to set:
>
>
> res@gsnScalarContour = True
>
> This will cause your contours to be drawn separately, rather than
> coloring your vectors according to the ssh field.
>
> There could also be a draw order issue. You can try (if you haven't
> already):
>
> res@cnFillDrawOrder = "draw"
>
> or
>
> res@cnFillDrawOrder = "predraw"
>
> Finally, I usually recommend people *not* use
> gsn_csm_vector_scalar_map_ce. It's cleaner to use:
>
>
> cnres = True ; variable for contour/map resources
> cnres@cnFillOn =True
> . . .
> vcres = True ; variable for vector resources
> vcres@vcXXXXX = ....
>
> . . .
> vector = gsn_csm_vector(wks,u,v,vcres) ; generate the vectors
> map = gsn_csm_contour_map_ce(wks,ssh,cnres)
> overlay(map,vector)
> draw(map)
> frame(wks)
>
> See example 1 at:
>
> http://www.ncl.ucar.edu/Applications/overlay.shtml
>
> This draws two contour plots over a map, but the idea is the same.
>
> --Mary
>
> On Oct 20, 2011, at 2:02 PM, Gerald Creager wrote:
>
>> I'm trying to plot Sea Surface height and current, given U and V
>> values (and SSH) in a netcdf height.
>>
>> When I run this, I don't see any vectors appear.
>>
>> For completeness,
>> ncl 56> print(min(model1CurrentU))
>> (0)-1.556
>> ncl 57> print(min(model1CurrentV))
>> (0)-1.563
>> ncl 58> print(max(model1CurrentU))
>> (0)1.711
>> ncl 60> print(max(model1CurrentV))
>> (0)2.45
>> print(sqrt(max(model1CurrentU))^2+(max(model1CurrentV))^2)
>> (0)7.7135
>>
>> I've been tweaking and getting approximately nowhere for the last
>> couple of hours, so a clue-by-4 could be in order...
>>
>> The .ncl script is attached. So is an example of the output.
>>
>> I'm seeing some warnings, included below:
>> warning:cnFillOn is not a valid resource in Model1-SSH_vector at this time
>> warning:cnLineLabelsOn is not a valid resource in Model1-SSH_vector at
>> this time
>> warning:cnLevelSelectionMode is not a valid resource in
>> Model1-SSH_vector at this time
>> warning:cnMinLevelValF is not a valid resource in Model1-SSH_vector at
>> this time
>> warning:cnMaxLevelValF is not a valid resource in Model1-SSH_vector at
>> this time
>> warning:cnLinesOn is not a valid resource in Model1-SSH_vector at this
>> time
>> warning:cnExplicitLabelBarLabelsOn is not a valid resource in
>> Model1-SSH_vector at this time
>>
>> Here's an extract from ncl_filedump for the input netcdf data file:
>> dimensions:
>> longitude = 401
>> latitude = 261
>> zlev = 22
>> time = 99 // unlimited
>> variables:
>> float longitude ( longitude )
>> name : longitude
>> long_name : longitude at cell-center
>> units : degree_east
>>
>> float latitude ( latitude )
>> name : latitude
>> long_name : latitude at cell-center
>> units : degree_north
>>
>> float zlev ( zlev )
>> name : zlev
>>
>> float time ( time )
>> name : time
>> long_name : elapsed time
>> units : day
>> start : 2011-10-14 12:00:00 UTC
>> unlimited :
>>
>> float sea_surface_height_above_sea_level ( time, latitude, longitude )
>> name : sea_surface_height_above_sea_level
>> long_name : sea-surface height
>> units : m
>> positive : up
>> missing_value : -9999
>> _FillValue : -9999
>>
>> float eastward_sea_water_velocity ( time, zlev, latitude, longitude )
>> name : eastward_sea_water_velocity
>> long_name : eastward component of velocity
>> units : m s-1
>> missing_value : -9999
>> _FillValue : -9999
>>
>> float northward_sea_water_velocity ( time, zlev, latitude, longitude )
>> name : northward_sea_water_velocity
>> long_name : northward component of velocity
>> units : m s-1
>> missing_value : -9999
>> _FillValue : -9999
>>
>> --
>> Gerry Creager --gerry.creager@tamu.edu <mailto:gerry.creager@tamu.edu>
>> Texas Mesonet -- AATLT, Texas A&M University
>> Cell: 979.229.5301 Office: 979.458.4020 FAX: 979.862.3983
>> Office: 7607 Eastmark Drive, Suite 112, College Station, TX 77840
>>
>> --------------020102000001070502090901
>> Content-Type: text/plain;
>> name="CV-test.ncl"
>> Content-Transfer-Encoding: 7bit
>> Content-Disposition: attachment;
>> filename="CV-test.ncl"
>>
>> ;filename: iasnfs_forecast_2011091612_2011122312.nc
>> ; float sea_surface_height_above_sea_level ( time, latitude, longitude )
>> ; float sea_water_potential_temperature ( time, zlev, latitude,
>> longitude )
>> ; and for future use...
>> ; float eastward_sea_water_velocity ( time, zlev, latitude, longitude )
>> ; float northward_sea_water_velocity ( time, zlev, latitude, longitude )
>> ;
>> ; float longitude ( longitude ) units : degree_east
>> ; float latitude ( latitude ) units : degree_north
>> ; float zlev ( zlev ) units : m positive : down
>> ; float time ( time ) units : day start : 2010-01-01 12:00:00 UTC
>>
>> 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/contrib/calendar_decode2.ncl"
>>
>> ; ###
>> ; ### This is the first prototype of the model intercomparisons.
>> ; ### This version uses Step 2 data instead of Step 3 data but that's
>> an easy fix.
>> ; ###
>>
>> ; ### Info on file and some variable names follows:
>> ; ### iasnfs_forecast_2010010112_2010033112
>> ; ### float sea_surface_height_above_sea_level ( time, latitude,
>> longitude )
>> ; ### float sea_water_potential_temperature ( time, zlev, latitude,
>> longitude )
>> ; ### and for future use...
>> ; ### float eastward_sea_water_velocity ( time, zlev, latitude,
>> longitude )
>> ; ### float northward_sea_water_velocity ( time, zlev, latitude,
>> longitude )
>> ; ### ; ### float longitude ( longitude ) units : degree_east
>> ; ### float latitude ( latitude ) units : degree_north
>> ; ### float zlev ( zlev ) units : m positive : down
>> ; ### float time ( time ) units : day start : 2010-01-01 12:00:00 UTC
>>
>> ;fnameModel1="/home/gerry/GOMEX-PPP/Step2/iasnfs_forecast_2010010112_2010033112.nc"
>> fnameModel1="iasnfs_forecast_2011091612_2011122312.nc"
>> model1=addfile(fnameModel1, "r")
>> ; type = "pdf"
>> ; type = "ps"
>> ; type = "ncgm"
>> ; type = "png"
>> type="x11"
>> Time=model1->time; Elapsed time in DAYS since 2010-01-01 12:00:00 UTC
>> Time@units="days since 2011-09-16 12:00:00 UTC" ; because the file is
>> not set up properly.
>>
>> model1Lat=model1->latitude; Degrees NORTH
>> model1Lon=model1->longitude; Degrees EAST
>>
>> model1Depth=model1->zlev; Positive down, meters (22 levels)
>> ;model1Ssh=100 * model1->sea_surface_height_above_sea_level;Derived
>> from ncl_filedump variable names (and interactively tested)
>> model1Ssh=model1->sea_surface_height_above_sea_level
>> model1Ssh = model1Ssh*100
>>
>> model1Sst=model1->sea_water_potential_temperature(:,0,:,:) ;
>> temperature is in C
>> model1CurrentU=model1->eastward_sea_water_velocity(:,0,:,:)
>> model1CurrentV=model1->northward_sea_water_velocity(:,0,:,:)
>>
>> ; ###
>> wks = gsn_open_wks(type,"Model1-SSH")
>> gsn_define_colormap(wks,"BlAqGrYeOrRe") ; choose colormap
>>
>> ntimes=dimsizes(Time)
>> utcdate=cd_calendar(Time, -5)
>> dyear = day_of_year(utcdate(:,0),utcdate(:,1),utcdate(:,2))
>>
>> ; ###
>> ; ###stop
>> ; ###
>>
>> ;### We're trying something here...
>> res = True ; plot mods desired
>> i = NhlNewColor(wks,0.7,0.7,0.7) ; add gray to colormap
>> ;
>> res@cnFillOn = True ; turn on color for contours
>> res@cnLinesOn = False ; turn off contour lines
>> res@cnLineLabelsOn = False ; turn off contour line labels
>> res@cnExplicitLabelBarLabelsOn = True ; Explicit label-bar values
>> res@cnLevelSelectionMode = "ManualLevels" ; Manually define levels
>> res@cnMinLevelValF = -100 ; Minimum SSH variation from MSL
>> res@cnMaxLevelValF = 80 ; Maximum SSH above MSL
>> ;#
>> ; res@gsnScalarContour = True ; contours desired
>> res@gsnSpreadColors = True ; use full color map
>> res@gsnSpreadColorStart = 4 ; start at color 17
>> res@gsnSpreadColorEnd = 200 ; end at color 200
>> res@gsnRightString = "Sea Surface Height (cm ref. to MSL)"
>> res@gsnAddCyclic = False; Tell NCL this is a regional model output
>> ;#
>> res@tiMainString = "Model 1"
>> res@tiMainOn = True
>> ;#
>> res@mpLandFillColor = "gray" ; set land to be gray
>> res@mpMinLonF = -98.; Select a subregion
>> res@mpMaxLonF = -78.
>> res@mpMinLatF = 18.
>> res@mpMaxLatF = 31.
>> res@mpOutlineDrawOrder = "PostDraw"; Explicitly add a black shoreline
>> ; res@mpFillOn = True; gray landmass
>> ; res@mpGeophysicalLineColor = "Navy"; GeoLine color navy blue
>>
>> res@lbOrientation = "Vertical" ; vertical label bar
>> res@lbLabelStride = 1
>> res@pmLabelBarOrthogonalPosF = -0.01 ; move label bar closer
>>
>> ; ###
>> ; ### Let's do some curly vectors
>> res@vcRefMagnitudeF = 2.0 ; define vector ref mag
>> res@vcRefLengthF = 0.045 ; define length of vec ref
>> res@vcRefAnnoOrthogonalPosF = -1.0 ; move ref vector
>> res@vcRefAnnoArrowLineColor = "black" ; change ref vector color
>> res@vcRefAnnoArrowUseVecColor = False ; don't use vec color for ref
>>
>> res@vcGlyphStyle = "CurlyVector" ; turn on curley vectors
>> ; res@vcLineArrowColor = "white" ; change vector color
>> res@vcLineArrowThicknessF = 2.0 ; change vector thickness
>> res@vcVectorDrawOrder = "PostDraw" ; draw vectors last
>>
>> gsn_define_colormap(wks,"BlAqGrYeOrRevi200") ; choose color map
>>
>> ;## wks = gsn_open_wks(type,"Model1-SSH")
>> ;## gsn_define_colormap(wks,"BlAqGrYeOrRe") ; choose colormap
>> do timeCounter=0,ntimes-1,14
>> res@gsnLeftString = "MJD = 2011:" + dyear(timeCounter)
>> ;###plotSsh=gsn_csm_contour_map(wks,model1Ssh(timeCounter,:,:),res)
>> plot=gsn_csm_vector_scalar_map_ce(wks,model1CurrentU(timeCounter,:,:),
>> model1CurrentV(timeCounter,:,:),model1Ssh(timeCounter,:,:),res)
>> end do
>>
>> exit
>>
>> clear(wks)
>>
>> res@gsnRightString = "Sea Surface Temperature (deg C)"
>> res@cnMinLevelValF = 13 ; Minimum SST deg C
>> res@cnMaxLevelValF = 33 ; Maximum SST deg C
>> wks = gsn_open_wks(type,"Model1-SST")
>> gsn_define_colormap(wks,"BlAqGrYeOrRe") ; choose colormap
>> res = True ; plot mods desired
>> i = NhlNewColor(wks,0.7,0.7,0.7) ; add gray to colormap
>>
>> res@cnFillOn = True ; turn on color for contours
>> res@cnLinesOn = False ; turn off contour lines
>> res@cnLineLabelsOn = False ; turn off contour line labels
>> res@cnExplicitLabelBarLabelsOn = True ; Explicit label-bar values
>> res@cnLevelSelectionMode = "ManualLevels" ; Manually define levels
>> res@cnMinLevelValF = 13 ; Minimum SST deg C
>> res@cnMaxLevelValF = 33 ; Maximum SST deg C
>>
>> ; res@gsnScalarContour = True ; contours desired
>> res@gsnSpreadColors = True ; use full color map
>> res@gsnSpreadColorStart = 4 ; start at color 17
>> res@gsnSpreadColorEnd = 200 ; end at color 200
>> res@gsnRightString = "Sea Surface Temperature (deg C)"
>> res@gsnAddCyclic = False ; Tell NCL this is a regional model output
>>
>> res@tiMainString = "Model 1"
>> res@tiMainOn = True
>>
>> res@mpLandFillColor = "gray" ; set land to be gray
>> res@mpMinLonF = -98. ; Select a subregion
>> res@mpMaxLonF = -78.
>> res@mpMinLatF = 18.
>> res@mpMaxLatF = 31.
>> res@mpOutlineDrawOrder = "PostDraw" ; Explicitly add a black shoreline
>> ; res@mpFillOn = True ; gray landmass
>> ; res@mpGeophysicalLineColor = "Navy" ; GeoLine color navy blue
>>
>> res@lbOrientation = "Vertical" ; vertical label bar
>> res@lbLabelStride = 1
>> res@pmLabelBarOrthogonalPosF = -0.01 ; move label bar closer
>>
>> ; ###
>> ; ### Let's do some curly vectors
>> ; res@vcRefMagnitudeF = 4.0 ; define vector ref mag
>> ; res@vcRefLengthF = 0.045 ; define length of vec ref
>> ; res@vcRefAnnoOrthogonalPosF = -1.0 ; move ref vector
>> ; res@vcRefAnnoArrowLineColor = "black" ; change ref vector color
>> ; res@vcRefAnnoArrowUseVecColor = False ; don't use vec color for ref
>>
>> ; res@vcGlyphStyle = "CurlyVector" ; turn on curley vectors
>> ; res@vcLineArrowColor = "white" ; change vector color
>> ; res@vcLineArrowThicknessF = 2.0 ; change vector thickness
>> ; res@vcVectorDrawOrder = "PostDraw" ; draw vectors last
>>
>> ; gsn_define_colormap(wks,"BlAqGrYeOrRevi200") ; choose color map
>>
>> do timeCounter=0,ntimes-1,14
>> res@gsnLeftString = "MJD = 2011:" + dyear(timeCounter)
>> plotSsh=gsn_csm_contour_map(wks,model1Sst(timeCounter,:,:),res)
>> end do
>>
>

-- 
Gerry Creager -- gerry.creager@tamu.edu
Texas Mesonet -- AATLT, Texas A&M University
Cell: 979.229.5301 Office: 979.458.4020 FAX: 979.862.3983
Office: 7607 Eastmark Drive, Suite 112, College Station, TX 77840
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Oct 20 14:25:34 2011

This archive was generated by hypermail 2.1.8 : Mon Oct 24 2011 - 09:29:35 MDT