comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » trying to convert map to graphic functions
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
trying to convert map to graphic functions [message #93305] Fri, 10 June 2016 06:38 Go to next message
Brian McNoldy is currently offline  Brian McNoldy
Messages: 35
Registered: July 2000
Member
I still don't use the "new" graphics system much, just because the old way is so entrenched in my memory. But I do really like the new system when I do try it (and can get it to do what I want).
I have a plot that I'd love to switch over, but have had a rather hard time getting the same behavior.

It begins with a map (box axes, 0.5 degree lat/lon spacing, simple decimal degree labels aligned parallel with the axes). Then I have a series of colored dots on there (looks like a squiggly rainbow line), where the colors vary by altitude. Then there are wind barbs, which are also colored by altitude. The wind barbs have a quality flag value printed next to them. Finally, I draw circles around the top and bottom points of the colored dots.
The code looks like this:

window,0,xsize=900,ysize=950
loadct,39
!p.color=0
!p.background=255
map_set,/cyl,limit=[min(lat)-2,min(lon)-2,max(lat)+2,max(lon )+2],/isotropic,/noborder,position=[0.02,0.04,0.98,0.90]
map_continents,/hi,/coasts
map_grid,latdel=0.5,londel=0.5,/box_axes
for p=0,n_elements(pres)-1 do begin
plots,lon[p],lat[p],psym=3,thick=10,symsize=5,color=(pres[p] /max(pres))*254
endfor
plot_range_rings2,dist_thresh*111.2,lon[0],lat[0],color=50
plot_range_rings2,dist_thresh*111.2,lon[-1],lat[-1],color=23 0
for p=0,n_elements(amv_pres)-1 do begin
wind_barb,amv_wspd[p],amv_wdir[p],amv_lons[p],amv_lats[p],$
size=0.1,color=(amv_pres[p]/max(amv_pres))*254
xyouts,amv_lons[p],amv_lats[p],string(amv_qi[p],format='(f4. 2)'),$
charsize=1,/data,noclip=0
endfor
xyouts,0.5,0.96,title_string,charsize=3,align=0.5,/normal

The figure looks like this:
http://andrew.rsmas.miami.edu/bmcnoldy/tmp/map_example.png


I have been stumped just trying to get the grids and labels to look the same! I'm also not sure how to loop through and vary the plotting color by value using SYMBOL but not in indexed color space.

Maybe this is a case where it's best to stick with what I've got, but if anyone has any quick insights, I'd be happy to try them!

Thanks,
Brian
Re: trying to convert map to graphic functions [message #93719 is a reply to message #93305] Wed, 05 October 2016 07:14 Go to previous message
Phillip Bitzer is currently offline  Phillip Bitzer
Messages: 223
Registered: June 2006
Senior Member
On Friday, June 10, 2016 at 8:38:56 AM UTC-5, Brian McNoldy wrote:
> I still don't use the "new" graphics system much, just because the old way is so entrenched in my memory. But I do really like the new system when I do try it (and can get it to do what I want).
> I have a plot that I'd love to switch over, but have had a rather hard time getting the same behavior.
>

So, I'm a little late with this, but this is exactly the sort of thing that is absolutely necessary - examples of how to bridge the gap between pre-FG and post-FG.

I've been using FG quite a bit, and mostly like them. The biggest adjustment?The way you think about how to make plots is different in DG/CG and FG.

Here's the code to get something close to your plot. I've generated some dummy data. I also tend to be quite verbose in my code. I separated a lot of the setting of properties so we can see exactly what each one does.

;first, generate the dummy data
lat = INTERPOL([22.1, 22.4], 100)
lon = INTERPOL([-74.25, -74.1], 100)
press = INTERPOL([1000, 100], 100)

;generate the map:
mapLimits = [MIN(lat)-2,MIN(lon)-2,MAX(lat)+2,MAX(lon)+2]

m = MAP('Cylindrical Equal Area', LIMIT=mapLimits)

;set some properties, including the grid
m.mapgrid.LINESTYLE = 'dotted'

m.mapgrid.LABEL_ANGLE = 0
m.mapgrid.LABEL_POSITION = 0

;let's change the default formatting
;Look ma! Lambda function!
m.mapgrid.LABEL_FORMAT=LAMBDA(orientation, location, fractional, defaultLabel : STRING(location, FORMAT='(F7.2)'))

m.mapgrid.box_axes = 1
m.mapgrid.GRID_LONGITUDE = 0.5 ;similar to londel in direct graphics
m.mapgrid.GRID_LATITUDE = 0.5 ;similar to londel in direct graphics

;add some continents
mCont = MAPCONTINENTS(/HIRES)


;now, let's add the data, colored by pressure

;first, byte scale the pressure to 0->255
ind = REVERSE(BYTSCL(press)) ;reverse to make the smallest pressures correspond to higher indices (reds)

p = PLOT(lon, lat, $
RGB_TABLE=39, VERT_COLORS=ind, $ ;set the colors
SYMBOL=3, THICK=4, /OVERPLOT)

;plot some wind barbs

;generate some random locations
nStations = 10
wLat = RANDOMU(1L, nStations) * (mapLimits[2]-mapLimits[0]) + mapLimits[0]
wLon = RANDOMU(2L, nStations) * (mapLimits[3]-mapLimits[1]) + mapLimits[1]

;some random speeds and directions, too
wSpd = RANDOMU(3L, nStations) * 40.
wDir = RANDOMU(4l, nStations) * 360.

;get the horizontal/vertical components of the vector
uVec = wSpd * COS(wDir * !DTOR)
vVec = wSpd * SIN(wDir * !DTOR)

;plot the vectors
wb = VECTOR(uVec, vVec, wLon, wLat, $
VECTOR_STYLE=1, COLOR='blue', /OVERPLOT)
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDL new graphics memory leak?
Next Topic: Finding high rise buildings using shadows

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 07:17:11 PDT 2025

Total time taken to generate the page: 0.00461 seconds