Skip to content

Commit

Permalink
Astrometry addons
Browse files Browse the repository at this point in the history
1) Added a number of files to do astrometry (at the users risk).
2) Bug fixes.
  • Loading branch information
jaymurthy committed Aug 29, 2017
1 parent 32e09c4 commit 0e2773c
Show file tree
Hide file tree
Showing 8 changed files with 371 additions and 38 deletions.
65 changes: 65 additions & 0 deletions #Untitled-1#
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
-rwxr-xr-x@ 1 jayanth staff 1529 Aug 22 00:48 jude_check_bod.pro
-rwxr-xr-x@ 1 jayanth staff 7880 Aug 22 00:48 jude_cnvt_att_xy.pro
-rwxr-xr-x@ 1 jayanth staff 5186 Aug 22 00:48 jude_coadd.pro
-rwxr-xr-x@ 1 jayanth staff 3112 Aug 22 00:48 jude_create_mask.pro
-rwxr-xr-x@ 1 jayanth staff 2608 Aug 22 00:48 jude_create_uvit_hdr.pro
-rwxr-xr-x@ 1 jayanth staff 19077 Aug 22 00:48 jude_driver_uv.pro
-rwxr-xr-x@ 1 jayanth staff 4278 Aug 22 00:48 jude_driver_vis.pro
-rwxr-xr-x@ 1 jayanth staff 1288 Aug 22 00:48 jude_err_process.pro
-rwxr-xr-x@ 1 jayanth staff 12377 Aug 22 00:48 jude_fuv_astrometry.pro
-rwxr-xr-x@ 1 jayanth staff 2591 Aug 22 00:48 jude_get_files.pro
-rwxr-xr-x@ 1 jayanth staff 8909 Aug 22 00:48 jude_get_xy.pro
-rwxr-xr-x@ 1 jayanth staff 21803 Aug 22 00:48 jude_interactive.pro
-rwxr-xr-x@ 1 jayanth staff 6023 Aug 22 00:48 jude_match_vis_offsets.pro
-rwxr-xr-x@ 1 jayanth staff 10536 Aug 22 00:48 jude_max_resolution.pro
-rwxr-xr-x@ 1 jayanth staff 6596 Aug 22 00:48 jude_merge_files.pro
-rwxr-xr-x@ 1 jayanth staff 9228 Aug 22 00:48 jude_mosaic.pro
-rwxr-xr-x@ 1 jayanth staff 3097 Aug 22 00:48 jude_obs_log.pro
-rwxr-xr-x@ 1 jayanth staff 2240 Aug 22 00:48 jude_params.pro
-rwxr-xr-x@ 1 jayanth staff 6443 Aug 22 00:48 jude_read_hk_files.pro
-rwxr-xr-x@ 1 jayanth staff 4014 Aug 22 00:48 jude_read_vis.pro
-rwxr-xr-x@ 1 jayanth staff 10772 Aug 22 00:48 jude_register_data.pro
-rwxr-xr-x@ 1 jayanth staff 9236 Aug 22 00:48 jude_set_dqi.pro
-rwxr-xr-x@ 1 jayanth staff 4044 Aug 22 00:48 jude_uv_cleanup.pro
-rwxr-xr-x@ 1 jayanth staff 6772 Aug 22 00:48 jude_vis_shifts.pro
-rwxr-xr-x@ 1 jayanth staff 3826 Aug 22 00:48 make_movie.pro
-rwxr-xr-x@ 1 jayanth staff 867 Aug 22 00:48 process_uvit.com
$
rw-r--r--@ 1 jayanth staff 11358 Aug 29 20:18 LICENSE-2.0.txt
-rw-r--r--@ 1 jayanth staff 219 Aug 29 20:18 README.md
-rw-r--r--@ 1 jayanth staff 1385 Aug 29 20:18 interactive.com
-rw-r--r--@ 1 jayanth staff 9656 Aug 29 20:18 jude_add_frames.pro
-rw-r--r--@ 1 jayanth staff 4954 Aug 29 20:18 jude_add_vis.pro
-rw-r--r--@ 1 jayanth staff 5738 Aug 29 20:18 jude_apply_astrometry.pro
-rw-r--r--@ 1 jayanth staff 1789 Aug 29 20:18 jude_apply_cal.pro
-rw-r--r--@ 1 jayanth staff 4591 Aug 29 20:18 jude_apply_time.pro
-rw-r--r--@ 1 jayanth staff 3374 Aug 29 20:18 jude_call_astrometry.pro
-rw-r--r--@ 1 jayanth staff 15728 Aug 29 20:18 jude_centroid.pro
-rw-r--r--@ 1 jayanth staff 1529 Aug 29 20:18 jude_check_bod.pro
-rw-r--r--@ 1 jayanth staff 7880 Aug 29 20:18 jude_cnvt_att_xy.pro
-rw-r--r--@ 1 jayanth staff 5186 Aug 29 20:18 jude_coadd.pro
-rw-r--r--@ 1 jayanth staff 3112 Aug 29 20:18 jude_create_mask.pro
-rw-r--r--@ 1 jayanth staff 2608 Aug 29 20:18 jude_create_uvit_hdr.pro
-rw-r--r--@ 1 jayanth staff 19292 Aug 29 20:18 jude_driver_uv.pro
-rw-r--r--@ 1 jayanth staff 4278 Aug 29 20:18 jude_driver_vis.pro
-rw-r--r--@ 1 jayanth staff 1288 Aug 29 20:18 jude_err_process.pro
-rw-r--r--@ 1 jayanth staff 12815 Aug 29 20:18 jude_fuv_astrometry.pro
-rw-r--r--@ 1 jayanth staff 2591 Aug 29 20:18 jude_get_files.pro
-rw-r--r--@ 1 jayanth staff 8909 Aug 29 20:18 jude_get_xy.pro
-rw-r--r--@ 1 jayanth staff 21898 Aug 29 20:18 jude_interactive.pro
-rw-r--r--@ 1 jayanth staff 6023 Aug 29 20:18 jude_match_vis_offsets.pro
-rw-r--r--@ 1 jayanth staff 10536 Aug 29 20:18 jude_max_resolution.pro
-rw-r--r--@ 1 jayanth staff 6596 Aug 29 20:18 jude_merge_files.pro
-rw-r--r--@ 1 jayanth staff 9228 Aug 29 20:18 jude_mosaic.pro
-rw-r--r--@ 1 jayanth staff 3097 Aug 29 20:18 jude_obs_log.pro
-rw-r--r--@ 1 jayanth staff 2240 Aug 29 20:18 jude_params.pro
-rw-r--r--@ 1 jayanth staff 6443 Aug 29 20:18 jude_read_hk_files.pro
-rw-r--r--@ 1 jayanth staff 4014 Aug 29 20:18 jude_read_vis.pro
-rw-r--r--@ 1 jayanth staff 10772 Aug 29 20:18 jude_register_data.pro
-rw-r--r--@ 1 jayanth staff 9236 Aug 29 20:18 jude_set_dqi.pro
-rw-r--r--@ 1 jayanth staff 4044 Aug 29 20:18 jude_uv_cleanup.pro
-rw-r--r--@ 1 jayanth staff 6772 Aug 29 20:18 jude_vis_shifts.pro
-rw-r--r--@ 1 jayanth staff 3826 Aug 29 20:18 make_movie.pro
-rw-r--r--@ 1 jayanth staff 8128 Aug 29 20:18 plot_simbad.pro
-rw-r--r--@ 1 jayanth staff 867 Aug 29 20:18 process_uvit.com
$
5 changes: 4 additions & 1 deletion jude_add_frames.pro
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
;JM: Jul 27, 2017: Corrected reference frame.
;JM: Aug. 12, 2017: Modified time addition to be faster (but still slow).
;JM: Aug. 18, 2017: Corrected crash if xoff or yoff are not passed through
;JM: Aug. 21, 2017: Made Dtime floating instead of double.
;JM: Aug. 27, 2017: Reset ref_frame if required
;Copyright 2016 Jayant Murthy
;
; Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -118,6 +120,7 @@ if (min_frame eq 0)then min_frame = $
(abs(yoff) lt 1000)))

