def spec_extract(observation, region_file, region_num, min_counts): infile = "{data_clean}[sky=region({region_file})]".format( data_clean=observation.cluster.acisI_clean_obs(observation.id), region_file=region_file ) outroot = "{outdir}/acisI_region_{obsid}_{region_num}".format( outdir=observation.cluster.super_comp_dir, region_num=region_num, obsid=observation.id ) print("Starting specextract on {}".format(infile)) rt.specextract(infile=infile, outroot=outroot, weight='yes', correct='no', asp='@{}'.format(observation.pcad_asol), combine='no', mskfile=observation.acis_mask_sc, # bkgfile=observation.back, bkgresp="no", badpixfile=observation.bad_pixel_file, binspec=1, clobber=True ) io.append_to_file(observation.cluster.spec_lis(region_num), "{}.pi\n".format(outroot))
def extract_spec(observation, region_file, region_number, dtime, btime): infile = "{clean}[sky=region({region_file})][bin pi]".format( clean=observation.sc_clean, region_file=region_file ) outfile = io.get_path( "{super_comp_dir}/{obsid}_{region_number}.pi".format( super_comp_dir=observation.cluster.super_comp_dir, obsid=observation.id, region_number=region_number )) rt.dmextract(infile=infile, outfile=outfile, clobber=True) infile = "{back}[sky=region({region_file})][bin pi]".format( back=observation.sc_back, region_file=region_file ) outfile = io.get_path( "{super_comp_dir}/{obsid}_back_{region_number}.pi".format( super_comp_dir=observation.cluster.super_comp_dir, obsid=observation.id, region_number=region_number )) rt.dmextract(infile=infile, outfile=outfile, clobber=True) data_pi = "{super_comp_dir}/{obsid}_{region_number}.pi".format( super_comp_dir=observation.cluster.super_comp_dir, obsid=observation.id, region_number=region_number ) back_pi = "{super_comp_dir}/{obsid}_back_{region_number}.pi".format( super_comp_dir=observation.cluster.super_comp_dir, obsid=observation.id, region_number=region_number ) warf = "'{super_comp_dir}/{name}_{obsid}.arf'".format( super_comp_dir=observation.cluster.super_comp_dir, name=observation.cluster.name, obsid=observation.id ) wrmf = "'{super_comp_dir}/{name}_{obsid}.rmf'".format( super_comp_dir=observation.cluster.super_comp_dir, name=observation.cluster.name, obsid=observation.id ) # Put this background file into the 'grouped' data file for the region #rt.dmhedit(infile=data_pi, filelist="", operation="add", key="BACKFILE", value=back_pi) rt.dmhedit(infile=data_pi, filelist="", operation="add", key="EXPOSURE", value=dtime) rt.dmhedit(infile=data_pi, filelist="", operation="add", key="RESPFILE", value=wrmf) rt.dmhedit(infile=data_pi, filelist="", operation="add", key="ANCRFILE", value=warf) rt.dmhedit(infile=data_pi, filelist="", operation="add", key="BACKFILE", value=back_pi) rt.dmhedit(infile=back_pi, filelist="", operation="add", key="EXPOSURE", value=btime) io.append_to_file(observation.cluster.spec_lis(region_number), "{}\n".format(data_pi)) return (data_pi, back_pi)