예제 #1
0
def plot_2005ip():
    '''
	Create a plot of the combined NUV and FUV spectrum of SN 2005ip, label the common SN
	lines with different colors for different species and save
	'''
    redshift = 0.0072
    tbdata = fits.getdata('2005ip_all_x1dsum.fits', 1)
    sdqflags = fits.getval('2005ip_all_x1dsum.fits', 'sdqflags', 1)
    good_indx = np.where(tbdata['dq'][0] & sdqflags == 0)

    fig = pyplot.figure(figsize=[20, 10])
    ax = fig.add_subplot(1, 1, 1)
    deredshift_wl = deredshift_wavelength(tbdata['wavelength'][0][good_indx],
                                          redshift)
    smoothed_signal = convolve.convolve(
        tbdata['flux'][0][good_indx],
        make_kernel.make_kernel([15], 15, 'boxcar'))

    ax.plot(deredshift_wl, smoothed_signal, 'b')
    ax = label_spectra(ax)
    ax.set_xlabel('Rest Wavelength ($\AA$)')
    ax.set_ylabel('Flux (ergs/cm^2/s/$\AA$)')
    ax.set_title(
        'Preliminary HST/STIS Spectrum of SN 2005ip (smoothed by 15 pix)')
    ax.set_ylim(-0.1E-15, 0.25E-15)
    add_date_to_plot(ax)
    pyplot.savefig('2005ip_combined_labeled.pdf')
예제 #2
0
def plot_2009ip():
	'''
	Create a plot of the combined NUV and FUV spectrum of SN 2009ip, label the common SN
	lines with different colors for different species and save
	'''
	redshift = 0.0072
	tbdata = fits.getdata('2009ip_all_x1dsum.fits', 1)
	sdqflags = fits.getval('2009ip_all_x1dsum.fits', 'sdqflags', 1)
	good_indx = np.where(tbdata['dq'][0]&sdqflags == 0)

	fig = pyplot.figure(figsize = [20, 10])
	ax = fig.add_subplot(1,1,1)
	deredshift_wl = deredshift_wavelength(tbdata['wavelength'][0][good_indx], redshift)
	smoothed_signal = convolve.convolve(tbdata['flux'][0][good_indx], make_kernel.make_kernel([15],15,'boxcar'))

	ax.plot(deredshift_wl, smoothed_signal, 'b')
	ax = label_spectra(ax)
	ax.set_xlabel('Rest Wavelength ($\AA$)')
	ax.set_ylabel('Flux (ergs/cm^2/s/$\AA$)')
	ax.set_title('Preliminary HST/STIS Spectrum of SN 2009ip (smoothed by 15 pix)')
	ax.set_ylim(-0.1E-15, 0.25E-15)
	add_date_to_plot(ax)
	pyplot.savefig('2009ip_combined_labeled.pdf')
예제 #3
0
def plot_indiv_spec_with_combined(indiv_filename, combined_filename):
	'''
	Plot each file individually with the combined spectrum to make sure one doesn't look
	very different from the others
	'''
	tbdata_indiv = fits.getdata(indiv_filename, 1)
	tbdata_combined = fits.getdata(combined_filename, 1)

	fig = pyplot.figure()
	ax = fig.add_subplot(1,1,1)

	sdqflags = fits.getval(indiv_filename, 'sdqflags', 1)
	good_indx = np.where(tbdata_indiv['dq'][0]&sdqflags == 0)

	ax.plot(tbdata_indiv['wavelength'][0][good_indx], tbdata_indiv['flux'][0][good_indx], label = 'indiv obs')
	ax.plot(tbdata_combined['wavelength'][0], tbdata_combined['flux'][0], 'r', label = 'combined')
	ax.legend(loc = 'best')
	ax.set_xlabel('Wavelength')
	ax.set_ylabel('Flux')
	add_date_to_plot(ax)
	ax.set_title('Compare Indiv Spec to Combine Spec: {}'.format(os.path.basename(indiv_filename)[0:9]))
	pyplot.savefig(indiv_filename.replace('x1d.fits', 'comb_spec_comp.pdf'))
	pyplot.close()
