Showing posts with label contour. Show all posts
Showing posts with label contour. Show all posts

Tuesday, August 17, 2010

Overlapping Contours


;Turn on colors
device,true_color=24,decomposed=0,retain=2

;Set up fonts
!P.FONT = -1
!P.THICK = 1
DEVICE, SET_FONT ='Times Bold',/TT_FONT

white = GetColor('White', 1)
black = GetColor('Black', 2)
green = GetColor('Green', 3)
red = GetColor('Red', 4)
blue = GetColor('Blue',5)

LoadCT, 33, NColors=levels, Bottom=3


;Set up contour data
bin_width = 0.05
minx=-1.0
miny=-0.5
maxx=4
maxy=2

star_contours = HIST_2D(ugscolor, grscolor, bin1=bin_width, bin2=bin_width, max1=maxx, MAX2=maxy, MIN1=minx, MIN2=miny)

;; This sets up (max1-min1)bin1 bins in X....
x_cont = findgen(n_elements(star_contours[*,1]))
sx_cont = (x_cont*bin_width) + minx

;; And 60 bins in y
y_cont = findgen(n_elements(star_contours[1,*]))
sy_cont = (y_cont*bin_width) + miny


qso_contours = HIST_2D(ugqcolor, grqcolor, bin1=bin_width, bin2=bin_width, max1=maxx, MAX2=maxy, MIN1=minx, MIN2=miny)

;; This sets up (max1-min1)bin1 bins in X....
x_cont = findgen(n_elements(qso_contours[*,1]))
qx_cont = (x_cont*bin_width) + minx

;; And 60 bins in y
y_cont = findgen(n_elements(qso_contours[1,*]))
qy_cont = (y_cont*bin_width) + miny

levels = 10
userlevels = findgen(levels)^2.5
maxlevel = max(userlevels)
smax = max(star_contours)*1.1
slevels = userlevels*smax/maxlevel

levels = 7
userlevels = findgen(levels)^2.5
maxlevel = max(userlevels)
qmax = max(qso_contours)*1.1
qlevels = userlevels*qmax/maxlevel

mtitle = 'Color-Color Contour Plot'
xtitle = 'u-g magnitude'
ytitle = 'g-r magnitude'

Window, XSize=800, YSize=700
Contour, star_contours, sx_cont, sy_cont, C_Colors=red, Background=1, Levels=slevels, Color=black, XTITLE = xtitle, YTITLE = ytitle, TITLE = mtitle, charsize = 2, charthick = 1, thick=2, xthick=2, ythick=2
Contour, qso_contours, qx_cont, qy_cont, /Overplot, Levels=qLevels, Color=blue, thick=2


set_plot, 'ps'
!P.FONT = 0
!P.THICK = 1
aspect_ratio = (7.0/8.0)
xsz = 5.0
ysz = xsz*aspect_ratio
device, filename = 'contourqsostar.eps', /color, bits_per_pixel = 8,encapsul=0, xsize=xsz,ysize=ysz, /INCHES, /TIMES, /BOLD

Contour, star_contours, sx_cont, sy_cont, C_Colors=red, Background=1, Levels=slevels, Color=black, XTITLE = xtitle, YTITLE = ytitle, TITLE = mtitle, charsize = 1, charthick = 1, thick=2, xthick=2, ythick=2
Contour, qso_contours, qx_cont, qy_cont, /Overplot, Levels=qLevels, Color=blue, thick=2

device, /close
set_plot,'X'
!P.FONT = -1
!P.THICK = 1
DEVICE, SET_FONT ='Times Bold',/TT_FONT

log file:

../logs/100817log.pro

Monday, August 16, 2010

Final Plotting

From this page we see how to do color contour plots: http://www.dfanning.com/tips/contour_hole.html

Here are the plots for the QSO and EE catalogs:


Here is the code to make them... I've used non-linear color levels to show peaks better...
For everything else catalog:

file1 = filepath('Likeli_everything.fits', root_dir=getenv('BOSSTARGET_DIR'), subdir='data')

;file1 = './Likeli_everything.fits.gz'
.com likelihood_compute
startemplate = likelihood_everything_file(file1, area=area1)


