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

Home » Public Forums » archive » Colorbar for temperature scale
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
Colorbar for temperature scale [message #8467] Fri, 14 March 1997 00:00 Go to next message
Kelly Dean is currently offline  Kelly Dean
Messages: 92
Registered: March 1997
Member
I am attempting to make a color bar for some satellite images. I am
using CBAR.PRO from JHU and it is not working out. The labels used by
PLOT are not lining up. Below is some IDL code to make a color bar and
plot. The color bar has two marks to show the location of 0C and -50C.

Is there a way to get PLOT to line up the X-axis labels with the color
bar?

Kelly Dean
CSU/CIRA

=============== SUG.PRO ===============================

FUNCTION ModeAtbl, K=K, C=C, F=F
;
; Standard Mode-A infrared calibration table
;
; Keyword:
; K : Kelvin (default)
; C : Centigrade
; F : Fahrenheit
;
ModeA = FLTarr(256)
;
; Create array with Kelvin numbers.
;
ModeA = 330 - ( FINDGEN(256) * .5 )
result = WHERE( ModeA LE 242, count )
ModeA(result) = 242 - FINDGEN(count)
;
; Convert numbers to Fahrenheit.
;
IF ( KEYWORD_SET(F) ) THEN BEGIN
ModeA = ModeA - 273.16
ModeA = 1.8 * ModeA + 32.
ENDIF
;
; Convert numers to Centigrade.
;
IF ( KEYWORD_SET(C) ) THEN BEGIN
ModeA = ModeA - 273.16
ENDIF

RETURN, ModeA
END

;----------------------------------------------------------- --
;+
; NAME:
; CBAR
; PURPOSE:
; Make a color bar.
; CATEGORY:
; CALLING SEQUENCE:
; cbar
; INPUTS:
; KEYWORD PARAMETERS:
; Keywords:
; VMIN=vmn Minimum value of color bar parameter (def=0).
; VMAX=vmx Maximum value of color bar parameter (def=top).
; CMIN=cmn Color that represents vmn (def=0).
; CMAX=cmx Color that represents vmx (def=top).
; where top = !d.table_size-1.
; /HORIZONTAL Colors vary horizontally (def).
; /VERTICAL Colors vary vertical.
; /BOTTOM Horizontal axis on bottom (def).
; /TOP Horizontal axis on top.
; /RIGHT Vertical axis on right (def).
; /LEFT Vertical axis on left.
; Plus all keywords accepted by PLOT.
; OUTPUTS:
; COMMON BLOCKS:
; NOTES:
; Notes: Bar is positioned using the POSITION keyword.
; To display a title use TITLE and so on.
; MODIFICATION HISTORY:
; R. Sterner, 13 Dec, 1993
; R. Sterner, 1994 Jul 5 --- Added axis positioning.
;
; Copyright (C) 1993, Johns Hopkins University/Applied Physics
Laboratory
; This software may be used, copied, or redistributed as long as it is
not
; sold and this copyright notice is reproduced on each copy made. This
; routine is provided as is without any express or implied warranties
; whatsoever. Other limitations apply as described in the file
disclaimer.txt.
;-
;----------------------------------------------------------- --

pro cbar, z, vmin=vmn, vmax=vmx, cmin=cmn, cmax=cmx, horizontal=hor, $
vertical=ver, top=top, bottom=bottom, left=left, right=right, $
position=pos, color=col, title=ttl, _extra=extra, $
charsize=csz, help=hlp

if keyword_set(hlp) then begin
print,' Make a color bar.'
print,' cbar'
print,' All arguments are keywords.'
print,' Keywords:'
print,' VMIN=vmn Minimum value of color bar parameter (def=0).'
print,' VMAX=vmx Maximum value of color bar parameter (def=top).'
print,' CMIN=cmn Color that represents vmn (def=0).'
print,' CMAX=cmx Color that represents vmx (def=top).'
print,' where top = !d.table_size-1.'
print,' /HORIZONTAL Colors vary horizontally (def).'
print,' /VERTICAL Colors vary vertical.'
print,' /BOTTOM Horizontal axis on bottom (def).'
print,' /TOP Horizontal axis on top.'
print,' /RIGHT Vertical axis on right (def).'
print,' /LEFT Vertical axis on left.'
print,' Plus all keywords accepted by PLOT.'
print,' Notes: Bar is positioned using the POSITION keyword.'
print,' To display a title use TITLE and so on.'
return
endif

;------- Set defaults ---------------
if n_elements(vmn) eq 0 then vmn = 0.
if n_elements(vmx) eq 0 then vmx = !d.table_size-1
if n_elements(cmn) eq 0 then cmn = 0

if n_elements(cmx) eq 0 then cmx = !d.table_size-1
if n_elements(col) eq 0 then col = !p.color
if n_elements(ttl) eq 0 then ttl = ''
if n_elements(csz) eq 0 then csz = !p.charsize

;---- Set orientation dependent parameters ----------
if keyword_set(ver) then begin ; Vertical.
dim = [1,256]
x = [0,1]
y = [vmn,vmx]
ax = 2 ; Right.
if keyword_set(left) then ax = 4 ; Left.
if n_elements(pos) eq 0 then pos = [.4,.2,.6,.8]
endif else begin ; Horizontal.
dim = [256,1]
x = [vmn,vmx]
y = [0,1]
ax = 1 ; Bottom.
if keyword_set(top) then ax = 3 ; Top.
if n_elements(pos) eq 0 then pos = [.2,.4,.8,.6]
endelse

;----- Make bar --------------
;z = reform(scalearray(maken(vmn,vmx,256),vmn,vmx,cmn,cmx),dim)

;------ Plot bar -------------
tn = [' ',' ']
plot, x,y,/xstyl,/ystyl,/nodata,/noerase,xticks=1,xtickn=tn,$
yticks=1,ytickn=tn,xminor=1,yminor=1, pos=pos, col=col, titl=ttl, $
chars=csz, xran=x, yran=y
imgunder, z
plot, x,y,/xstyl,/ystyl,/nodata,/noerase, $
yticks=1, ytickn=tn, xminor=10, yminor=1, xticklen = 0.6, pos=pos,
col=col, titl=ttl, $
chars=csz, xran=x, yran=y

;-------- Axis ------------
case ax of
1: axis,xaxis=0,/xstyl,chars=csz,col=col,_extra=extra
2: axis,yaxis=1,/ystyl,chars=csz,col=col,_extra=extra
3: axis,xaxis=1,/xstyl,chars=csz,col=col,_extra=extra
4: axis,yaxis=0,/ystyl,chars=csz,col=col,_extra=extra
endcase

return

end

PRO SUG, do_modea=do_modea
;
; Do:
; sug, /do_modea
;
IF ( KEYWORD_SET(DO_MODEA) ) THEN BEGIN
TempC = ModeAtbl(/C)
;
; Create scale and add marks for 0 and -50 C
;
ModeAbar = BYTSCL(INDGEN(256) # REPLICATE(1, 25))
result00 = WHERE( (TempC GT -0.2 AND TempC LT 0.2) )
result50 = WHERE( ( TempC GT -50.3 AND TempC LT -50.0) )
ModeAbar(result00,*) = 255b
ModeAbar(result50,*) = 255b
;
; Display ModeA scale
;
WINDOW, 2, XSIZE = 256, YSIZE = 55, TITLE='modeA'
TV, modeAbar
XYOUTS, result00, 30, ['0.0'], ALIGN=0.5, CHARSIZE = .75, /DEVICE
XYOUTS, result50, 30, ['-50.0'], ALIGN=0.5, CHARSIZE = .75, /DEVICE
minC = MIN(TempC)
maxC = MAX(TempC)
;
; Create scale and plot.
;
WINDOW, 0, XSIZE=400, YSIZE=400, TITLE='Test ModeA Color Bar'
pos = [.1,.1,.9,.15]
Cbar, modeabar, position=pos, vmin=maxC, vmax=minC
;
; Plot pixel range 0 thru 255
;
pos = [.1,.25,0.9,0.9]
PLOT, TempC, INDGEN(256), /xstyl,/ystyl, Xrange=[maxC,minC],
POSITION=pos, /NoErase
ENDIF

END
Re: Colorbar for temperature scale [message #8641 is a reply to message #8467] Fri, 21 March 1997 00:00 Go to previous message
D.Kennedy is currently offline  D.Kennedy
Messages: 26
Registered: January 1997
Junior Member
In article <3329E317.1F4A@cira.colostate.edu>,
Kelly Dean <" dean"@cira.colostate.edu> writes:
>
> I am attempting to make a color bar for some satellite images. I am
> using CBAR.PRO from JHU and it is not working out. The labels used by
> PLOT are not lining up. Below is some IDL code to make a color bar and
> plot. The color bar has two marks to show the location of 0C and -50C.

Not sure what your problem is exactly but you might also want to look
at TVIM in the ESRG library (any IDL web page should have a link).
You may already have this lib actually. TVIM does a nice colourbar,
its what I now use for my stuff, nice and simple.

--
David Kennedy, Dept. of Pure & Applied Physics, Queen's University of Belfast
Email: D.Kennedy@Queens-Belfast.ac.uk | URL: http://star.pst.qub.ac.uk/~dcjk/
Hi! I'm a .signature virus! Copy me into yours and join the fun!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Digital Alpha, Windows NT and IDL
Next Topic: Dual Installation of IDL 4 and IDL 5

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

Current Time: Wed Oct 08 13:38:35 PDT 2025

Total time taken to generate the page: 0.00671 seconds