예제 #4
0
def make_fuv_finder_plot(stis_img, wfc3_cc_offset, sn_yloc_stis = 331):
	'''
	Plot a 3 panel pdf of the WFC3 image on the left, cropped to the slit location in the middle
	and the STIS cross-dispersion profile on the right. The region plotted for WFPC2 was determined
	by cross-correlating the cross-dispersion profiles of different x locations with the STIS data.
	This is performed in the notebook currently.
	'''
	wfc3_img = fits.getdata('hst_08645_11_wfpc2_f300w_wf/hst_08645_11_wfc3_f275w_wf_drz.fits', 1)
	orientat = 36.6-153.72  #+90
	rot_wfc3_img = rotate(wfc3_img, orientat)
	wfc3_y_start = 375+wfc3_cc_offset

	fig = pyplot.figure(figsize = [20, 15])
	ax1 = fig.add_subplot(1, 3, 1)
	ax2 = fig.add_subplot(1,3,2)
	ax3 = fig.add_subplot(1, 3, 3)

	wfc3_x_start = 717.0 #Derived by visual inspection of image compares with WFPC2 image
	wfc3_platescale =  0.0394 #arcsec/pix
	stis_slit_height_pix = int(25.0/wfc3_platescale)
	stis_slit_width_pix = 0.5/wfc3_platescale
	wfc3_x_end = wfc3_x_start + stis_slit_width_pix

	ax1.set_title('WFC3 Image of 2010JL')
	im1 = ax1.imshow(rot_wfc3_img, interpolation = 'nearest', vmin = 0, vmax = 0.1)
	ax1.set_ylim(50, 1200)
	ax1.set_xlim(384, 884)
	#ax1.plot([1220, 1220, 1250, 1250, 1220], [wfc3_y_start+wfc3_cc_offset, wfc3_y_start+wfc3_cc_offset+stis_slit_height_pix, wfc3_y_start+wfc3_cc_offset+stis_slit_height_pix, wfc3_y_start+wfc3_cc_offset, wfc3_y_start+wfc3_cc_offset], color = 'r')

	#Make compass
	#north_dx = -50.0*math.sin(orientat*math.pi/180.0)
	#north_dy = 50.0*math.cos(orientat*math.pi/180.0)
	#east_dx = 50.0*math.sin((90.0-orientat)*math.pi/180.0)
	#east_dy = 50.0*math.cos((90.0-orientat)*math.pi/180.0)
	#arrow_center_x = 1150
	#arrow_center_y = 1050
	#ax1.arrow(arrow_center_x, arrow_center_y, north_dx, north_dy, color = 'w', width = 0.5, head_length = 12*0.5)
	#ax1.arrow(arrow_center_x, arrow_center_y, east_dx, east_dy, color = 'w', width = 0.5, head_length = 12*0.5)
	#ax1.text(arrow_center_x + north_dx, arrow_center_y + north_dy +10, 'N', color = 'w' )
	#ax1.text(arrow_center_x + east_dx, arrow_center_y + east_dy +10, 'E', color = 'w' )

	ax2.set_title('STIS Slit position on WFC3 Image')
	im2 = ax2.imshow(rot_wfc3_img, interpolation = 'nearest', vmin = 0, vmax = 0.1)

	#ax2.set_ylim(wfc3_y_start+wfc3_cc_offset, wfc3_y_start+wfc3_cc_offset+stis_slit_height_pix)
	ax2.set_ylim(wfc3_y_start+0, wfc3_y_start+0+stis_slit_height_pix)
	ax2.set_xlim(684, 762)
	ax2.axvspan(684, wfc3_x_start, color = 'k', alpha = 0.5)
	ax2.axvspan(wfc3_x_end, 762, color = 'k', alpha = 0.5)
	ax2.set_yticks(np.arange(ax2.get_ylim()[0], ax2.get_ylim()[1], 50))
	ax2.grid(color = 'w')

	ax3.set_title('Normalized XD profiles from STIS and WFC3')

	wfc3_xd_lower_y = wfc3_y_start
	wfc3_xd_upper_y = wfc3_y_start+stis_slit_height_pix
	print stis_slit_height_pix
	wfc3_xd_lower_x = wfc3_x_start
	wfc3_xd_upper_x = wfc3_x_end+1
	#Choose a small y region of background to normalize by
	normalization = np.max(np.sum(rot_wfc3_img[wfc3_y_start:wfc3_y_start + 1*stis_slit_height_pix, wfc3_x_start:wfc3_x_end+1], axis = 1))
	ax3.plot(np.sum(rot_wfc3_img[wfc3_xd_lower_y:wfc3_xd_upper_y, wfc3_xd_lower_x:wfc3_xd_upper_x], axis = 1)/normalization, np.arange(stis_slit_height_pix))
	ax3.legend(['WFC3'], loc = 1)
	#ax3.set_ylim(-25, 625)
	ax3.grid()
	#	ax3.axhspan(300, 400, color = 'k', alpha = 0.5)

	ax4 = ax3.twinx()
	img = fits.getdata(stis_img, 1)
	xd_profile = np.sum(img, axis = 1)

	multfactor = 1.
	xd_profile = congrid(xd_profile, multfactor*int(stis_slit_height_pix))
	ax4.plot(xd_profile/np.max(xd_profile[550:650]), np.arange(len(xd_profile))+0, color = 'g')
	#ax4.set_ylim(0, 1024)
	ax4.legend(['STIS'], loc = 4)
	#ax4.axhspan(319, 361, color = 'k', alpha = 0.5)
	ax4.axhspan(195, 216, color = 'k', alpha = 0.5)

	add_date_to_plot(ax3)
	pdb.set_trace()
	pyplot.savefig('2010jl_wfc3_finder_image_fuv.pdf')
