Re: Overlay multiple filled contour plots? [message #46208] |
Tue, 08 November 2005 23:56  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Sarah writes:
> I've ran into a problem overplotting several filled contour plots.
>
> I want to plot three filled contour plots:
>
> 1) A landsea mask such that the ocean values are filled
> 2) A topography fill
> 3) some other variable...
>
> I have plotted my topography, and then attempted to overplot the sea
> mask so that the ocean is coloured. However this also overplots my
> existing terrain heights!
>
> I want to specify there is to be no fill for a particular variable
> range, but cannot see how.
Is something like this what you are looking for?
http://www.dfanning.com/map_tips/seamask.html
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: Overlay multiple filled contour plots? [message #46209 is a reply to message #46208] |
Tue, 08 November 2005 23:48   |
peter.albert@gmx.de
Messages: 108 Registered: July 2005
|
Senior Member |
|
|
Hi Sarah,
if I get it right, after plotting the terrain height the ocean areas
are still black (or white, or whatever your background colour is),
which you'd like to change by plotting the landsea mask? Well, it might
be that David Fanning's image_blend routine might help
(http://www.dfanning.com/programs/image_blend.pro), but it is actually
more about overlaying images using transparency. Your point seems to be
not to overlay the terrain information but to cut out the ocean areas,
put a different information there and leave the rest untouched.
I'd suggest creating one array first using all input data you have and
the subsequent usage of the WHERE function, combined with a definition
of an appropriate colour bar using TVLCT. You can find a crude
elevation colour bar here (http://tinyurl.com/9682g), which uses index
0 as blue for the ocean, colurs 1 to 80 for shades of green and brown
and finally white. Using this your code could look like:
...
add the definiton of the colour bar here
...
...
You can similarily use the upper colours > 80 for your whatever else
you want to display
...
; Scale the topography between 0 and 3000 m,
; such that only the 80 colours of thr elevation colour bar are used:
plot_array = bytscl(topography, min = 0, max = 3000, top = 80)
; Mask ocean areas
idx = where(landsea eq 0, n)
; Setting the ocean pixels to 0 will make them appear blue.
if n gt 0 then plot_array[idx] = 0
; Now you want to ass "some other variable".
; I guess this variable does not fill the entire plot region,
; but is given e.g. in an array with the same dimension as the
; topography and the landsea mask. Let's assume it can also be
; identified by a threshhold, in this example the values between 1 and
100
; should be displayed using the colours 81 to 90 (which you have to add
to
; the colour bar in advancve)
idx = where(additional_data gt 0, n)
if n gt 0 then plot_array[idx] = $
bytscl(additional_data[idx], min = 1, max = 100 top = 9) + 81
; And finally:
tv, plot_array
Cheers,
Peter
|
|
|
Re: Overlay multiple filled contour plots? [message #46285 is a reply to message #46208] |
Wed, 09 November 2005 18:50  |
Sarah
Messages: 3 Registered: November 2005
|
Junior Member |
|
|
Hi David,
Thanks, but I don't want to mask out the ocean. I want to overlay
several filled contour plots, with gaps left in the image, so the
previous image is still visible. I may not have made myself clear
before.
I'll included my solution in the reply post above, if you are
interested.
Thanks, Sarah
|
|
|
Re: Overlay multiple filled contour plots? [message #46286 is a reply to message #46209] |
Wed, 09 November 2005 18:47  |
Sarah
Messages: 3 Registered: November 2005
|
Junior Member |
|
|
Thanks Peter,
This has helped alot. You were right in assuming that 'some other
variable' is defined and to be plotted over both land and sea, but does
not fill the entire region. And further I had hoped to overlay several
(non-overlapping) filled variables in the plot. Creating the colour
table and appropriately filling a 'plot_array' works well. I will
certainly use this in the future.
Unfortunately, I want to make use of the map projections and continents
within the mapping routines as well!
The solution I've come up with is to use tvrd to capture each screen I
want, then merge them together, in a similar fashion as you suggested
above.
It's a bit clunky, but this is the script I came up with:
map_set,cen_lat,cen_lon, $
limit = [min(xlat), min(xlong), max(xlat), max(xlong)], $
/lambert, /continents
;get terrain image
contour,hgt,xlong,xlat,levels = [0,1,100,500,750,1000,1500,2000,2500],
$
c_colors = [0,2,4,6,8,10,12,14,15],/fill, /overplot
array_1 = tvrd(true=1)
;get variable points to overlay, in this case xland
plot_points = where(xland ge 2, count)
sxld= size(xland)
plot_array = intarr(sxld[1],sxld[2])
if count ne 0 then plot_array[plot_points] = 1
contour, plot_array, xlong, xlat, levels = [1], $
c_colors = [0], /fill, /overplot ; plot ocean white
array_points = tvrd()
points = where(array_points ne 0, count)
; get variable image
contour, xland, xlong, xlat, levels = [2], $
c_colors = [64], /fill, /overplot
array_2 = tvrd(true=1)
; overlay array_2 onto array_1 at overlay points
if count ne 0 then begin
array_temp = reform(array_1[0,*,*])
array_temp[points] = (array_2[0,*,*])[points]
array_1[0,*,*] = array_temp
array_temp = reform(array_1[1,*,*])
array_temp[points] = (array_2[1,*,*])[points]
array_1[1,*,*] = array_temp
array_temp = reform(array_1[2,*,*])
array_temp[points] = (array_2[2,*,*])[points]
array_1[2,*,*] = array_temp
endif
tv, array_1, true = 1
It seems to do okay!
Cheers, Sarah
|
|
|