# mkacisrmf (CIAO 3.4): ERROR: Not matched ccd_id of wamp header to the pixlib calculated one.
	(07 Jul 2006)
	    Note: This bug fix also resolves the problems seen
	    when working with ACIS
	    "Blank-Sky" Background Files obtained from
	    the ACIS Calibration
	    page.  These files have a single ONTIME keyword
	    in the file header, rather than one for each chip that was
	    used in the observation.  
	  
	
	    This error occurs when there are places in the WMAP that
	    map to a different CCD than the one you are using (i.e.
	    the one the source is on).  mkacisrmf needs
	    ONTIME header keyword information that isn't available in
	    the WMAP.   This error is usually paired with the "do
	    not find extension related to 'RESP_TWEAK'."
	    message; the workaround given below will resolve both
	    errors.  
	  
	    The data is mapping to a different chip because the SIM
	    drift during an observation cannot be taken into 
	    account by mkacisrmf currently.  Since this
	    correction is not applied, the drift combined with the
	    resolution of the WMAP leads to detector positions mapping
	    to inaccurate chip coordinates.  
	  
	    The following CIAO commands may be used to determine which
	    chips mkacisrmf is trying to process for the
	    WMAP.  The minimum and maximum detector coordinates are
	    obtained with dmstat, then dmcoords is used to determine on what chip
	    they fall.  We introduce the same SIM drift seen in
	    mkacisrmf by not providing the aspect solution to
	    dmcoords.  The region file is the one that was
	    used in creating the spectrum and WMAP. The syntax
	    used here works in the tcsh shell;
	    users of other shells may need to change the set or loop
	    syntax to match their environment.
	  
unix% dmstat "acis_evt2.fits[sky=region(source.reg)][cols det]" sig- med- > /dev/null
unix% set min = `pget dmstat out_min | tr "," " "` 
unix% set max = `pget dmstat out_max | tr "," " "`
unix% foreach xx ( $min[1] $max[1] )
foreach?   foreach yy ( $min[2] $max[2] )
foreach?     dmcoords acis_evt2.fits op=det detx=$xx dety=$yy verb=0
foreach?     pget dmcoords chip_id
foreach?   end
foreach? end
1
3
1
3 
	    We know that the source of interest is on ccd_id=3 (given
	    by the source.reg region file).  However, some
	    positions map to ccd_id=1.  This tells us that
	    mkacisrmf needs the ONTIME header keyword for
	    ccd_id=1 in order to run correctly.  
	  
Workaround:
	    Use dmhedit to add the ONTIME keyword to the WMAP
	    file.  The ONTIME header keywords are numbered to match
	    the ccd_id, so ONTIME1 must be added for ccd_id=1 (ONTIME2
	    is ccd_id=2, and so on).  Use the same ONTIME value that
	    exists in the header:
	  
unix% dmlist "source.pi[wmap]" header |grep ONTIME
0078 ONTIME                   40129.3360019030 [s]       Real8        Sum of GTIs
0079 ONTIME3                  40129.3360019030 [s]       Real8        Sum of GTIs
unix% dmhedit infile="source.pi[wmap]" filelist="" op=add key=ONTIME1 value=40129.3360019030 unit=s
	    This assumes that the WMAP is an extension in the spectrum
	    file; your WMAP may be a separate image file.
	  
	    Note that the RMF will contain data from the other CCD
	    (ccd_id=1), even though we know only ccd_id=3 data are in
	    the file.  This is the only workaround, as there is
	    currently no way to correct for the SIM drift in
	    mkacisrmf.