예제 #5
0
def make_nuv_finder_plot(stis_img, wfc3_cc_offset, sn_yloc_stis = 461):
	'''
	Plot a 3 panel pdf of the WFPC2 image on the left, cropped to the slit location in the middle
	and the STIS cross-dispersion profile on the right. The region plotted for WFPC2 was determined
	by cross-correlating the cross-dispersion profiles of different x locations with the STIS data.
	This is performed in the notebook currently.
	'''
	wfc3_img = fits.getdata('hst_08645_11_wfpc2_f300w_wf/hst_08645_11_wfc3_f275w_wf_drz.fits', 1)
	orientat = 36.6-153.72
	rot_wfc3_img = rotate(wfc3_img, orientat)
	wfc3_y_start = 375+wfc3_cc_offset

	fig = pyplot.figure(figsize = [20, 15])
	ax1 = fig.add_subplot(1, 3, 1)
	ax2 = fig.add_subplot(1,3,2)
	ax3 = fig.add_subplot(1, 3, 3)

	wfc3_x_start = 709.0
	wfc3_platescale =  0.0394 #arcsec/pix
	stis_slit_height_pix = int(25.0/wfc3_platescale)
	stis_slit_width_pix = 0.5/wfc3_platescale
	wfc3_x_end = wfc3_x_start + stis_slit_width_pix

	ax1.set_title('WFC3 Image of 2010JL')
	im1 = ax1.imshow(rot_wfc3_img, interpolation = 'nearest', vmin = 0, vmax = 0.1)
	ax1.set_ylim(50, 1200)
	ax1.set_xlim(384, 884)

	ax2.set_title('STIS Slit position on WFC3 Image')
	im2 = ax2.imshow(rot_wfc3_img, interpolation = 'nearest', vmin = 0, vmax = 0.1)
	ax2.set_ylim(wfc3_y_start+0, wfc3_y_start+0+stis_slit_height_pix)
	ax2.set_xlim(684, 762)
	ax2.axvspan(684, wfc3_x_start, color = 'k', alpha = 0.5)
	ax2.axvspan(wfc3_x_end, 762, color = 'k', alpha = 0.5)
	ax2.set_yticks(np.arange(ax2.get_ylim()[0], ax2.get_ylim()[1], 50))
	ax2.grid(color = 'w')

	ax3.set_title('Normalized XD profiles from STIS (NUV) and WFC3')
	wfc3_xd_lower_y = wfc3_y_start
	wfc3_xd_upper_y = wfc3_y_start+stis_slit_height_pix
	wfc3_xd_lower_x = wfc3_x_start
	wfc3_xd_upper_x = wfc3_x_end+1
	#Choose a small y region of background to normalize by
	normalization = np.max(np.sum(rot_wfc3_img[wfc3_y_start:wfc3_y_start + 1*stis_slit_height_pix, wfc3_x_start:wfc3_x_end+1], axis = 1))
	ax3.plot(np.sum(rot_wfc3_img[wfc3_xd_lower_y:wfc3_xd_upper_y, wfc3_xd_lower_x:wfc3_xd_upper_x], axis = 1)/normalization, np.arange(stis_slit_height_pix))
	ax3.legend(['WFC3'], loc = 1)
	#ax3.set_ylim(0, 634)
	ax3.grid()

	ax4 = ax3.twinx()
	img = fits.getdata(stis_img, 1)
	xd_profile = np.sum(img, axis = 1)
	multfactor = 1.
	xd_profile = congrid(xd_profile, multfactor*int(stis_slit_height_pix))
	ax4.plot(xd_profile/np.max(xd_profile), np.arange(len(xd_profile)), color = 'g')
	#ax4.set_ylim(, len(binned_xd_profile)+max_corr_indx)
	ax4.legend(['STIS'], loc = 4)
	ax4.axhspan(262, 285, color = 'k', alpha = 0.5)

	add_date_to_plot(ax3)
	pdb.set_trace()
	pyplot.savefig('2010jl_wfc3_finder_image_fuv.pdf')
