;+ ; NAME: ; WINDHATCH ; ; PURPOSE: ; ; This is routine for drawing wind barb-ish hatches on a map. ; ; CALLING SEQUENCE: ; ; Windhatch, x, y, speed, direction ; ; REQUIRED INPUTS: ; ; x: The X location of the wind barb, expressed in data coordinates. ; Positive X is pointing in EAST direction. ; ; y: The Y location of the wind barb, expressed in data coordinates. ; Positive Y is pointing in NORTH direction. ; ; speed: The wind speed, expressed in m/s. ; ; direction: The wind direction in degrees clockwise from north. Winds from ; the NE come at 45 degrees, and the wind "arrow" points in the ; direction from which the window is blowing. (The wind arrow ; points in the direction of the station circle, with the "barbs" ; of the arrow at the end of the arrow from which the wind is coming.) ; ; KEYWORDS: ; ; ASPECT: The aspect ratio of the map or plot in the display window. ; ; CLIP: A four-element array in normalized coordinates [x0,y0,x1,y1] giving ; the lower-left and upper-right corner of a cliping rectangle. This ; is normally the extent of your plot. See the example below. ; ; COLOR: The name of the color to draw the wind barbs in. May be a vector ; the same length as X. ; ; LENGTH: The approximate length of the wind barb in normalized coordinates. ; Will be set to 0.066 of the plot distance in the X direction by default. ; ; HEADING: heading of wind measurement system relative to true north (Default = 0) ;########################################################################### PRO Windhatch, x, y, wspeed, wdirection, $ Clip=clip, $ Color=color, $ Length=length, $ Heading=heading,$ Thick=thick On_Error, 2 ; Check positional parameters. IF N_PARAMS() NE 4 THEN BEGIN Print, 'Required Syntax: Windhatch x, y, speed, direction, Length=length,' Message, 'Incorrect number of positional parameters.' ENDIF ; Check keywords IF N_Elements(color) EQ 0 THEN color = Replicate(1,N_Elements(x)) ;Make_Array(N_Elements(x), /String, Value='Yellow') IF N_Elements(color) EQ 1 THEN color = Replicate(color, N_Elements(x)) IF N_Elements(length) EQ 0 THEN BEGIN IF Total(!X.Window) EQ 0 THEN BEGIN length = 1.0 / 15.0 ENDIF ELSE BEGIN length = (!X.Window[1] - !X.Window[0]) / 15.0 ENDELSE ENDIF IF N_Elements(thick) EQ 0 THEN thick = 1.0 if not keyword_set(heading) then heading=0 ; Initialize variables. sr = length * 0.25 staff_len = length - sr half_len = staff_len * 0.3 coord = Convert_Coord(x, y, /Data, /To_Normal) xx = coord[0,*] yy = coord[1,*] ; Make sure you have a clipping rectangle. IF N_Elements(clip) EQ 0 THEN BEGIN minxx = Min(xx, Max=maxxx) minyy = Min(yy, Max=maxyy) clip = [minxx-0.25, minyy-0.25, maxxx+0.25, maxyy+0.25] ENDIF ; Loop through all the elements of the array. FOR j=0L, N_Elements(x) - 1 DO BEGIN ; Set up directions for staff and barbs. dr = (wdirection[j]+heading) * !DtoR drb1 = (wdirection[j] + 45+heading) * !DtoR drb2 = (wdirection[j] - 45+heading) * !DtoR IF dr GT (2*!Pi) THEN dr = dr - (2 * !Pi) sindr = Sin(dr) cosdr = Cos(dr) sindrb1 = Sin(drb1) cosdrb1 = Cos(drb1) sindrb2 = Sin(drb2) cosdrb2 = Cos(drb2) ; Draw the staff. x1 = clip[0] > (xx[j] + sindr * sr) < clip[2] y1 = clip[1] > (yy[j] + cosdr * sr) < clip[3] x2 = clip[0] > (x1 + sindr * staff_len) < clip[2] y2 = clip[1] > (y1 + cosdr * staff_len) < clip[3] PLOTS, [x1, x2], [y1,y2], /Normal, Color=color[j], Clip=clip, Thick=thick x1 = x2 + sindrb1*half_len y1 = y2 + cosdrb1*half_len IF x1 LT clip[0] OR x1 GT clip[2] THEN CONTINUE IF x2 LT clip[0] OR x2 GT clip[2] THEN CONTINUE IF y1 LT clip[1] OR y1 GT clip[3] THEN CONTINUE IF y2 LT clip[1] OR y2 GT clip[3] THEN CONTINUE PLOTS, [x1, x2], [y1,y2], /Normal, Color=color[j], Clip=clip, Thick=thick x1 = x2 + sindrb2*half_len y1 = y2 + cosdrb2*half_len IF x1 LT clip[0] OR x1 GT clip[2] THEN CONTINUE IF x2 LT clip[0] OR x2 GT clip[2] THEN CONTINUE IF y1 LT clip[1] OR y1 GT clip[3] THEN CONTINUE IF y2 LT clip[1] OR y2 GT clip[3] THEN CONTINUE PLOTS, [x1, x2], [y1,y2], /Normal, Color=color[j], Clip=clip, Thick=thick ENDFOR END