;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Apply a time dependent boresight shift to CALALIGN files. ; This file has been customized to reflect the particular shifts needed. ; ; TLA 2002-Apr ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Set up input and output files. Input files are taken from ; ~/Aspect/flt/fid_pos/UPDATE_2001-Jul/align_fid_update. These files ; have had the fid positions (extension 2) updated. in_file = './CALDB_old/data/chandra/pcad/bcf/align/pcadD1999-08-18alignN0004.fits' in_dir = './CALDB_old/data/chandra/pcad/bcf/align/' out_dir = './CALDB_new/data/chandra/pcad/bcf/align/' ; The first few files (before 1999-10-07) are not modified at all because ACIS ; was drifting rapidly. Just copy them as is. out_copy = [ '1999-07-19', '1999-07-29', '1999-08-08', '1999-08-18', '1999-08-28', '1999-09-07', '1999-09-17', '1999-09-27'] n_copy = n_elements(out_copy) for i = 0, n_copy-1 do begin print, 'cp ' + in_dir+'pcadD'+out_copy[i]+'alignN0004.fits ' + out_dir+'pcadD'+out_copy[i]+'alignN0005.fits' ; spawn, 'cp ' + in_dir+'pcadD'+out_copy[i]+'alignN0004.fits ' + out_dir+'pcadD'+out_copy[i]+'alignN0005.fits' end ; Add some new files out_dates = [ $ '1999-10-07', '1999-10-17', '1999-10-27', '1999-11-06', $ '1999-12-01', '2000-01-01', '2000-02-01', '2000-03-01', '2000-04-01', '2000-05-01', '2000-06-01', '2000-07-01', $ '2000-08-01', '2000-09-01', '2000-10-01', '2000-11-01', '2000-12-01', '2001-01-01', '2001-02-01', '2001-03-01', $ '2001-04-01', '2001-05-01', '2001-06-01', $ '2001-07-01', '2001-08-01', '2001-09-01', '2001-10-01', '2001-11-01', $ '2001-12-01', '2002-01-01', '2002-02-01', '2002-03-01', '2002-04-01', '2002-05-01', '2002-06-01', '2002-07-01', $ '2002-08-01', '2002-09-01', '2002-10-01', '2002-11-01', '2002-12-01', $ '2999-01-01'] out_files = 'pcadD' + out_dates[0:n_elements(out_dates)-2] + 'alignN0005.fits' ;last_in = in_files[n_elements(in_files)-1] ;for i = 0, n_elements(out_files)-n_elements(in_files)-1 do in_files = [in_files, last_in] n_files = n_elements(out_files) if (n_elements(out_times) le 0) then begin out_times = dblarr(n_elements(out_dates)) print, 'Converting out_dates' for i = 0, n_elements(out_dates)-1 do begin date_cmd = '/proj/rad1/ska/perl/time_convert.pl '+out_dates[i] + 'T00:00:00 secs' print, date_cmd spawn, date_cmd, results out_times[i] = double(results[0]) end end start_hr = '00:00:00' exp_coeff = -0.00279532 exp_off_y = [-2.81803,-3.2013 ,-2.62313 ,-1.95124 ] exp_off_z = [1.91393 ,1.83976 ,1.83264 ,1.44095 ] exp_amp_y = 2.75 exp_amp_z = -1.19 date_create = '2002-04-18T20:00:00'; for i_file = 0, n_files-1 do begin outfile = out_dir + out_files[i_file] cin0 = mrdfits(in_file, 0, hdr0) cin1 = mrdfits(in_file, 1, hdr1) cin2 = mrdfits(in_file, 2, hdr2) tstart = out_times[i_file] tstop = out_times[i_file+1]-1.0 date = out_dates[i_file] ;DATE 2000-01-20T21:34:54 # Update ;TSTART 51685123.0 # What is the appropriate value? ;TSTOP 51688667.0 # Ditto ^ ;CVSD0001 1999-08-12T19:00:00 # Update to valid start time ;CVST0001 19:00:00 # Update to valid start hour sxaddpar, hdr0, 'DATE', date_create sxaddpar, hdr0, 'TSTART', tstart sxaddpar, hdr0, 'TSTOP', tstop sxaddpar, hdr0, 'CVSD0001', date+'T'+start_hr sxaddpar, hdr0, 'CVST0001', start_hr sxaddpar, hdr0, 'HISTORY', 'CALALIGN updated using time_align.pro to modify' sxaddpar, hdr0, 'HISTORY', ' alignment' sxaddpar, hdr1, 'DATE', date_create sxaddpar, hdr1, 'TSTART', tstart sxaddpar, hdr1, 'TSTOP', tstop sxaddpar, hdr1, 'CVSD0001', date+'T'+start_hr sxaddpar, hdr1, 'CVST0001', start_hr sxaddpar, hdr2, 'DATE', date_create sxaddpar, hdr2, 'TSTART', tstart sxaddpar, hdr2, 'TSTOP', tstop sxaddpar, hdr2, 'CVSD0001', date+'T'+start_hr sxaddpar, hdr2, 'CVST0001', start_hr ; See NOTES in this directory ; ; Make a new align to correct for an offset of (dy, dz) arcsec, ; The convention of (dy,dz) is (true - observed). ; ; The sign of dy is opposite to the values in Maxims tables: ; my dy corresponds to d_RA at roll=0, or to d_spacecraft_Y ; if you are looking from behind the detector out to space ; ; In the following sy = sin(dy*a2r), etc. ; ; [ cz 0.0 -sz ] [ cy -sy 0.0 ] ;R = [ 0.0 1.0 0.0 ] * [ sy cy 0.0 ] ; [ sz 0.0 cz ] [ 0.0 0.0 1.0 ] ; ; out_aca_misalign = R * in_aca_misalign ; out_fts_misalign = in_aca_misalign^-1 * R^-1 * in_aca_misalign * in_fts_misalign day_of_mission = (tstart+tstop)/2.0 / 86400. - 568.5 det = ['ACIS-S', 'ACIS-I', 'HRC-S', 'HRC-I'] print, 'Creating file ', outfile for i_det = 0, 3 do begin dy = exp_off_y[i_det] + exp_amp_y * exp(exp_coeff * day_of_mission) dz = exp_off_z[i_det] + exp_amp_z * exp(exp_coeff * day_of_mission) if (abs(dy) gt 0.01 or abs(dz) gt 0.01) then begin print, ' si=',det[i_det],' dy=',dy, ' dz=',dz sxaddpar, hdr0, 'HISTORY', det[i_det] + ' alignment shift is dy, dz = ' $ + string(format='(2f6.2)', dy, dz) + ' arcsec' in_aca = cin1[i_det].aca_misalign in_fts = cin1[i_det].fts_misalign sy = sin(dy * a2r) sz = sin(dz * a2r) cy = cos(dy * a2r) cz = cos(dz * a2r) R = [[cz, 0.0, -sz], $ [0.0, 1.0, 0.0], $ [sz, 0.0, cz]] $ ## $ [[cy, -sy, 0.0], $ [sy, cy, 0.0], $ [0.0, 0.0, 1.0]] R2 = [[cy, -sy, 0.0], $ [sy, cy, 0.0], $ [0.0, 0.0, 1.0]] $ ## $ [[cz, 0.0, -sz], $ [0.0, 1.0, 0.0], $ [sz, 0.0, cz]] ; For FTS align drift ; out_aca = in_aca ; out_fts = invert(R) ## in_fts out_aca = R ## in_aca out_fts = invert(in_aca) ## invert(R) ## in_aca ## in_fts cin1[i_det].aca_misalign = out_aca cin1[i_det].fts_misalign = out_fts end end mwrfits, cin0, outfile, hdr0, /create mwrfits, cin1, outfile, hdr1 mwrfits, cin2, outfile, hdr2 end end ; For reference, here are header keywords needing modification ;CHECKSUM gamhgWmegamegWme # Is there a tool to update this? ;DATASUM 2605983188 # Ditto ^ ;DATE 2000-01-20T21:34:54 # Update ;DATE-OBS 1999-09-13T04:44:46 # These don't apply, since there ;DATE-END 1999-09-13T08:44:59 # are many observations in align ;TSTART 51685123.0 # What is the appropriate value? ;TSTOP 51688667.0 # Ditto ^ ;CVSD0001 1999-08-12T19:00:00 # Update to valid start time ;CVST0001 19:00:00 # Update to valid start hour ;HISTORY # Add processing history lines