예제 #6
0
def make_fuv_finder_plot(stis_img, wfpc2_cc_offset, sn_yloc_stis=340):
    '''
	Plot a 3 panel pdf of the WFPC2 image on the left, cropped to the slit location in the middle
	and the STIS cross-dispersion profile on the right. The region plotted for WFPC2 was determined
	by cross-correlating the cross-dispersion profiles of different x locations with the STIS data.
	This is performed in the notebook currently.

	'''
    wfpc2_img = fits.getdata(
        'hst_08645_11_wfpc2_f300w_wf/hst_08645_11_wfpc2_f300w_wf_drz.fits', 1)
    orientat = 36.6144
    rot_wfpc2_img = rotate(wfpc2_img, orientat)
    wfpc2_y_start = 750

    fig = pyplot.figure(figsize=[20, 15])
    ax1 = fig.add_subplot(1, 3, 1)
    ax2 = fig.add_subplot(1, 3, 2)
    ax3 = fig.add_subplot(1, 3, 3)

    wfpc2_x_start = 1229.5
    wfpc2_x_end = 1234.5
    wfpc2_platescale = 0.1  #arcsec/pix
    stis_slit_height_pix = 25.0 / wfpc2_platescale
    stis_slit_width_pix = 0.5 / wfpc2_platescale

    ax1.set_title('WFPC2 Image of UGC 5189')
    im1 = ax1.imshow(rot_wfpc2_img, interpolation='nearest', vmin=0, vmax=0.2)
    ax1.set_ylim(700, 1150)
    ax1.set_xlim(1100, 1300)
    ax1.plot([1220, 1220, 1250, 1250, 1220], [
        wfpc2_y_start + wfpc2_cc_offset,
        wfpc2_y_start + wfpc2_cc_offset + stis_slit_height_pix,
        wfpc2_y_start + wfpc2_cc_offset + stis_slit_height_pix,
        wfpc2_y_start + wfpc2_cc_offset, wfpc2_y_start + wfpc2_cc_offset
    ],
             color='r')

    #Make compass
    north_dx = -50.0 * math.sin(orientat * math.pi / 180.0)
    north_dy = 50.0 * math.cos(orientat * math.pi / 180.0)
    east_dx = 50.0 * math.sin((90.0 - orientat) * math.pi / 180.0)
    east_dy = 50.0 * math.cos((90.0 - orientat) * math.pi / 180.0)
    arrow_center_x = 1150
    arrow_center_y = 1050
    ax1.arrow(arrow_center_x,
              arrow_center_y,
              north_dx,
              north_dy,
              color='w',
              width=0.5,
              head_length=12 * 0.5)
    ax1.arrow(arrow_center_x,
              arrow_center_y,
              east_dx,
              east_dy,
              color='w',
              width=0.5,
              head_length=12 * 0.5)
    ax1.text(arrow_center_x + north_dx,
             arrow_center_y + north_dy + 10,
             'N',
             color='w')
    ax1.text(arrow_center_x + east_dx,
             arrow_center_y + east_dy + 10,
             'E',
             color='w')

    ax2.set_title('STIS Slit position on WFPC2 Image')
    im2 = ax2.imshow(rot_wfpc2_img, interpolation='nearest', vmin=0, vmax=0.2)
    ax2.set_ylim(wfpc2_y_start + wfpc2_cc_offset,
                 wfpc2_y_start + wfpc2_cc_offset + stis_slit_height_pix)
    ax2.set_xlim(1220, 1250)
    ax2.axvspan(1220, wfpc2_x_start, color='k', alpha=0.5)
    ax2.axvspan(wfpc2_x_end, 1250, color='k', alpha=0.5)
    ax2.set_yticks(np.arange(ax2.get_ylim()[0], ax2.get_ylim()[1], 50))
    ax2.grid(color='w')

    ax3.set_title('Normalized XD profiles from STIS and WFPC2')
    ax3.plot(
        np.sum(rot_wfpc2_img[wfpc2_y_start + wfpc2_cc_offset:wfpc2_y_start +
                             wfpc2_cc_offset + stis_slit_height_pix,
                             wfpc2_x_start:wfpc2_x_end + 1],
               axis=1) / np.max(
                   np.sum(rot_wfpc2_img[wfpc2_y_start + wfpc2_cc_offset +
                                        120:wfpc2_y_start + wfpc2_cc_offset +
                                        175, wfpc2_x_start:wfpc2_x_end + 1],
                          axis=1)), np.arange(stis_slit_height_pix))
    ax3.legend(['WFPC2'], loc=1)
    ax3.grid()

    ax4 = ax3.twinx()
    img = fits.getdata(stis_img, 1)
    xd_profile = np.sum(img, axis=1)
    ax4.plot(xd_profile / np.max(xd_profile[550:650]),
             np.arange(len(xd_profile)),
             color='g')
    ax4.set_ylim(0, 1024)
    ax4.legend(['STIS'], loc=4)

    add_date_to_plot(ax3)
    pdb.set_trace()
    pyplot.savefig('2010jl_finder_image_fuv.pdf')
