Vector/windbarb problem

From: Ertl, John <John.Ertl_at_nyahnyahspammersnyahnyah>
Date: Mon, 22 Nov 2004 12:36:14 -0800

All,

Either my recollection if U and V components is backwards (very possible), I
have made an error in my program (also very possible) or the wind barb
plotting routine is not working as it should.

I have included a short Py_Ngl program. I plot the U and V in a vertical.
The U component looks to be doing as it should but the V looks to be not
only be backwards but when combined with the U I do not get wind directions
I would expect.

I am going to go to my old text but I remember a + V as a wind from the
South the North. Also try a U and V of the same speed and dir. I would
expect a U of -10 and a V of -10 to give a dir of 45...I look to get closer
to 90.
  
Am I using the Ngl.vector(wks,ugrid,vgrid,uv_res) all wrong? Am I plotting
this wrong?

Thanks for any help?

import Ngl
import getopt
import sys
import os
import Numeric

def imagemaker(path = "/opt/global/webservices/apache/app/tmd/html/"):
    roughtName = "test"
    tempgridlevels = [ 1000., 975., 950., 925., 850., 800., 750.,
700., 650., 600., 550.,
        500., 450., 400., 350., 300., 250., 200.,]
    tempgridfcsthour = [ 6., 12., 18., 24.,]

    ugridvalues = [[ -2.05150312, 6.35332027, 6.76982279, 2.55292673,],
 [ -2.86678782, 5.0433381 , 6.97366233, 2.80842602,],
 [ -4.05589724, 3.41150545, 7.49888353, 3.23786891,],
 [ -4.01037941, 2.37747494, 7.55492071, 3.59700497,],
 [ -0.16920371, 4.02244309, 8.69651883, 5.00833914,],
 [ 2.6121914 , 4.57301342, 9.09211847, 8.23363639,],
 [ 4.51711019, 4.84990388, 10.5230647 , 10.96729079,],
 [ 6.4066451 , 5.31463239, 12.21603776, 15.88754298,],
 [ 8.65317985, 6.47454759, 11.84856169, 17.14057537,],
 [ 9.49926825, 7.72689077, 13.74437316, 19.53301126,],
 [ 10.02020172, 9.51807013, 15.9536513 , 22.29914324,],
 [ 10.75378936, 12.9274966 , 18.24237696, 26.29770832,],
 [ 11.17418658, 15.11715804, 20.5356652 , 27.77352674,],
 [ 15.60085484, 17.63894992, 24.05864825, 29.95795818,],
 [ 19.58221707, 22.22364835, 28.83559067, 35.47861268,],
 [ 24.46507963, 28.42863092, 35.03773854, 43.07712404,],
 [ 25.51692826, 35.89138829, 49.026005 , 49.56447503,],
 [ 32.54987218, 46.69087115, 56.66525145, 46.58317863,]]

    vgridvalues = [[ 5.63847657,-10.785276 ,-22.6095379 ,-13.64153244,],
 [ 7.58693619,-11.37366376,-26.1143077 ,-14.62308003,],
 [ 8.2156419 ,-10.33270526,-24.78681308,-14.57817169,],
 [ 7.26747522,-11.1164535 ,-21.7708644 ,-14.62065599,],
 [ 6.57993472,-14.70175538,-11.27197898,-10.68162139,],
 [ 5.28504003,-11.27965435, -7.03932987, -6.08223454,],
 [ 5.95954353, -7.45738786, -3.27552714, -4.93190105,],
 [ 5.77207997, -4.98734635, -0.95076732, -3.98832105,],
 [ 6.84405143, -2.85872752, -0.78989329, -0.75523239,],
 [ 10.28425586, -1.13856714, 1.96991034, 2.32479111,],
 [ 12.10531588, 3.36748677, 5.42371863, 5.64545439,],
 [ 11.26947244, 9.86871971, 8.64386002, 9.61426628,],
 [ 9.40053589, 15.18333125, 9.64433372, 13.72908174,],
 [ 7.29871436, 16.70357228, 11.91403688, 15.57819765,],
 [ 6.665339 , 16.13653837, 18.15582137, 19.63645081,],
 [ 6.65063667, 17.16557595, 21.74739333, 25.49785107,],
 [ 11.11541436, 19.38975617, 25.77206951, 29.06548106,],
 [ 21.5467361 , 21.30678801, 25.32755049, 25.56175503,]]


    levels = tempgridlevels
    taus = tempgridfcsthour
 
    ugrid = Numeric.array(ugridvalues)
    vgrid = Numeric.array(vgridvalues)

    ###################Change the U and V here ############

    ugrid = ugrid * 0 + 10
    vgrid = vgrid * 0 - 10

    ###########################################
    
    print "Ugrid",ugrid
    print "Vgrid",vgrid

    plotname = "ATNCL_meteogram"

    rlist = Ngl.Resources()
 
    wks = Ngl.open_wks('x11',plotname,rlist)

    uv_res = Ngl.Resources()

    uv_res.trYReverse = True # Reverse the Y values.
    uv_res.nglDraw = False # Don't draw individual plot.
    uv_res.nglFrame = False # Don't advance frame.
    uv_res.nglMaximize = True # Maximize plot in frame.

# ------resources
    uv_res.tiYAxisString = "Pressure (mb)" # Y axes label.
  
    uv_res.tmYLMode = "Explicit" # Define own tick mark labels.
    uv_res.tmYLLabelFont = 25 # Change the font.
    uv_res.tmYLValues = levels
    uv_res.tmYLLabels =
["1000","975","950","925","850","800","750","700","650","600","550","500","4
50","400","350","300","250","200"]
    uv_res.tmYLMinorOn = False # No minor tick marks.
    uv_res.tmXBMinorOn = False # No minor tick marks.
    uv_res.tiXAxisString = "" # X axes label.
    uv_res.tiMainString = "Meteogram for TEST"
    uv_res.vfXArray = taus # Define X/Y axes values that
    uv_res.vfYArray = levels # all three data fields are on
    uv_res.vcRefAnnoOn = False # turns off the ref box
    uv_res.vcRefLengthF = 0.040


## uv_res.vcGlyphStyle = "WindBarb"
    
# uv_res.vcMinDistanceF = 0.025
    uv_res.vcMonoWindBarbColor = True # to color the windbarbs with
                                      # respect to speed use False

    windlayer = Ngl.vector(wks,ugrid,vgrid,uv_res)
    Ngl.draw(windlayer)

    Ngl.frame(wks)

    return True

if __name__ == "__main__":
    
   print "Starting program"
   imagemaker()



John C. Ertl
Fleet Numerical Meteorology & Oceanography Center
7 Grace Hopper Ave
Monterey, CA 93943
phone: (831) 656-5704
fax: (831) 656-4363

_______________________________________________
pyngl-talk mailing list
pyngl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
Received on Tue Nov 23 2004 - 10:12:25 MST

This archive was generated by hypermail 2.2.0 : Thu Jan 19 2006 - 21:30:17 MST