if (n_elements(ref_frame) eq 0)then ref_frame = min_frame
if (ref_frame eq -1)then ref_frame = min_frame
while (((abs(xoff[ref_frame]) gt 1000) or (abs(yoff[ref_frame]) gt 1000)) and $
(ref_frame lt (n_elements(data) - 2))) do ref_frame = ref_frame + 1
if (max_frame eq 0) then max_frame = n_elements(data)-1
Expand Down Expand Up @@ -239,7 +242,7 @@ endfor

;Put grid into units of either counts per pixel per frame or counts per pixel per s.
if (keyword_set(notime))then pixel_time = fltarr(gxsize, gysize) + nframe
if (not(keyword_set(notime)))then pixel_time = pixel_time*dtime/nframe
if (not(keyword_set(notime)))then pixel_time = pixel_time*float(dtime)/nframe
q = where(pixel_time gt 0, nq)
if (nq gt 0)then grid(q) = grid(q)/pixel_time(q)
return,nframe ;Return number of frames
Expand Down
16 changes: 13 additions & 3 deletions jude_centroid.pro
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
;JM: Aug. 02, 2017: Explicitly print number of frames.
;JM: Aug. 03, 2017: Added option to quit.
;JM: Aug. 11, 2017: Nbin is redundant (params.fine_bin) so removed the option
;JM: Aug. 21, 2017: Fixed an inconsistency in passing offsets
;Copyright 2016 Jayant Murthy
;
; Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -327,7 +328,7 @@ pro jude_centroid, events_file, grid2, params, xstar, ystar, $
if (nq gt 3)then begin
quadterp,xindex[q],xcent[q]-xcent[q[0]],findgen(ndata_l2),xoff,missing=-1e6
quadterp,xindex[q],ycent[q]-ycent[q[0]],findgen(ndata_l2),yoff,missing=-1e6
qmiss = where((xoff gt -1e6) and (yoff gt -1e6),nmiss)
qmiss = where((xoff gt -1e6) or (yoff gt -1e6),nmiss)