예제 #7
0
def make_fuv_finder_plot(stis_img, wfpc2_cc_offset, sn_yloc_stis=340):
    '''
	Plot a 3 panel pdf of the WFPC2 image on the left, cropped to the slit location in the middle
	and the STIS cross-dispersion profile on the right. The region plotted for WFPC2 was determined
	by cross-correlating the cross-dispersion profiles of different x locations with the STIS data.
	This is performed in the notebook currently.

	'''
    wfpc2_img = fits.getdata(
        'hst_08645_11_wfpc2_f300w_wf/hst_08645_11_wfpc2_f300w_wf_drz.fits', 1)
    orientat = 36.6144
    rot_wfpc2_img = rotate(wfpc2_img, orientat)
    wfpc2_y_start = 750

    fig = pyplot.figure(figsize=[20, 15])
    ax1 = fig.add_subplot(1, 3, 1)
    ax2 = fig.add_subplot(1, 3, 2)
    ax3 = fig.add_subplot(1, 3, 3)

    wfpc2_x_start = 1229.5
    wfpc2_x_end = 1234.5
    wfpc2_platescale = 0.1  #arcsec/pix
    stis_slit_height_pix = 25.0 / wfpc2_platescale
    stis_slit_width_pix = 0.5 / wfpc2_platescale

    ax1.set_title('WFPC2 Image of UGC 5189')
    im1 = ax1.imshow(rot_wfpc2_img, interpolation='nearest', vmin=0, vmax=0.2)
    ax1.set_ylim(700, 1150)
    ax1.set_xlim(1100, 1300)
    ax1.plot([1220, 1220, 1250, 1250, 1220], [
        wfpc2_y_start + wfpc2_cc_offset,
        wfpc2_y_start + wfpc2_cc_offset + stis_slit_height_pix,
        wfpc2_y_start + wfpc2_cc_offset + stis_slit_height_pix,
        wfpc2_y_start + wfpc2_cc_offset, wfpc2_y_start + wfpc2_cc_offset
    ],
             color='r')

    #Make compass
    north_dx = -50.0 * math.sin(orientat * math.pi / 180.0)
    north_dy = 50.0 * math.cos(orientat * math.pi / 180.0)
    east_dx = 50.0 * math.sin((90.0 - orientat) * math.pi / 180.0)
    east_dy = 50.0 * math.cos((90.0 - orientat) * math.pi / 180.0)
    arrow_center_x = 1150
    arrow_center_y = 1050
    ax1.arrow(
        arrow_center_x,
        arrow_center_y,
        north_dx,
        north_dy,
        color='w',
        width=0.5,
        head_length=12 * 0.5)
    ax1.arrow(
        arrow_center_x,
        arrow_center_y,
        east_dx,
        east_dy,
        color='w',
        width=0.5,
        head_length=12 * 0.5)
    ax1.text(
        arrow_center_x + north_dx,
        arrow_center_y + north_dy + 10,
        'N',
        color='w')
    ax1.text(
        arrow_center_x + east_dx,
        arrow_center_y + east_dy + 10,
        'E',
        color='w')

    ax2.set_title('STIS Slit position on WFPC2 Image')
    im2 = ax2.imshow(rot_wfpc2_img, interpolation='nearest', vmin=0, vmax=0.2)
    ax2.set_ylim(wfpc2_y_start + wfpc2_cc_offset,
                 wfpc2_y_start + wfpc2_cc_offset + stis_slit_height_pix)
    ax2.set_xlim(1220, 1250)
    ax2.axvspan(1220, wfpc2_x_start, color='k', alpha=0.5)
    ax2.axvspan(wfpc2_x_end, 1250, color='k', alpha=0.5)
    ax2.set_yticks(np.arange(ax2.get_ylim()[0], ax2.get_ylim()[1], 50))
    ax2.grid(color='w')

    ax3.set_title('Normalized XD profiles from STIS and WFPC2')
    ax3.plot(
        np.sum(
            rot_wfpc2_img[wfpc2_y_start + wfpc2_cc_offset:wfpc2_y_start +
                          wfpc2_cc_offset +
                          stis_slit_height_pix, wfpc2_x_start:wfpc2_x_end + 1],
            axis=1) / np.max(
                np.sum(
                    rot_wfpc2_img[wfpc2_y_start + wfpc2_cc_offset +
                                  120:wfpc2_y_start + wfpc2_cc_offset +
                                  175, wfpc2_x_start:wfpc2_x_end + 1],
                    axis=1)), np.arange(stis_slit_height_pix))
    ax3.legend(['WFPC2'], loc=1)
    ax3.grid()

    ax4 = ax3.twinx()
    img = fits.getdata(stis_img, 1)
    xd_profile = np.sum(img, axis=1)
    ax4.plot(
        xd_profile / np.max(xd_profile[550:650]),
        np.arange(len(xd_profile)),
        color='g')
    ax4.set_ylim(0, 1024)
    ax4.legend(['STIS'], loc=4)

    add_date_to_plot(ax3)
    pdb.set_trace()
    pyplot.savefig('2010jl_finder_image_fuv.pdf')