;Get magnitudes
;Star Magnitudes (don't need to deredden)
smag = 22.5 - 2.5*alog10(startemplate.psfflux>1.0d-3)
ugscolor = smag[0,*] - smag[1,*]
grscolor = smag[1,*] - smag[2,*]


;Turn on colors
device,true_color=24,decomposed=0,retain=2

;Set up fonts
!P.FONT = -1
!P.THICK = 1
DEVICE, SET_FONT ='Times Bold',/TT_FONT

bin_width = 0.025
minx=-1.0
miny=-0.5
maxx=4
maxy=2

;Create contours
star_contours = HIST_2D(ugscolor, grscolor, bin1=bin_width, bin2=bin_width, max1=maxx, MAX2=maxy, MIN1=minx, MIN2=miny)

;; This sets up (max1-min1)bin1 bins in X....
x_cont = findgen(n_elements(star_contours[*,1]))
x_cont = (x_cont*bin_width) + minx

;; And bins in y
y_cont = findgen(n_elements(star_contours[1,*]))
y_cont = (y_cont*bin_width) + miny

;Set up plot titles
xtitle = 'u-g magnitude'
ytitle = 'g-r magnitude'
mtitle = 'Color-Color Contour Plot EE Catalog'

levels = 256 ;plot in 256 colors
data = star_contours
x = x_cont
y = y_cont
white = GetColor('White', 1) ; know what is white
black = GetColor('Black', 2) ; know what is black
;load blue-red color table
LoadCT, 33, NColors=levels, Bottom=3

;define the levels of the color contours
;non linear to show data shape better
userlevels = findgen(levels)^3
maxlevel = max(userlevels)
thismax = max(star_contours)*1.1
userlevels = userlevels*thismax/maxlevel

;define the levels of the contour lines
;non linear to show data shape better
;only ten lines so that the text is legible
slevels = 10
suserlevels = findgen(slevels)^3
maxlevel = max(suserlevels)
thismax = max(star_contours)*1.1
suserlevels = suserlevels*thismax/maxlevel

; make window
Window, XSize=800, YSize=700
;Make contour plot
Contour, data, x, y, /Fill, C_Colors=Indgen(levels)+3, Background=1, Levels=userlevels, Position=[0.12, 0.1, 0.9, 0.80], Color=black, XTITLE = xtitle, YTITLE = ytitle, TITLE = mtitle, charsize = 2, charthick = 1, thick=1, xthick=2, ythick=2
;Overplot black lines
Contour, data, x, y, /Overplot, Levels=suserLevels, /Follow, Color=black
;Make color bar
ColorBar, NColors=levels, Bottom=3, Divisions=slevels-1, TICKNAMES=suserlevels, Range=[Min(data), Max(data)], Format='(G8.5)', Position = [0.12, 0.9, 0.9, 0.95], Color=black


Similarly for the qso catalog:


bin_width = 0.03
minx=0.0
miny=-0.5
maxx=3.0
maxy=1.5

qso_contours = HIST_2D(ugqcolor, grqcolor, bin1=bin_width, bin2=bin_width, max1=maxx, MAX2=maxy, MIN1=minx, MIN2=miny)

;; This sets up (max1-min1)bin1 bins in X....
x_cont = findgen(n_elements(qso_contours[*,1]))
x_cont = (x_cont*bin_width) + minx

;; And 60 bins in y
y_cont = findgen(n_elements(qso_contours[1,*]))
y_cont = (y_cont*bin_width) + miny


xtitle = 'u-g magnitude'
ytitle = 'g-r magnitude'
mtitle = 'Color-Color Contour Diagram of QSO Catalog'

levels = 256
data = qso_contours
x = x_cont
y = y_cont
white = GetColor('White', 1)
black = GetColor('Black', 2)
LoadCT, 33, NColors=levels, Bottom=3

userlevels = findgen(levels)^3
maxlevel = max(userlevels)
thismax = max(qso_contours)*1.1
userlevels = userlevels*thismax/maxlevel

slevels = 7
suserlevels = findgen(slevels)^3
maxlevel = max(suserlevels)
thismax = max(qso_contours)*1.1
suserlevels = suserlevels*thismax/maxlevel


Window, XSize=800, YSize=700

Contour, data, x, y, /Fill, C_Colors=Indgen(levels)+3, Background=1, Levels=userlevels, Position=[0.12, 0.1, 0.9, 0.80], Color=black, XTITLE = xtitle, YTITLE = ytitle, TITLE = mtitle, charsize = 2, charthick = 1, thick=1, xthick=2, ythick=2
Contour, data, x, y, /Overplot, Levels=suserLevels, /Follow, Color=black
ColorBar, NColors=levels, Bottom=3, Divisions=slevels-1, TICKNAMES=suserlevels, Range=[Min(data), Max(data)], Format='(G10.5)', Position = [0.12, 0.9, 0.9, 0.95], Color=black



And to make the plots to files:

set_plot, 'ps'
!P.FONT = 0
!P.THICK = 1
aspect_ratio = (7.0/8.0)
xsz = 7.0
ysz = xsz*aspect_ratio
device, filename = 'contourstars.eps', /color, bits_per_pixel = 8,encapsul=0, xsize=xsz,ysize=ysz, /INCHES, /TIMES, /BOLD

Contour, data, x, y, /Fill, C_Colors=Indgen(levels)+3, Background=1, Levels=userlevels, Position=[0.11, 0.1, 0.9, 0.80], Color=black, XTITLE = xtitle, YTITLE = ytitle, TITLE = mtitle, charsize = 1, charthick = 1, thick=1, xthick=2, ythick=2
Contour, data, x, y, /Overplot, Levels=suserLevels, /Follow, Color=black
ColorBar, NColors=levels, Bottom=3, Divisions=slevels-1, TICKNAMES=suserlevels, Range=[Min(data), Max(data)], Format='(G8.5)', Position = [0.11, 0.9, 0.9, 0.95], Color=black



device, /close
set_plot,'X'
!P.FONT = -1
!P.THICK = 1
DEVICE, SET_FONT ='Times Bold',/TT_FONT







bin_width = 0.03
minx=0.0
miny=-0.5
maxx=3.0
maxy=1.5

qso_contours = HIST_2D(ugqcolor, grqcolor, bin1=bin_width, bin2=bin_width, max1=maxx, MAX2=maxy, MIN1=minx, MIN2=miny)

;; This sets up (max1-min1)bin1 bins in X....
x_cont = findgen(n_elements(qso_contours[*,1]))
x_cont = (x_cont*bin_width) + minx

;; And 60 bins in y
y_cont = findgen(n_elements(qso_contours[1,*]))
y_cont = (y_cont*bin_width) + miny


xtitle = 'u-g magnitude'
ytitle = 'g-r magnitude'
mtitle = 'Color-Color Contour Diagram of QSO Catalog'

levels = 256
data = qso_contours
x = x_cont
y = y_cont
white = GetColor('White', 1)
black = GetColor('Black', 2)
LoadCT, 33, NColors=levels, Bottom=3

userlevels = findgen(levels)^3
maxlevel = max(userlevels)
thismax = max(qso_contours)*1.1
userlevels = userlevels*thismax/maxlevel

slevels = 7
suserlevels = findgen(slevels)^3
maxlevel = max(suserlevels)
thismax = max(qso_contours)*1.1
suserlevels = suserlevels*thismax/maxlevel

set_plot, 'ps'
!P.FONT = 0
!P.THICK = 1
aspect_ratio = (7.0/8.0)
xsz = 7.0
ysz = xsz*aspect_ratio
device, filename = 'contourqsos.eps', /color, bits_per_pixel = 8,encapsul=0, xsize=xsz,ysize=ysz, /INCHES, /TIMES, /BOLD

Contour, data, x, y, /Fill, C_Colors=Indgen(levels)+3, Background=1, Levels=userlevels, Position=[0.12, 0.1, 0.9, 0.80], Color=black, XTITLE = xtitle, YTITLE = ytitle, TITLE = mtitle, charsize = 1, charthick = 1, thick=1, xthick=2, ythick=2
Contour, data, x, y, /Overplot, Levels=suserLevels, /Follow, Color=black
ColorBar, NColors=levels, Bottom=3, Divisions=slevels-1, TICKNAMES=suserlevels, Range=[Min(data), Max(data)], Format='(G10.5)', Position = [0.12, 0.9, 0.9, 0.95], Color=black

device, /close
set_plot,'X'
!P.FONT = -1
!P.THICK = 1
DEVICE, SET_FONT ='Times Bold',/TT_FONT

See they look pretty:



All in the following log file:
../logs/100816log.pro

Friday, August 13, 2010

More Plotting

More plotting....

Plot to a file:
;Save color-color diagram to file
set_plot, 'ps'
!P.FONT = 0
!P.THICK = 2
aspect_ratio = (6.0/7.0)
xsz = 4.0
ysz = xsz*aspect_ratio
device, filename = 'ccstars.eps', /color, bits_per_pixel = 8,encapsul=0, xsize=xsz,ysize=ysz, /INCHES, /TIMES, /BOLD
ccplot, xobject, yobject, xtitle, ytitle, mtitle
device, /close
set_plot,'X'

or (from here -- note I needed to change /encapsul command to device to encapsul=0)

to_eps, /eps, device=device
ccplot, xobject, yobject, xtitle, ytitle, mtitle
to_eps, /eps, device=device, /out

It looks pretty:
Contour plot with non-linear contour levels:
!P.FONT = -1
mtitle = 'Color-Color Contour Plot'
levels = findgen(25)^2*16
contour,star_contours,x_cont,y_cont,levels=levels,XTITLE = xtitle, YTITLE = ytitle, TITLE = mtitle, charsize = 2, charthick = 1, thick=1, xthick=1,/follow



Contour plot shaded:
levels = findgen(25)^2*16
contour,star_contours,x_cont,y_cont,levels=levels,XTITLE = xtitle, YTITLE = ytitle, TITLE = mtitle, charsize = 2, charthick = 1, thick=1, xthick=2, ythick=2,/cell_fill


To overlay levels:
window,xsize=700,ysize=600
loadct, 0
nlevels = 15
levels = findgen(nlevels)^4
maxlevel = max(levels)
thismax = max(star_contours)
levels = levels*thismax/maxlevel
contour,star_contours,x_cont,y_cont,levels=levels,XTITLE = xtitle, YTITLE = ytitle, TITLE = mtitle, charsize = 2, charthick = 1, thick=1, xthick=2, ythick=2,/cell_fill
contour,star_contours,x_cont,y_cont,levels=levels,/follow,/overplot

Thursday, August 12, 2010

Contour Plots

Nic wants me to put some contour plots in my likelihood paper. Here is some playing to make the plots....

From this tutorial: http://xweb.geos.ed.ac.uk/~hcp/notes/node4.html

I'm using the "everything else" catalog as my data to plot.

Color-Color Scatter Plot

The code:

!P.FONT = 1
!P.THICK = 2
DEVICE, SET_FONT ='Times',/TT_FONT

xtitle = 'u-g magnitude'
ytitle = 'g-r magnitude'
mtitle = 'Color-Color Diagram All Input QSOs'

window,xsize=700,ysize=600
plot, ugscolor[0:2], grscolor[0:2], ps=3, xr=[-0.5,4],yr=[-0.5,2],XTITLE = xtitle, YTITLE = ytitle, TITLE = mtitle, charsize = 2, charthick = 1
;Stars
oplot, ugscolor[ii], grscolor[ii], ps=3, color=fsc_color('red')

Mesh Surface Plot

The Code:

bin_width = 0.05
minx=-0.5
miny=-0.5
maxx=4
maxy=2

star_contours = HIST_2D(ugscolor, grscolor, bin1=bin_width, bin2=bin_width, max1=maxx, MAX2=maxy, MIN1=minx, MIN2=miny)

;; This sets up (max1-min1)bin1 bins in X....
x_cont = findgen(n_elements(star_contours[*,1]))
x_cont = (x_cont*bin_width) + minx

;; And 60 bins in y
y_cont = findgen(n_elements(star_contours[1,*]))
y_cont = (y_cont*bin_width) + miny



;Mesh surface
xtitle = 'u-g magnitude'
ytitle = 'g-r magnitude'
ztitle = 'density'
mtitle = 'Color-Color Density Plot'

window,xsize=700,ysize=600
!P.THICK = 1

surface,star_contours,x_cont,y_cont,XTITLE = xtitle, YTITLE = ytitle, ZTITLE=ztitle, TITLE = mtitle, charsize = 4, charthick = 1, ax = 45, az = 10

B&W Shaded Surface
The code:
shade_surf,star_contours,x_cont,y_cont,XTITLE = xtitle, YTITLE = ytitle, ZTITLE=ztitle, TITLE = mtitle, charsize = 4, charthick = 1, ax = 45, az = 10

B&W Contour Plot

The Code:
mtitle = 'Color-Color Contour Plot'
contour,star_contours,x_cont,y_cont,levels=findgen(75)*100,XTITLE = xtitle, YTITLE = ytitle, TITLE = mtitle, charsize = 2, charthick = 1,/follow

logfile: ../logs/100812log.pro