Re: coloring vectors using a scalar

From: Nicole Schiffer <nschiff2_at_nyahnyahspammersnyahnyah>
Date: Thu Nov 19 2009 - 12:39:16 MST

Mary-

Here are the files you requested. You are correct about the scalar data. Thanks for your help.

-Nicole

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Nicole Schiffer
* Graduate Research Assistant
* Department of Atmospheric Sciences
* University of Illinois, Urbana-Champaign
* Email: nschiff2 [at] illinois [dot] edu
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

----- "Mary Haley" <haley@ucar.edu> wrote:
| Hi Nicole,

|
Your scalar data is an array made up of -1, 0, 1, and missing values, correct? This is the field that you want to color your vectors according to?

|
It would help if you could provide the data.

|
If you can, then add this resource:

|
res@gsnDebugWriteFileName = "formary"

|
rerun your script, and email me the "formary.ncl" and "formary.nc" files, and I will be able to run your code using the exact same data and resources as you.

|
If the files are too big to email, then you can ftp them. See the "ftp" section at: http://www.ncl.ucar.edu/report_bug.shtml

|
Thanks,

|
--Mary

|

On Nov 17, 2009, at 2:41 PM, Nicole Schiffer wrote:

| Mary-
|
| Thank you for your help. I think I implemented the changes you suggested, but it is still coloring the vectors by magnitude. I attached the full script--relevant resources start at line 208 . Please let me know if any more information would be helpful.
|
| Nicole
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| * Nicole Schiffer
| * Graduate Research Assistant
| * Department of Atmospheric Sciences
| * University of Illinois, Urbana-Champaign
| * Email: nschiff2 [at] illinois [dot] edu
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| ----- "Mary Haley" < haley@ucar.edu > wrote:
| | Hi Nicole,

| |
I think you're almost there. The ***FieldData and sfDataArray resources should not be set by you. These are being set internally by the gsn_csm_vector_xxx routine.

Also, you don't need to set vcUseScalarArray, as this is set internally when you call gsn_csm_vector_scalar_map.

| |
By default, the gsn_csm_vector_scalar_map routine should be coloring your vectors according to the given scalar field.

| |
I've attached a sample script and PNG image to show this. Please let me know if you are not seeing the same results.

| |
--Mary

| |
| | [image/png:vector-1.png]
| |
| |

| |

| |

| |

On Nov 13, 2009, at 7:32 PM, Nicole Schiffer wrote:

| | I'm trying to color vectors using a scalar with the gsn_csm_vector_scalar_map function. My understanding is that this should be the default behavior, but the vectors are still colored by magnitude. I've included a code snippet below. Commented code are options that I have tried in various combinations. Thanks.
| |
| | ; Open a workspace to begin creating the plot
| | wsplot = gsn_open_wks("ps", "./graphs/anomavgNARR."+filemidout+"."+i)
| |
| | ; Change options for plot (res=True)
| | res = True
| |
| | ; Color fill on, contours off, line labels off, manual level selection
| | ; mode, spacing every 1.0 units, min value 270, max value 320, use
| | ; entire color spectrum
| | res@gsnSpreadColors = True
| |
| | ; set vector resources
| | res@vfXCStride = 4
| | res@vfYCStride = 4
| | res@vcRefMagnitudeF = 100000.0
| | res@vcRefLengthF = 0.008
| | res@vcGlyphStyle = "LineArrow"
| | res@vcRefAnnoOrthogonalPosF = -1.0
| | res@vcRefAnnoParallelPosF = 1.0
| | res@vcLineArrowThicknessF = 3.0
| | res@vcVectorDrawOrder = "PostDraw"
| | res@vcMapDirection = False
| |
| | ;res@sfDataArray = vectorcolor
| | ;res@vcLevelSelectionMode = "ExplicitLevels"
| | res@vcScalarFieldData = vectorcolor
| | ;res@vcVectorFieldData =
| | res@vcMonoLineArrowColor = False
| | ;res@sfMissingValueV = -999
| | res@vcScalarMissingValColor = -1
| | res@vcUseScalarArray = True
| | ;res@vcLevelColors = (/0,1,2,3/)
| | ;res@vcLevels = (/-0.5,0,0.5/)
| | ;res@vcLevelCount = 3
| |
| | ; Draw map boundaries: coastlines, national boundaries, and states/provinces
| | res@mpAreaMaskingOn = False
| | res@mpFillOn = False
| | res@mpDataBaseVersion="Ncarg4_1"
| | res@mpOutlineBoundarySets = "National"
| | res@mpOutlineSpecifiers = (/"Canada:Provinces", "United States:States", "Mexico:States"/)
| |
| | ; Always display tick marks
| | res@pmTickMarkDisplayMode = "Always"
| | ; Do not add cyclic reference point, maximize plot to workstation size,
| | ; orient paper horizontally, 0.5 inch paper margin
| | res@gsnAddCyclic = False
| | res@gsnMaximize = True
| | res@gsnPaperOrientation = "landscape"
| | res@gsnPaperMargin = 0.5
| | ; blank strings above image
| | res@gsnCenterString = ""
| | res@gsnRightString = ""
| | res@gsnLeftString = ""
| | res@gsnScalarContour = False
| |
| | ; Define map projection properties
| | res@mpProjection = "LambertConformal"
| | res@mpLambertMeridianF = 253
| | res@mpLambertParallel1F = 50
| | res@mpLambertParallel2F = 50
| |
| | ; Define display boundaries
| | res@mpLimitMode = "Corners"
| | res@mpLeftCornerLatF = lat2d(0,nlat/6)
| | res@mpLeftCornerLonF = lon2d(0,nlat/6)
| | res@mpRightCornerLatF = lat2d(mlon/2,nlat-nlat/3)
| | res@mpRightCornerLonF = lon2d(mlon/2,nlat-nlat/3)
| | ; map perimeter on, map fill on, no map rotation
| | res@mpPerimOn = True
| | res@mpCenterRotF = 0
| | ; 10deg lat-lon grid spacing, show lat-lon grid, make lat-lon lines
| | ; dashed
| | res@mpGridSpacingF = 10.0
| | res@mpGridAndLimbOn = True
| | res@mpGridLineDashPattern = 16
| | ; NCDOverlay is false
| | res@tfDoNDCOverlay = False
| |
| | ; Create the label bar for the colored contours
| | res@lbLabelFontHeightF = 0.020
| | res@lbTitleString = ""
| | res@lbLabelFont = 21
| | res@lbLabelAutoStride = False
| | res@lbLabelStride = 10
| | res@lbOrientation = "Vertical"
| | res@pmLabelBarOrthogonalPosF = 0.02
| | res@pmLabelZone = 2
| | res@lbBoxLinesOn = True
| |
| | ; Define the colorscale for the plot and reverse it (R-W-B)
| | gsn_define_colormap(wsplot, "cosam")
| |
| | ; Create the plot
| | plot = gsn_csm_vector_scalar_map(wsplot, plotthisu(:,:), plotthisv(:,:), vectorcolor(:,:), res)
| |
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | * Nicole Schiffer
| | * Graduate Research Assistant
| | * Department of Atmospheric Sciences
| | * University of Illinois, Urbana-Champaign
| | * Email: nschiff2 [at] illinois [dot] edu
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| | _______________________________________________
| | ncl-talk mailing list
| | List instructions, subscriber options, unsubscribe:
| | http://mailman.ucar.edu/mailman/listinfo/ncl-talk
| | <avganomplot_moistflx.ncl>
|

Received on Thu Nov 19 12:39:35 2009

This archive was generated by hypermail 2.1.8 : Mon Nov 15 2010 - 12:48:08 MST