예제 #8
0
def make_fuv_finder_plot(stis_img, wfc3_cc_offset, sn_yloc_stis = 331):
	'''
	Plot a 3 panel pdf of the WFC3 image on the left, cropped to the slit location in the middle
	and the STIS cross-dispersion profile on the right. The region plotted for WFPC2 was determined
	by cross-correlating the cross-dispersion profiles of different x locations with the STIS data.
	This is performed in the notebook currently.
	'''
	wfc3_img = fits.getdata('hst_08645_11_wfpc2_f300w_wf/hst_08645_11_wfc3_f275w_wf_drz.fits', 1)
	orientat = 36.6-153.72  #+90
	rot_wfc3_img = rotate(wfc3_img, orientat)
	wfc3_y_start = 375+wfc3_cc_offset

	fig = pyplot.figure(figsize = [20, 15])
	ax1 = fig.add_subplot(1, 3, 1)
	ax2 = fig.add_subplot(1,3,2)
	ax3 = fig.add_subplot(1, 3, 3)

	wfc3_x_start = 717.0
	wfc3_platescale =  0.0394 #arcsec/pix
	stis_slit_height_pix = int(25.0/wfc3_platescale)
	stis_slit_width_pix = 0.5/wfc3_platescale
	wfc3_x_end = wfc3_x_start + stis_slit_width_pix
	
	ax1.set_title('WFC3 Image of 2006gy')
	im1 = ax1.imshow(rot_wfc3_img, interpolation = 'nearest', vmin = 0, vmax = 0.1)
	ax1.set_ylim(50, 1200)
	ax1.set_xlim(384, 884)
	#ax1.plot([1220, 1220, 1250, 1250, 1220], [wfc3_y_start+wfc3_cc_offset, wfc3_y_start+wfc3_cc_offset+stis_slit_height_pix, wfc3_y_start+wfc3_cc_offset+stis_slit_height_pix, wfc3_y_start+wfc3_cc_offset, wfc3_y_start+wfc3_cc_offset], color = 'r')

	#Make compass
	#north_dx = -50.0*math.sin(orientat*math.pi/180.0)
	#north_dy = 50.0*math.cos(orientat*math.pi/180.0)
	#east_dx = 50.0*math.sin((90.0-orientat)*math.pi/180.0)
	#east_dy = 50.0*math.cos((90.0-orientat)*math.pi/180.0)
	#arrow_center_x = 1150
	#arrow_center_y = 1050
	#ax1.arrow(arrow_center_x, arrow_center_y, north_dx, north_dy, color = 'w', width = 0.5, head_length = 12*0.5)
	#ax1.arrow(arrow_center_x, arrow_center_y, east_dx, east_dy, color = 'w', width = 0.5, head_length = 12*0.5)
	#ax1.text(arrow_center_x + north_dx, arrow_center_y + north_dy +10, 'N', color = 'w' )
	#ax1.text(arrow_center_x + east_dx, arrow_center_y + east_dy +10, 'E', color = 'w' )

	ax2.set_title('STIS Slit position on WFC3 Image')
	im2 = ax2.imshow(rot_wfc3_img, interpolation = 'nearest', vmin = 0, vmax = 0.1)
	#ax2.set_ylim(wfc3_y_start+wfc3_cc_offset, wfc3_y_start+wfc3_cc_offset+stis_slit_height_pix)
	ax2.set_ylim(wfc3_y_start+0, wfc3_y_start+0+stis_slit_height_pix)
	ax2.set_xlim(684, 762)
	ax2.axvspan(684, wfc3_x_start, color = 'k', alpha = 0.5)
	ax2.axvspan(wfc3_x_end, 762, color = 'k', alpha = 0.5)
	ax2.set_yticks(np.arange(ax2.get_ylim()[0], ax2.get_ylim()[1], 50))
	ax2.grid(color = 'w')

	ax3.set_title('Normalized XD profiles from STIS and WFC3')
	wfc3_xd_lower_y = wfc3_y_start
	wfc3_xd_upper_y = wfc3_y_start+stis_slit_height_pix
	print stis_slit_height_pix
	wfc3_xd_lower_x = wfc3_x_start
	wfc3_xd_upper_x = wfc3_x_end+1
	#Choose a small y region of background to normalize by
	normalization = np.max(np.sum(rot_wfc3_img[wfc3_y_start:wfc3_y_start + 1*stis_slit_height_pix, wfc3_x_start:wfc3_x_end+1], axis = 1))
	ax3.plot(np.sum(rot_wfc3_img[wfc3_xd_lower_y:wfc3_xd_upper_y, wfc3_xd_lower_x:wfc3_xd_upper_x], axis = 1)/normalization, np.arange(stis_slit_height_pix))
	ax3.legend(['WFC3'], loc = 1)
	#ax3.set_ylim(-25, 625)
	ax3.grid()
	#	ax3.axhspan(300, 400, color = 'k', alpha = 0.5)

	ax4 = ax3.twinx()
	img = fits.getdata(stis_img, 1)
	xd_profile = np.sum(img, axis = 1)
	multfactor = 1.
	xd_profile = congrid(xd_profile, multfactor*int(stis_slit_height_pix))
	ax4.plot(xd_profile/np.max(xd_profile[550:650]), np.arange(len(xd_profile))+0, color = 'g')
	#ax4.set_ylim(0, 1024)
	ax4.legend(['STIS'], loc = 4)
	#ax4.axhspan(319, 361, color = 'k', alpha = 0.5)
	ax4.axhspan(195, 216, color = 'k', alpha = 0.5)

	add_date_to_plot(ax3)
	pdb.set_trace()
	pyplot.savefig('2006gy_wfc3_finder_image_fuv.pdf')
