Viewing contents of file '../idllib/uit/pro/colormag.pro'
PRO COLORMAG,filename1,head1,filename2,head2,cdst,title=title,xmin=xmin, $
    xsize=xsize, ymin=ymin,ysize=ysize
;+
; NAME:
;    COLORMAG
; PURPOSE:
;    Create a color-magnitude plot from 2 uitphot tables.
; CALLING SEQUENCE:
;    Colormag,filename1,head1,filename2,head2,cdst
; INPUTS:
;    filename1 - name of nuv fits table 1 (example: nuv0388t1_1 )
;    head1   - header with GOOD astrometry for file1
;    filename2 - name of fuv fits table 2 (example:fuv0485t1_1 )
;    head2   - header with GOOD astrometry fof file2
;    cdst - critical distance, in real pixels for determining matches
; KEYWORD INPUTS:
;    title - string for title of plot
;    xmin  - min x value (from first image)
;    xsize - length of x (from first image)
;    ymin  - min y value (from first image)
;    ysize - length of y (from first image)
; OUTPUT:
;    none
; SIDE EFFECTS:
; REVISION HISTORY:  
;    Written, B. PFarr, STX, 2/91
;-
On_error,2
if (N_params(0) lt 5) then begin
 print,'COLORMAG calling sequence: colormag,filename1,head1,filename2',$
       ',head2,cdst'
 return
end
;
!p.title=''
if (keyword_set(title)) then !p.title=title
if (not(keyword_set(xmin))) then xmin = 0 
if (not(keyword_set(xsize))) then xsize = 2048
if (not(keyword_set(ymin))) then ymin = 0 
if (not(keyword_set(ysize))) then ysize = 2048

; get headers
;
f1 = filename1 
f2 = filename2 
;
; get table info
ftread,f1,ht1,tab1
x1=ftget(ht1,tab1,'x',-1,nulls)
y1=ftget(ht1,tab1,'y',-1,nulls)
mags1=ftget(ht1,tab1,'ap1 mag',-1,nulls)
ok1 = where((mags1 lt 30.0) and (x1 gt xmin) and (y1 gt ymin) and $
            (x1 lt (xmin+xsize)) and (y1 lt (ymin+ysize)) )
;
ftread,f2,ht2,tab2
x2=ftget(ht2,tab2,'x',-1,nulls)
y2=ftget(ht2,tab2,'y',-1,nulls)
mags2=ftget(ht2,tab2,'ap1 mag',-1,nulls)
ok2 = where(mags2 lt 30.0)
;
; only use pts with good mags
x1 = x1(ok1)
y1 = y1(ok1)
x2 = x2(ok2)
y2 = y2(ok2)
mags1 = mags1(ok1)
mags2 = mags2(ok2)
;
; convert x2,y2 to same frame as x1,y1
chngxy,head2,x2,y2,head1,x3,y3
;
; correlate 2 lists
srcor,x1,y1,x3,y3,cdst,ind1,ind2
col=mags2(ind2)-mags1(ind1)
yr1 = fix(max(mags1(ind1)+1))
yr2 = fix(min(mags1(ind1)))
plot,col,mags1(ind1),/ynoz,psym=2,yrange=[yr1,yr2]
return
end