Attachment 'demoscript.py'

Download

   1 #!/usr/bin/python
   2 
   3 import os, os.path, time, subprocess, sys
   4 
   5 skyfield="183156"
   6 config="001"
   7 infile="EventLists/sm04_183156_020_EventList_001_t001.fits"
   8 #infile="./EventLists/sm03_183156_020_EventList_001_t001.fits"
   9 outfile="sm04_%s_" %(skyfield)
  10 outfile_post="001_t001.fits"
  11 suffix_srctool="_001_t001"
  12 
  13 # run evtool for energy bands and gti
  14 
  15 emin_ev=[200, 500, 2000, 5000]
  16 emax_ev=[500, 2000, 5000, 10000]
  17 emin_kev=[0.2, 0.5, 2.0, 5.0]
  18 emax_kev=[0.5, 2.0, 5.0, 10.0]
  19 eband=["1", "2", "3", "4"]
  20 ccd=[1, 2, 3, 4, 5, 6, 7]
  21 #ccd=[1]
  22 
  23 # select the energy bands index
  24 # start with 0
  25 eband_selected=[0, 1, 2, 3]
  26 do_evtool=True
  27 do_expmap=True
  28 do_ermask=True
  29 do_erbox_local=True
  30 do_erbackmap=True
  31 do_erbox_m=True
  32 do_ermldet=True
  33 do_catprep=False
  34 do_srctool=False
  35 
  36 subdir="./"
  37 srctool_dir="srctool_products/"
  38 
  39 expmaps=[]
  40 expmap_all=[]
  41 infile_expmap=[]
  42 emin=[]
  43 emax=[]
  44 emin_ev_str=[]
  45 emax_ev_str=[]
  46 outfile_evtool=[]
  47 cheesemask=[]
  48 bkgimage=[]
  49 srcmaps=[]
  50 
  51 # for ii in xrange(len(emin_kev)):
  52 for ii in xrange(len(eband_selected)):
  53 
  54   index=eband_selected[ii]
  55 
  56   outfile_evtool.append("%s02%s_EventList_%s" %(os.path.join(subdir,outfile), eband[index], outfile_post))
  57   srcmaps.append("%s02%s_SourceMap_%s" %(os.path.join(subdir,outfile), eband[index], outfile_post))
  58 
  59   print outfile_evtool,os.path.join(subdir,outfile), eband[index], outfile_post
  60 
  61   #sys.exit()
  62 
  63   cmd=["evtool",
  64       "eventfiles=%s" %(infile),
  65       "outfile=%s" %(outfile_evtool[ii]),
  66       "emin=%f" %(emin_kev[index]),
  67       "emax=%f" %(emax_kev[index]),
  68       "image=yes",
  69       "rebin=80",
  70       "resolution=3240",
  71       "pattern=15"
  72       ]
  73 
  74   # run the command
  75   if(do_evtool==True):
  76     print cmd
  77     subprocess.check_call(cmd)
  78   
  79   infile_expmap.append(outfile_evtool[ii])
  80 
  81   #expmaps=[]
  82   for jj in xrange(len(ccd)):
  83     expmaps.append("%s%d2%s_ExposureMap_%s" %(os.path.join(subdir,outfile), ccd[jj], eband[index], outfile_post))
  84 
  85   expmap_all.append("%s02%s_ExposureMap_%s" %(os.path.join(subdir,outfile), eband[index], outfile_post))
  86 
  87   emin.append("%f" %(emin_kev[index]))
  88   emax.append("%f" %(emax_kev[index]))
  89   emin_ev_str.append("%ld" %(emin_ev[index]))
  90   emax_ev_str.append("%ld" %(emax_ev[index]))
  91 
  92 if(do_expmap==True):
  93   cmd=["expmap",
  94        "inputdatasets=%s"  %(infile), #%(infile_expmap[0]),
  95        "emin=%s" %((" ").join(emin)),
  96        "emax=%s" %((" ").join(emax)),
  97        "templateimage=%s" %(infile_expmap[0]),
  98        "withvignetting=yes",
  99        "expmaps=%s" %((" ").join(expmaps)),
 100        "withalltelmaps=yes",
 101        "texpmaps=%s" %((" ").join(expmap_all))
 102        ]
 103   #t0=time.time()
 104   print(cmd)
 105   subprocess.check_call(cmd)
 106   #t1=time.time()
 107   #print("%ld minutes" %((t1-t0)/60.))
 108 
 109 #detmask="detmask_1.fits"
 110 detmask="%s020_DetectionMask_%s" %(os.path.join(subdir,outfile), outfile_post)
 111 
 112 cmd=["ermask",
 113      "expimageset=%s" %(expmap_all[0]), # use the first exposure maps calculated for that skyfield, independent of the energy band
 114      "detmaskset=%s" %(detmask),
 115      "threshold1=0.05",
 116      "threshold2=0.05",
 117      "regionfile_flag=no"
 118      ]
 119 
 120 if(do_ermask==True):
 121   if(os.path.isfile(detmask)==True):
 122     os.remove(detmask)
 123   print(cmd)
 124   subprocess.check_call(cmd)
 125 
 126 #boxlist_l="%s_boxlist_l.fits" %(os.path.join(subdir,outfile))
 127 boxlist_l="%s020_BoxDetSourceListL_%s" %(os.path.join(subdir,outfile), outfile_post)
 128 
 129 cmd=["erbox",
 130     "imagesets=%s" %((" ").join(outfile_evtool)),
 131     "boxlistset=%s" %(boxlist_l),
 132     "expimagesets=%s" %((" ").join(expmap_all)),
 133     "detmasksets=%s" %(detmask),
 134     "emin=%s" %((" ").join(emin_ev_str)),
 135     "emax=%s" %((" ").join(emax_ev_str)),
 136     "hrdef=",
 137     "ecf=1.0 1.0",
 138     "nruns=3",
 139     "likemin=6.0",
 140     "boxsize=4",
 141     "compress_flag=N",
 142     "bkgima_flag=N",
 143     "expima_flag=Y",
 144     "detmask_flag=Y"
 145     ]
 146 
 147 if(do_erbox_local==True):
 148   if(os.path.isfile(boxlist_l)==True):
 149     os.remove(boxlist_l)
 150   print(cmd)
 151   subprocess.check_call(cmd)
 152 
 153 for ii in xrange(len(eband_selected)):
 154   index=eband_selected[ii]
 155 
 156 
 157   cheesemask.append("%s02%s_CheeseMask_%s" %(os.path.join(subdir,outfile), eband[index], outfile_post))
 158   bkgimage.append("%s02%s_BackgrImage_%s" %(os.path.join(subdir,outfile), eband[index], outfile_post))
 159   #cheesemask.append("%s_%s_cheesemask.fits" %(os.path.join(subdir,outfile), eband[index]))
 160   #bkgimage.append("%s_%s_bkg.fits" %(os.path.join(subdir,outfile), eband[index]))
 161   # one command per energy band
 162   cmd=["erbackmap",
 163       "imageset=%s" %(outfile_evtool[ii]),
 164       "expimageset=%s" %(expmap_all[ii]),
 165       "boxlistset=%s" %(boxlist_l),
 166       "detmaskset=%s" %(detmask),
 167       "cheesemaskset=%s" %(cheesemask[ii]),
 168       "bkgimageset=%s" %(bkgimage[ii]),
 169       "idband=%s" %(ii),
 170       "scut=0.001",
 171       "mlmin=10",
 172       "maxcut=0.5",
 173       "fitmethod=smooth",
 174       "nsplinenodes=36",
 175       "degree=2",
 176       "smoothflag=yes",
 177       "smoothval=15.",
 178       "snr=40.0",
 179       "excesssigma=10000.",
 180       "nfitrun=1",
 181       "cheesemaskflag=Y"
 182       ]
 183 
 184   if(do_erbackmap==True):
 185     if(os.path.isfile(cheesemask[ii])==True):
 186       os.remove(cheesemask[ii])
 187     if(os.path.isfile(bkgimage[ii])==True):
 188       os.remove(bkgimage[ii])
 189     print(cmd)
 190     subprocess.check_call(cmd)
 191 
 192 
 193 # erbox m mode
 194 
 195 #boxlist_m="%s_boxlist_m.fits" %(os.path.join(subdir,outfile))
 196 
 197 boxlist_m="%s020_BoxDetSourceListM_%s" %(os.path.join(subdir,outfile), outfile_post)
 198 cmd=["erbox",
 199     "imagesets=%s" %((" ").join(outfile_evtool)),
 200     "boxlistset=%s" %(boxlist_m),
 201     "expimagesets=%s" %((" ").join(expmap_all)),
 202     "detmasksets=%s" %(detmask),
 203     "bkgimagesets=%s" %((" ").join(bkgimage)),
 204     "emin=%s" %((" ").join(emin_ev_str)),
 205     "emax=%s" %((" ").join(emax_ev_str)),
 206     "hrdef=",
 207     "ecf=1.0",
 208     "nruns=1",
 209     "likemin=4.",
 210     "boxsize=4",
 211     "compress_flag=N",
 212     "bkgima_flag=Y",
 213     "expima_flag=Y",
 214     "detmask_flag=Y"
 215     ]
 216 
 217 if(do_erbox_m==True):
 218   if(os.path.isfile(boxlist_m)==True):
 219     os.remove(boxlist_m)
 220   print(cmd)
 221   subprocess.check_call(cmd)
 222 
 223 # proceed with ermldet
 224 
 225 mllist="%s020_MaxLikSourceList_%s" %(os.path.join(subdir,outfile), outfile_post)
 226 srcmap="%s020_SourceMap_%s" %(os.path.join(subdir,outfile), outfile_post)
 227 
 228 cmd=["ermldet",
 229     "mllist=%s" %(mllist),
 230     "boxlist=%s" %(boxlist_m),
 231     "images=%s" %((" ").join(outfile_evtool)),
 232     "expimages=%s" %((" ").join(expmap_all)),
 233     "detmasks=%s" %(detmask),
 234     "bkgimages=%s" %((" ").join(bkgimage)),
 235     "emin=%s" %((" ").join(emin_ev_str)),
 236     "emax=%s" %((" ").join(emax_ev_str)),
 237     "hrdef=",
 238     "ecf=1.63127e+11 1.76051e+11 8.37841e+09 2.67441e+09",
 239     "likemin=4.",
 240     "extlikemin=7.",
 241     "compress_flag=N",
 242     "cutrad=15.",
 243     "multrad=15.",
 244     "extmin=1.5",
 245     "extmax=30.0",
 246     "bkgima_flag=Y",
 247     "expima_flag=Y",
 248     "detmask_flag=Y",
 249     "extentmodel=beta",
 250     "thres_flag=N",
 251     "thres_col=like",
 252     "thres_val=30.",
 253     "nmaxfit=3",
 254     "nmulsou=1",
 255     "fitext_flag=yes",
 256     "srcima_flag=yes",
 257     "shapelet_flag=yes",
 258     "srcimages=%s" %((" ").join(srcmaps))
 259     ]
 260 
 261 if(do_ermldet==True):
 262   if(os.path.isfile(mllist)==True):
 263     os.remove(mllist)
 264   if(os.path.isfile(srcmap)==True):
 265     os.remove(srcmap)
 266   print(cmd)
 267   subprocess.check_call(cmd)
 268 
 269 
 270 #catprep="%s" %(os.path.join(subdir,outfile +"_catprep" +  outfile_post))
 271 catprep="%s020_SourceCatalog_%s" %(os.path.join(subdir,outfile), outfile_post)
 272 cmd=["catprep",
 273      "infile=%s" %(mllist),
 274      "outfile=%s" %(catprep),
 275      "skyfield=%s" %(skyfield),
 276      "config=%s" %(config)
 277      ]
 278 
 279 if(do_catprep==True):
 280     if(os.path.isfile(catprep)==True):
 281         os.remove(catprep)
 282     print(cmd)
 283     subprocess.check_call(cmd)
 284 
 285 cmd=['srctool',
 286      'eventfiles=%s' %(infile),
 287      'prefix=%s' %(os.path.join(subdir,srctool_dir,outfile)),
 288      'suffix=%s' %(suffix_srctool),
 289      'srccoord=%s' %(catprep),
 290      'srcreg=fk5;circle * * 60"',
 291      'backreg=fk5;annulus * * 90" 120"',
 292      "clobber=yes"
 293      ]
 294 
 295 if(do_srctool==True):
 296     if(os.path.isdir(os.path.join(subdir, srctool_dir))==False):
 297       os.mkdir(os.path.join(subdir, srctool_dir))  
 298     print(cmd)
 299     subprocess.check_call(cmd)

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2017-07-27 07:36:38, 5132.8 KB) [[attachment:ccd1_new_events.fits]]
  • [get | view] (2017-07-27 09:00:42, 2089.7 KB) [[attachment:ccd1_new_events_AGNsurvey.fits]]
  • [get | view] (2017-07-27 07:37:02, 5124.4 KB) [[attachment:ccd2_new_events.fits]]
  • [get | view] (2017-07-27 09:01:01, 2115.0 KB) [[attachment:ccd2_new_events_AGNsurvey.fits]]
  • [get | view] (2017-07-27 07:37:30, 5090.6 KB) [[attachment:ccd3_new_events.fits]]
  • [get | view] (2017-07-27 09:01:21, 2112.2 KB) [[attachment:ccd3_new_events_AGNsurvey.fits]]
  • [get | view] (2017-07-27 07:43:05, 5130.0 KB) [[attachment:ccd4_new_events.fits]]
  • [get | view] (2017-07-27 09:01:39, 2098.1 KB) [[attachment:ccd4_new_events_AGNsurvey.fits]]
  • [get | view] (2017-07-27 07:43:23, 5138.4 KB) [[attachment:ccd5_new_events.fits]]
  • [get | view] (2017-07-27 09:01:56, 2129.1 KB) [[attachment:ccd5_new_events_AGNsurvey.fits]]
  • [get | view] (2017-07-27 07:43:30, 0.0 KB) [[attachment:ccd6_new_events.fits]]
  • [get | view] (2017-07-27 09:02:18, 2120.6 KB) [[attachment:ccd6_new_events_AGNsurvey.fits]]
  • [get | view] (2017-07-27 07:44:00, 5113.1 KB) [[attachment:ccd7_new_events.fits]]
  • [get | view] (2017-07-27 09:02:39, 2123.4 KB) [[attachment:ccd7_new_events_AGNsurvey.fits]]
  • [get | view] (2017-07-27 08:15:23, 55.9 KB) [[attachment:comp.png]]
  • [get | view] (2017-07-27 09:23:41, 268.0 KB) [[attachment:compAGNsurvey.png]]
  • [get | view] (2017-07-27 07:56:50, 7.8 KB) [[attachment:demoscript.py]]
  • [get | view] (2017-07-27 05:00:06, 0.0 KB) [[attachment:erositaXML.tar]]
  • [get | view] (2017-07-27 08:27:43, 30.9 KB) [[attachment:erosita_iv_1telonaxis_ff.arf]]
  • [get | view] (2017-07-27 08:28:27, 2671.9 KB) [[attachment:erosita_iv_1telonaxis_ff.rmf]]
  • [get | view] (2017-07-27 07:30:48, 262085.6 KB) [[attachment:erosita_psf_v2.1.fits]]
  • [get | view] (2017-07-27 10:43:46, 99400.0 KB) [[attachment:scripts.tar]]
  • [get | view] (2018-11-08 09:35:53, 970.0 KB) [[attachment:scripts.tar.gz]]
  • [get | view] (2017-07-27 07:45:59, 87.2 KB) [[attachment:simput_test.fits]]
  • [get | view] (2017-07-27 07:44:41, 33221.2 KB) [[attachment:sm04_183156_020_EventList_001_t001.fits]]
  • [get | view] (2017-07-27 08:15:43, 67.5 KB) [[attachment:sm04_183156_020_MaxLikSourceList_001_t001.fits]]
  • [get | view] (2017-07-27 08:14:31, 41017.5 KB) [[attachment:sm04_183156_022_SourceMap_001_t001.fits]]
  • [get | view] (2017-07-27 09:04:47, 13710.9 KB) [[attachment:sm05_183156_020_EventList_001_t001.fits]]
  • [get | view] (2017-07-27 09:20:17, 416.2 KB) [[attachment:sm05_183156_020_MaxLikSourceList_001_t001.fits]]
  • [get | view] (2017-07-27 09:18:42, 41017.5 KB) [[attachment:sm05_183156_022_SourceMap_001_t001.fits]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.