.. PNV_J19150199+071947: ############################################################################## PNV_J19150199+071947: Swift UVOT uv grism data reduction for a crowded field ############################################################################## Grism observations ==================== The observation was split in five exposures, with the following nominal parameters:: ftlist sw00032861002ugu_dt.img hk include=pa_pnt,date-obs,exposure Name Type Dimensions ---- ---- ---------- HDU 2 gu392603220I Image Real4(1987x2046) DATE-OBS= '2013-06-11T00:26:57' EXPOSURE= 1240.20665164292 / Total exposure, with all known correction PA_PNT = 42.0022867129876 / [deg] Position angle (roll) ----------------------------------------------------------------------- HDU 3 gu392609003I Image Real4(1987x2046) DATE-OBS= '2013-06-11T02:03:20' EXPOSURE= 1161.15381405482 / Total exposure, with all known correction PA_PNT = 42.0022867129876 / [deg] Position angle (roll) ----------------------------------------------------------------------- HDU 4 gu392621274I Image Real4(1987x2046) DATE-OBS= '2013-06-11T05:27:51' EXPOSURE= 360.928371097075 / Total exposure, with all known correction PA_PNT = 42.0022867129876 / [deg] Position angle (roll) ----------------------------------------------------------------------- HDU 5 gu392627040I Image Real4(1987x2046) DATE-OBS= '2013-06-11T07:03:57' EXPOSURE= 295.861787230699 / Total exposure, with all known correction PA_PNT = 42.0022867129876 / [deg] Position angle (roll) ----------------------------------------------------------------------- ftlist sw00032861003ugu_dt.img hk include=pa_pnt,date-obs,exposure Name Type Dimensions ---- ---- ---------- HDU 2 gu392868093I Image Real4(1987x2046) DATE-OBS= '2013-06-14T02:01:30' EXPOSURE= 863.934756769214 / Total exposure, with all known correction PA_PNT = 39.2816890780262 / [deg] Position angle (roll) ----------------------------------------------------------------------- HDU 3 gu392873773I Image Real4(1987x2046) DATE-OBS= '2013-06-14T03:36:10' EXPOSURE= 919.032843377417 / Total exposure, with all known correction PA_PNT = 39.2816890780262 / [deg] Position angle (roll) ----------------------------------------------------------------------- Note that the nominal roll angle was set to the same value for each observation. However, when looking at the actual data, the actual roll angle may move the spectrum relative to the background stars' zeroth orders. When the field is crowded, it is necessary to check what zeroth orders coincide with the first order spectrum. So load the spectra in DS9 [from "WCSTOOLS"], and plot the source positions from the Guide Star Catalog (V2.3):: first make a region file: echo 'fk5;circle(288.758291667, 7.32975, 5")' > src.reg start DS9 and load the data DS9 & from the file menu select "open ext multiframes" and select: file -> open ext multiframes -> 00032861002/uvot/image/sw00032861002ugu_sk.img which should load 4 frames, one for each extension. set scale to log frame->match->scale region>load regiond -> src.reg -> load into all frames The region appears on the zeroth order in the top of the image. Zoom out and adjust. frame -> match -> frame -> WCS frame -> blink Now the zeroth orders should be fixed, provided the grism aspect correction worked, and any changes in roll angle will appear to \'move\' the first order angle about. Now you will also notice that there is a spectrum from some other source that in two of the observations falls right between the zeroth and first order. That is bad, since the sensitivity in the uv part of the spectrum is low and rising. Adding some photons from another spectrum will mess up the flux calibration badly. So in these images we need to exclude the uv below ~2200A: gu392621274I,gu392627040I (fits extensions 3,4). Now mark all the zeroth orders near the spectrum in each image. Since the spectrum moves about a little, we can get ones that are contaminating:: region -> shape -> ellipse click region: angle -> 309 region -> safe region -> source.reg (next image) region -> load region -> source.reg if the aspect correction is done well, the sources should line up. If not, try to correct the aspect by hand or adjust for it in anther way. Make sure to reload the new region in all the panels and use the deepest exposure to see the fainter ones. region > load region > source.reg -> load in all frames So now we should see: .. figure::first_obs_markedup_ds9.jpeg :width: 640px Figure 1: spectrum with marked zeroth orders nearby. Now add the second observation:: frame -> new open -> ext multiframes -> 00032861003/uvot/image/sw00032861003ugu_sk.img Now we have six frames, including the later spectra. Match them up and add the region file. We then see that in the second observation some zeroth orders overlap. But where? That is less easy to figure out, and I'll come to that later. The observations were also not taken in one place on the detector. Notably, the second order can be seen to lie next to the first in the first image (gu392603220I, fits extension 1), and the last two observations ( gu392868093I, gu392873773I). So now we should see: .. figure::both_obs_markedup_ds9.jpeg :width: 640px Figure 2: all spectra with marked zeroth orders nearby. We then extract the spectra using the normal procedure with uvotgetspec. I used:: uvotgetspec.getSpec(ra,dec,'00032861002',1, fit_second=True,zoom=False,background_lower=[70,95], clobber=True,background_upper=[50,80]) And similar ones for the other spectra. Notice that I set zoom to False in order to see the zeroth order region also in the extracted image. I set the background ranges to correspond to regions relatively free from lots of bright first order emission. Now I copy the results to a subdirectory, sig2.5:: mkdir sig2.5 mv *.pha sig2.5 mv *.log sig2.5 In order to find the contamination from sources close to the spectra order, I extract the spectrum also with a smaller trackwidth. Next I reset the extraction width. That means I will get a nonstandard extraction which will throw off the flux calibration and the coincidence-loss correction (at least for version 1.0 of the software). One confusing problem is that the coincidence loss correction is based on a fixed area around the track, which leads to an overcorrection of the spectrum with the *smaller* trackwidth. (i.e., counter intuitive) :: uvotgetspec.trackwidth = 1.0 mkdir sig1.0 Then I rerun the extraction of all the spectra and mv them to the sig1.0 directory. I combined the spectral files in a data/ directory. Open filehandles for the results into ipython:: f1a = fits.open('data/sig1.0/sw00032861002ugu_1ord_1.pha') f1b = fits.open('data/sig1.0/sw00032861002ugu_1ord_1.pha') f2a = fits.open('data/sig1.0/sw00032861002ugu_1ord_2.pha') f2b = fits.open('data/sig2.5/sw00032861002ugu_1ord_2.pha') (...) Then make a plot using the "netrate" instead of the "flux" to see the differences. In particular regions with smaller response, say below 2200A, above 4000A, will have more noticable problems when zeroth orders are present. : .. figure::netrate_badregion_markup.png :width: 640px Figure 3: all count rate spectra marked up. Now we can sum the extracted spectra while excluding the regions marked bad. We'll add up the four spectra from the first and the two from the second separately. Data are contaminated by the second order:: File above sw00032861002ugu_1ord_1.pha 3400A sw00032861002ugu_1ord_2.pha 3000A sw00032861002ugu_1ord_3.pha 3000A sw00032861002ugu_1ord_4.pha 3000A sw00032861003ugu_1ord_1.pha 3400A sw00032861003ugu_1ord_2.pha 3500A Now make some filters:: q1 = (f1b[2].data['lambda'] < 3400) & ((f1b[2].data['lambda'] > 2270) | (f1b[2].data['lambda'] < 2200)) q2 = (f2b[2].data['lambda'] < 3000) & ((f2b[2].data['lambda'] > 2300) | (f2b[2].data['lambda'] < 2225)) q3 = (f3b[2].data['lambda'] < 3000) & (f3b[2].data['lambda'] > 2200) q4 = (f4b[2].data['lambda'] < 3000) & (f4b[2].data['lambda'] > 2288) q5 = (f5b[2].data['lambda'] < 3400) & ((f5b[2].data['lambda'] > 2288) | (f5b[2].data['lambda'] < 2189)) q6 = (f6b[2].data['lambda'] < 3500) & ((f6b[2].data['lambda'] > 2326) | (f6b[2].data['lambda'] < 2200)) Then plot with the filters:: plot(f1b[2].data['lambda'][q1],boxcar(f1b[2].data['flux'],(3,))[q1],color='b', lw=1.4,label=f1b[1].header['date-obs']+u' $\sigma$=2.5') plot(f2b[2].data['lambda'][q2],boxcar(f2b[2].data['flux'],(3,))[q2],color='g', lw=1.4,label=f2b[1].header['date-obs']+u' $\sigma$=2.5') plot(f3b[2].data['lambda'][q3],boxcar(f3b[2].data['flux'],(3,))[q3],color='r', lw=1.4,label=f3b[1].header['date-obs']+u' $\sigma$=2.5') plot(f4b[2].data['lambda'][q4],boxcar(f4b[2].data['flux'],(3,))[q4],color='m', lw=1.4,label=f4b[1].header['date-obs']+u' $\sigma$=2.5') plot(f1b[2].data['lambda'][q1],boxcar(f1b[2].data['flux'],(3,))[q1],color='b', lw=1.4,label=f1b[1].header['date-obs']+u' $\sigma$=2.5') plot(f6b[2].data['lambda'][q6],boxcar(f6b[2].data['flux'],(3,))[q6],color='k', alpha=0.7,lw=1.4,label=f6b[1].header['date-obs']+u' $\sigma$=2.5') .. figure::spectra_filtered.png :width: 640px Figure 4: Good parts of the spectra. Grism spectra times ============ =========== ======== start time stop time exposure ============ =========== ======== 392603220.9 392604481.0 1240.2 392609003.7 392610183.4 1161.2 392621274.3 392621641.0 360.9 392627040.4 392627341.0 295.9 392868093.7 392868971.5 863.9 392873773.3 392874707.1 919.0 ============ =========== ======== Photometry =========== The following photometry is available. The observations were taken in image mode. Time is swift seconds (swift time = (MJD-51910.0 )* 86400) ============ =========== ======== ====== ========= ========= ======== start time stop time exposure filter AB mag stat. err sys. err ============ =========== ======== ====== ========= ========= ======== 392608822.5 329608980.9 155.9 uvm2 12.37 0.03 0.03 392610190.4 392610301.0 108.9 uvw2 <12.64 UL UL 392868978.2 392869080.9 101.1 uvw2 12.77 0.03 0.03 392874713.4 392874781.0 66.6 uvw2 12.86 0.03 0.03 ============ =========== ======== ====== ========= ========= ========