Using TV command instead of contour [message #76865] |
Tue, 12 July 2011 03:18  |
Amit
Messages: 6 Registered: January 2006
|
Junior Member |
|
|
Dear Friends,
I have a data in form of flags, for example, dust=1,smoke=2 and so on.
There cannot be numbers in between.
The data is in the form of 2-dimensional array, with each cell
corresponding to a latitude, longitude pair. I want to display it --
the output would look something like a chess board. If I use the
CONTOUR command, it interpolates at the boundaries, producing
incorrect plots.
This problem is solved if I use TVIMAGE program. However, I cannot
pass the latitude,longitude data to the command (like CONTOUR). Can
anyone suggest me how to use TVIMAGE or TV in a way similar to
CONTOUR?
Thanks for your help
Amit
|
|
|
Re: Using TV command instead of contour [message #76924 is a reply to message #76865] |
Thu, 14 July 2011 23:58  |
Amit
Messages: 6 Registered: January 2006
|
Junior Member |
|
|
Thanks Paolo. I just noticed the NO_RESCALE keyword, and it sorted out
everything. I am using pg_image for displaying the data and COLORBAR
for displaying the color bar.
Thanks for all your help.
Grazie..(Thank You)
Amit
|
|
|
Re: Using TV command instead of contour [message #76926 is a reply to message #76865] |
Thu, 14 July 2011 14:06  |
pgrigis
Messages: 436 Registered: September 2007
|
Senior Member |
|
|
On Jul 13, 3:22 pm, Amit <amisra.a...@gmail.com> wrote:
> Thanks for help Paolo! I am up close to what I actually need. I have
> been able to modify and label the axes, titles etc and position the
> image to make sufficient room for colorbar.
>
> I just need the final advice on how to draw the colorbar. Actually I
> do not have any idea about the colour-palette pg_plotimage is using.
The color palette is specified by you - pg_plotimage and tv/tvscl will
use whatever color table you specified. They do not change it for you.
Ciao,
Paolo
>
> By the way, I compared the pg_plotimage output with TV and TVSCL. The
> pg_plotimage is similar to TVSCL but not to TV. The latter is similar
> to CONTOUR output.
>
> It would have been better if I could upload the image here, but I do
> not know how to.
>
> Amit
|
|
|
|
Re: Using TV command instead of contour [message #76937 is a reply to message #76865] |
Wed, 13 July 2011 12:22  |
Amit
Messages: 6 Registered: January 2006
|
Junior Member |
|
|
Thanks for help Paolo! I am up close to what I actually need. I have
been able to modify and label the axes, titles etc and position the
image to make sufficient room for colorbar.
I just need the final advice on how to draw the colorbar. Actually I
do not have any idea about the colour-palette pg_plotimage is using.
By the way, I compared the pg_plotimage output with TV and TVSCL. The
pg_plotimage is similar to TVSCL but not to TV. The latter is similar
to CONTOUR output.
It would have been better if I could upload the image here, but I do
not know how to.
Amit
|
|
|
Re: Using TV command instead of contour [message #76945 is a reply to message #76865] |
Wed, 13 July 2011 08:55  |
pgrigis
Messages: 436 Registered: September 2007
|
Senior Member |
|
|
On Jul 13, 8:21 am, Amit <amisra.a...@gmail.com> wrote:
> Hi Paolo,
>
> Many many thanks for your help. pg_plotimage does work fine and solves
> the problem.
>
> However, I see differences in the colours here as compared to those
> from CONTOUR, though I used the same colour table. Is there any way I
> can change the colours?
>
> BACKGROUND option is working fine, however I am not able to change the
> font color either. (I need to produce the plot on a white background,
> with axis labels etc in black).
>
> Finally is there any way to display the colour bar? Since the MARGIN
> keyword is not allowed, I do not think the conventional COLOR_BAR
> program would work.
>
> Thanks
> Amit
Well, you should compare the colors from what you get by tv/tvscl.
If those are the same (more or less) then pg_plotimage is working
as intended. If you see a difference, it may be due to the
interpolation
scheme used to convert a big image in memory to a small image on the
screen
- try plotting just a small part of the image and see if it helps.
I cannot comment on the colors used by contour, but the consensus
seems to be
they are somewhat weird, see http://www.idlcoyote.com/tips/contour_hole.php
To have the labels/axes of a different color you can modify !p.color
before
calling pg_plotimage.
pg_plotimage honors the position keyword, so you can plot your image
first
and then use pg_plotimage to plot the color bar (at a different
position)
by using the /noerase keyword as you would for a regular plot.
example:
loadct,5
!p.color=255
pg_plotimage,dist(512,512),charcolor=128,/xst,/
yst,position=[0,0,0.5,0.5]
!p.color=140
pg_plotimage,dist(512,512),charcolor=128,/xst,/
yst,position=[0.6,0.6,0.9,0.9],/noerase
Ciao,
Paolo
|
|
|
Re: Using TV command instead of contour [message #76947 is a reply to message #76865] |
Wed, 13 July 2011 08:21  |
KRDean
Messages: 69 Registered: July 2006
|
Member |
|
|
On Jul 12, 4:18 am, Amit <amisra.a...@gmail.com> wrote:
> Dear Friends,
>
> I have a data in form of flags, for example, dust=1,smoke=2 and so on.
> There cannot be numbers in between.
>
> The data is in the form of 2-dimensional array, with each cell
> corresponding to a latitude, longitude pair. I want to display it --
> the output would look something like a chess board. If I use the
> CONTOUR command, it interpolates at the boundaries, producing
> incorrect plots.
> This problem is solved if I use TVIMAGE program. However, I cannot
> pass the latitude,longitude data to the command (like CONTOUR). Can
> anyone suggest me how to use TVIMAGE or TV in a way similar to
> CONTOUR?
>
> Thanks for your help
> Amit
I normally use PLOTS to display index values, like landuse data were
certain numbers represent regions. For exmaple, 10:forest and
40:grass.
Below is an example how I use PLOTS.
Kelly Dean
Milliken, Colorado
;+
;
;---------------------------------------------
PRO IndexPlot
file = FILEPATH( 'worldelv.dat', SUBDIRECTORY = ['examples', 'data'])
image = READ_BINARY(file, DATA_DIMS = [360,360])
siz = SIZE( image )
LatArr = REPLICATE( 1.0, siz[1] ) # ( ( LINDGEN( siz[2] ) * 0.5 ) -
89.5 )
LngArr = ( LINDGEN( siz[1] ) * 1.0 ) # REPLICATE (1.0, siz[2] )
west = WHERE( LngArr GT 180.0, cnt )
IF ( cnt GT 0 ) THEN LngArr[west] = LngArr[west] - 360.0
; The user defined plotting symbol ( PSYM=8 ) is used by PlotS to
; add a symbol on the plot. So the IDL routine USERSYM is used to
; create a filled symbol of a circle.
A = FINDGEN(17) * (!PI*2/16.)
USERSYM, COS(A), SIN(A), /FILL
;image = ROTATE( image,7 )
DEVICE, decompose=0
WINDOW, 0, XSIZE=siz[1], YSIZE=siz[2], TITLE='Index Plot'
LOADCT, 27 ; Assign a color table
MAP_SET, 0.0, 180.0, 0.0, /Mercator
PlotS, LngArr, LatArr, COLOR = image, $
PSYM = 8, SYMsize = 0.8, /DATA
MAP_CONTINENTS
END
|
|
|
Re: Using TV command instead of contour [message #76948 is a reply to message #76865] |
Wed, 13 July 2011 05:21  |
Amit
Messages: 6 Registered: January 2006
|
Junior Member |
|
|
Hi Paolo,
Many many thanks for your help. pg_plotimage does work fine and solves
the problem.
However, I see differences in the colours here as compared to those
from CONTOUR, though I used the same colour table. Is there any way I
can change the colours?
BACKGROUND option is working fine, however I am not able to change the
font color either. (I need to produce the plot on a white background,
with axis labels etc in black).
Finally is there any way to display the colour bar? Since the MARGIN
keyword is not allowed, I do not think the conventional COLOR_BAR
program would work.
Thanks
Amit
|
|
|
Re: Using TV command instead of contour [message #76953 is a reply to message #76865] |
Tue, 12 July 2011 12:01  |
pgrigis
Messages: 436 Registered: September 2007
|
Senior Member |
|
|
On Jul 12, 6:18 am, Amit <amisra.a...@gmail.com> wrote:
> Dear Friends,
>
> I have a data in form of flags, for example, dust=1,smoke=2 and so on.
> There cannot be numbers in between.
>
> The data is in the form of 2-dimensional array, with each cell
> corresponding to a latitude, longitude pair. I want to display it --
> the output would look something like a chess board. If I use the
> CONTOUR command, it interpolates at the boundaries, producing
> incorrect plots.
> This problem is solved if I use TVIMAGE program. However, I cannot
> pass the latitude,longitude data to the command (like CONTOUR). Can
> anyone suggest me how to use TVIMAGE or TV in a way similar to
> CONTOUR?
The program pg_plotimage can be called similarly to contour:
http://hea-www.cfa.harvard.edu/~pgrigis/idl_stuff/pg_plotima ge.pro
pg_plotimage,image,x,y
where image is a n by m array, x an n array and y an m array.
Ciao,
Paolo
>
> Thanks for your help
> Amit
|
|
|
|