예제 #9
0
def make_nuv_finder_plot(stis_img, wfc3_cc_offset, sn_yloc_stis=461):
    '''
	Plot a 3 panel pdf of the WFPC2 image on the left, cropped to the slit location in the middle
	and the STIS cross-dispersion profile on the right. The region plotted for WFPC2 was determined
	by cross-correlating the cross-dispersion profiles of different x locations with the STIS data.
	This is performed in the notebook currently.
	'''
    wfc3_img = fits.getdata(
        'hst_08645_11_wfpc2_f300w_wf/hst_08645_11_wfc3_f275w_wf_drz.fits', 1)
    orientat = 36.6 - 153.72
    rot_wfc3_img = rotate(wfc3_img, orientat)
    wfc3_y_start = 375 + wfc3_cc_offset

    fig = pyplot.figure(figsize=[20, 15])
    ax1 = fig.add_subplot(1, 3, 1)
    ax2 = fig.add_subplot(1, 3, 2)
    ax3 = fig.add_subplot(1, 3, 3)

    wfc3_x_start = 709.0
    wfc3_platescale = 0.0394  #arcsec/pix
    stis_slit_height_pix = int(25.0 / wfc3_platescale)
    stis_slit_width_pix = 0.5 / wfc3_platescale
    wfc3_x_end = wfc3_x_start + stis_slit_width_pix

    ax1.set_title('WFC3 Image of 2010JL')
    im1 = ax1.imshow(rot_wfc3_img, interpolation='nearest', vmin=0, vmax=0.1)
    ax1.set_ylim(50, 1200)
    ax1.set_xlim(384, 884)

    ax2.set_title('STIS Slit position on WFC3 Image')
    im2 = ax2.imshow(rot_wfc3_img, interpolation='nearest', vmin=0, vmax=0.1)
    ax2.set_ylim(wfc3_y_start + 0, wfc3_y_start + 0 + stis_slit_height_pix)
    ax2.set_xlim(684, 762)
    ax2.axvspan(684, wfc3_x_start, color='k', alpha=0.5)
    ax2.axvspan(wfc3_x_end, 762, color='k', alpha=0.5)
    ax2.set_yticks(np.arange(ax2.get_ylim()[0], ax2.get_ylim()[1], 50))
    ax2.grid(color='w')

    ax3.set_title('Normalized XD profiles from STIS (NUV) and WFC3')
    wfc3_xd_lower_y = wfc3_y_start
    wfc3_xd_upper_y = wfc3_y_start + stis_slit_height_pix
    wfc3_xd_lower_x = wfc3_x_start
    wfc3_xd_upper_x = wfc3_x_end + 1
    #Choose a small y region of background to normalize by
    normalization = np.max(
        np.sum(
            rot_wfc3_img[wfc3_y_start:wfc3_y_start + 1 * stis_slit_height_pix,
                         wfc3_x_start:wfc3_x_end + 1],
            axis=1))
    ax3.plot(
        np.sum(rot_wfc3_img[wfc3_xd_lower_y:wfc3_xd_upper_y,
                            wfc3_xd_lower_x:wfc3_xd_upper_x],
               axis=1) / normalization, np.arange(stis_slit_height_pix))
    ax3.legend(['WFC3'], loc=1)
    #ax3.set_ylim(0, 634)
    ax3.grid()

    ax4 = ax3.twinx()
    img = fits.getdata(stis_img, 1)
    xd_profile = np.sum(img, axis=1)
    multfactor = 1.
    xd_profile = congrid(xd_profile, multfactor * int(stis_slit_height_pix))
    ax4.plot(xd_profile / np.max(xd_profile),
             np.arange(len(xd_profile)),
             color='g')
    #ax4.set_ylim(, len(binned_xd_profile)+max_corr_indx)
    ax4.legend(['STIS'], loc=4)
    ax4.axhspan(262, 285, color='k', alpha=0.5)

    add_date_to_plot(ax3)
    pdb.set_trace()
    pyplot.savefig('2010jl_wfc3_finder_image_fuv.pdf')