if (nmiss gt 0) then begin
xoff[qmiss] = -xoff[qmiss]
Expand Down Expand Up @@ -359,10 +360,19 @@ pro jude_centroid, events_file, grid2, params, xstar, ystar, $
tv,bytscl(rebin(h1, siz[0]*4,siz[1]*4),0,max_im_value),512,0
print,"New width is ",a1[2],a1[3]

;Update offsets
qbad = where((xoff le -1e6) or (yoff le -1e6),nqbad)
xoff = xoff/params.resolution
yoff = yoff/params.resolution
if (nqbad gt 0)then begin
xoff[qbad] = -1e6
yoff[qbad] = -1e6
endif
data_l2.xoff = xoff
data_l2.yoff = yoff

if (not(keyword_set(nosave)))then begin
;Update original events file
data_l2.xoff = xoff/params.resolution
data_l2.yoff = yoff/params.resolution
offsets=mrdfits(events_file,2,off_hdr)
sxaddhist,"jude_centroid has been run",data_hdr0
sxaddpar,data_hdr0, "XCENT", xstar_first/params.resolution, "XPOS of centroid star"
Expand Down
2 changes: 1 addition & 1 deletion jude_coadd.pro
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
; out_file: FITS image file
; OPTIONAL INPUTS:
; ra_cent: Central RA in degrees
; dec_Cent: Central Dec in degrees
; dec_cent: Central Dec in degrees
; Fov: Field of view in degrees
; pixel_size: Size of each pixel in degrees
; OPTIONAL KEYWORDS:
Expand Down
8 changes: 6 additions & 2 deletions jude_driver_uv.pro
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
; JM: Jul 27, 2017 : Add reference frame to files for astrometry
; JM: Aug. 14, 2017 : Added keyword to time frame.
; JM: Aug. 18, 2017 : No longer run jude_register by default.
; JM: Aug. 21, 2017 : Changed "Number of frames" to Nframes
; JM: Aug. 27, 2017 : Problem with ref_frame due to repeated calls.
; JM: Aug. 28, 2017 : Was writing header improperly for second extension
;Copyright 2016 Jayant Murthy
;
; Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -375,6 +378,7 @@ endif
xoff = data_l2.xoff
yoff = data_l2.yoff
par = params
ref_frame = -1
;The notimes is much faster
if (keyword_set(notime))then begin
nframes = JUDE_ADD_FRAMES(data_l2, grid, pixel_time, par, $
Expand Down Expand Up @@ -434,9 +438,9 @@ endif

;Write out the image followed by the exposure times
mwrfits,grid,image_name,out_hdr,/create
mkhdr, thdr, pixel_time
mkhdr, thdr, pixel_time,/image
if (keyword_set(notime))then begin
sxaddpar,thdr,"BUNIT","Number of frames","Exposure map not applied"
sxaddpar,thdr,"BUNIT","Nframes","Exposure map not applied"
endif else begin
sxaddpar,thdr,"BUNIT","s","Exposure map"
endelse
Expand Down
65 changes: 39 additions & 26 deletions jude_fuv_astrometry.pro
Original file line number Diff line number Diff line change
Expand Up @@ -98,31 +98,32 @@ pro find_point_sources, new_im, x, y, f,new_max_value,xoff,yoff
x = 0 & y = 0 & f = 0
thresh = .002
while ((n_elements(x) lt 6) or (n_elements(x) gt 20))do begin
tv,bytscl(rebin(new_im,512,512),0,new_max_value),xoff,yoff
find,new_im,x,y,f,s,r,thresh,1.2,[-1.0,1.0],[.2,1.0]
if (n_elements(x) ge 2)then begin
srt = reverse(sort(f))
x = x[srt]
y = y[srt]
f = f[srt]
for i = 0, n_elements(x) - 2 do begin
for j = i + 1, n_elements(x) - 1 do begin
d1 = sqrt((x[i] - x[j])^2 + (y[i] - y[j])^2)
if (d1 lt 100)then x[j] = -1
endfor
endfor
endif
q = where(x gt 0, nq)
if (nq gt 0)then begin
x = x[q]
y = y[q]
f = f[q]
endif
plots,/dev,x/8+xoff,y/8+yoff,/psym,col=255,symsize=3
print,n_elements(x)," stars found."
print,n_elements(x)," stars found with a threshold of ",thresh
if (n_elements(x) gt 20) then thresh = thresh*1.5
if (n_elements(x) lt 6) then thresh = thresh/2
endwhile

if (n_elements(x) ge 2)then begin
srt = reverse(sort(f))
x = x[srt]
y = y[srt]
f = f[srt]
for i = 0, n_elements(x) - 2 do begin
for j = i + 1, n_elements(x) - 1 do begin
d1 = sqrt((x[i] - x[j])^2 + (y[i] - y[j])^2)
if (d1 lt 100)then x[j] = -1
endfor
endfor
endif
q = where(x gt 0, nq)
if (nq gt 0)then begin
x = x[q]
y = y[q]
f = f[q]
endif
tv,bytscl(rebin(new_im,512,512),0,new_max_value),xoff,yoff
plots,/dev,x/8+xoff,y/8+yoff,/psym,col=255,symsize=3

end
;**********************END FIND_POINT_SOURCES **********************
Expand Down Expand Up @@ -159,11 +160,12 @@ function set_limits, grid2, xstar, ystar, boxsize, resolution,$
end
;*****************END DISPLAY PROGRAMS***************************

pro jude_fuv_astrometry, new_file, ref_file, both_same = both_same, ref_stars = ref_stars
pro jude_fuv_astrometry, new_file, ref_file, both_same = both_same, $
ref_stars = ref_stars, new_max_value = new_max_value, ref_max_value = ref_max_value

;Initialization
new_max_value = 0.0002
ref_max_value = 0.0002
if (n_elements(new_max_value) eq 0)then new_max_value = 0.0002
if (n_elements(ref_max_value) eq 0)then ref_max_value = 0.0002
device,window_state = window_state
if (window_state[0] eq 0)then $
window, 0, xs = 1024, ys = 512, xp = 10, yp = 500
Expand All @@ -190,14 +192,20 @@ pro jude_fuv_astrometry, new_file, ref_file, both_same = both_same, ref_stars =
ans = get_kbrd(1)
if (ans eq 'y')then read,"New scale factor: ",new_max_value
endwhile
tv,bytscl(rebin(ref_im,512,512),0,ref_max_value),512,0
ans='y'
while (ans eq 'y')do begin
tv,bytscl(rebin(ref_im,512,512), 0, ref_max_value),512,0
print,"Change scale? "
ans = get_kbrd(1)
if (ans eq 'y')then read,"New scale factor: ",ref_max_value
endwhile
;Read stars from simbad using the file I've already created. The name
;of the file must be simbad.csv, just because it was easier.
nstars = read_simbad_stars(names, ra, dec, stype, mag, xtest, ytest, ztest)

;If I've already figured out my useful stars, I don't need to find them again.
if (n_elements(ref_stars) gt 0)then begin
refra = ref_stars[*,0]
refra = ref_stars[*,0]
refdec = ref_stars[*,1]
ad2xy, refra, refdec, ref_astr, refxp, refyp
endif else begin
Expand Down Expand Up @@ -332,6 +340,11 @@ pro jude_fuv_astrometry, new_file, ref_file, both_same = both_same, ref_stars =
endif
endfor

;Save stars for future.
openw,ref_lun,"ref_stars.txt",/get_lun
printf,ref_lun,newra
printf,ref_lun,newdec
free_lun,ref_lun
;Calculate astrometry using either solve astro or starast
if (n_elements(newxp) gt 5)then begin
astr = solve_astro(newra, newdec, newxp, newyp, distort = 'tnx')
Expand Down
12 changes: 7 additions & 5 deletions jude_interactive.pro
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
; JM: Aug. 11, 2017 : If defaults = 2 then I don't run centroiding or write events file.
; JM: Aug. 14, 2017 : Added keywords to time header
; JM: Aug. 16, 2017 : Modified defaults as per table below
; JM: Aug. 22, 2017 : Minor typo
; JM: Aug. 21, 2017 : Minor typo
; JM: Aug. 21, 2017 : Problem in offsets if centroid was quit
; JM: Aug. 28, 2017 : Was writing header incorrectly for second extension.
;Copyright 2016 Jayant Murthy
;
; Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -476,8 +478,8 @@ print,"Starting centroid"
xoff = xoff_cent, yoff = yoff_cent,$
/nosave, defaults = defaults, /new_star,$
max_im_value = max_im_value, display = display
xoff_sc = xoff_cent/params.resolution
yoff_sc = yoff_cent/params.resolution
xoff_sc = xoff_cent
yoff_sc = yoff_cent
endif

;Final image production
Expand Down Expand Up @@ -571,9 +573,9 @@ print,"Starting centroid"
t = data_dir + uv_base_dir + params.image_dir + imname + ".fits"
print,"writing image file to ",t
mwrfits,grid,t,out_hdr,/create
mkhdr, thdr, pixel_time
mkhdr, thdr, pixel_time, /image
if (keyword_set(notime))then begin
sxaddpar,thdr,"BUNIT","Number of frames","Exposure map not applied"
sxaddpar,thdr,"BUNIT","Ns","Exposure map not applied"
endif else begin
sxaddpar,thdr,"BUNIT","s","Exposure map"
endelse
Expand Down
Loading

0 comments on commit 0e2773c

Please sign in to comment.