diff --git a/plots/NGC1068_x274020/NGC1068_FOC_POL0_crop_region.png b/plots/NGC1068_x274020/NGC1068_FOC_POL0_crop_region.png new file mode 100644 index 0000000..cc248e5 Binary files /dev/null and b/plots/NGC1068_x274020/NGC1068_FOC_POL0_crop_region.png differ diff --git a/plots/NGC1068_x274020/NGC1068_FOC_center_image.png b/plots/NGC1068_x274020/NGC1068_FOC_center_image.png new file mode 100644 index 0000000..b4706bf Binary files /dev/null and b/plots/NGC1068_x274020/NGC1068_FOC_center_image.png differ diff --git a/plots/NGC1068_x274020/NGC1068_FOC_crop_region.png b/plots/NGC1068_x274020/NGC1068_FOC_crop_region.png new file mode 100644 index 0000000..d05c2cb Binary files /dev/null and b/plots/NGC1068_x274020/NGC1068_FOC_crop_region.png differ diff --git a/plots/NGC1068_x274020/NGC1068_FOC_errors_POL0_background_location.png b/plots/NGC1068_x274020/NGC1068_FOC_errors_POL0_background_location.png new file mode 100644 index 0000000..74f3ddc Binary files /dev/null and b/plots/NGC1068_x274020/NGC1068_FOC_errors_POL0_background_location.png differ diff --git a/plots/NGC1068_x274020/NGC1068_FOC_errors_background_flux.png b/plots/NGC1068_x274020/NGC1068_FOC_errors_background_flux.png new file mode 100644 index 0000000..01f1423 Binary files /dev/null and b/plots/NGC1068_x274020/NGC1068_FOC_errors_background_flux.png differ diff --git a/plots/NGC1068_x274020/NGC1068_FOC_errors_background_location.png b/plots/NGC1068_x274020/NGC1068_FOC_errors_background_location.png new file mode 100644 index 0000000..97b246c Binary files /dev/null and b/plots/NGC1068_x274020/NGC1068_FOC_errors_background_location.png differ diff --git a/src/FOC_reduction.py b/src/FOC_reduction.py index bd5d29c..b6a07d9 100755 --- a/src/FOC_reduction.py +++ b/src/FOC_reduction.py @@ -104,14 +104,14 @@ def main(): rebin = True if rebin: pxsize = 0.10 - px_scale = 'full' #pixel, arcsec or full + px_scale = 'arcsec' #pixel, arcsec or full rebin_operation = 'sum' #sum or average # Alignement align_center = 'image' #If None will align image to image center display_data = False # Smoothing smoothing_function = 'combine' #gaussian_after, gaussian or combine - smoothing_FWHM = None #If None, no smoothing is done + smoothing_FWHM = 0.20 #If None, no smoothing is done smoothing_scale = 'arcsec' #pixel or arcsec # Rotation rotate_stokes = True #rotation to North convention can give erroneous results @@ -120,7 +120,7 @@ def main(): crop = False #Crop to desired ROI # Polarization map output figname = 'NGC1068_FOC' #target/intrument name - figtype = '_full' #additionnal informations + figtype = '_combine_FWHM020' #additionnal informations SNRp_cut = 10. #P measurments with SNR>3 SNRi_cut = 100. #I measurments with SNR>30, which implies an uncertainty in P of 4.7%. step_vec = 1 #plot all vectors in the array. if step_vec = 2, then every other vector will be plotted diff --git a/src/lib/plots.py b/src/lib/plots.py index f5a53f8..8eec25d 100755 --- a/src/lib/plots.py +++ b/src/lib/plots.py @@ -1137,17 +1137,18 @@ class pol_map(object): ax_save = self.fig.add_axes([0.850, 0.070, 0.05, 0.02]) b_save = Button(ax_save, "Save") ax_text_save = self.fig.add_axes([0.3, 0.020, 0.5, 0.025],visible=False) - text_box = TextBox(ax_text_save, "Save to:", initial='') + text_save = TextBox(ax_text_save, "Save to:", initial='') def saveplot(event): ax_text_save.set(visible=True) ax_snr_reset.set(visible=False) ax_save.set(visible=False) + ax_dump.set(visible=False) self.fig.canvas.draw_idle() b_save.on_clicked(saveplot) - def submit(expression): + def submit_save(expression): ax_text_save.set(visible=False) if expression != '': save_fig = plt.figure(figsize=(15,15)) @@ -1161,12 +1162,57 @@ class pol_map(object): expression += '.png' save_fig.savefig(expression, bbox_inches='tight', dpi=200) plt.close(save_fig) - text_box.set_val('') + text_save.set_val('') ax_snr_reset.set(visible=True) ax_save.set(visible=True) + ax_dump.set(visible=True) self.fig.canvas.draw_idle() - text_box.on_submit(submit) + text_save.on_submit(submit_save) + + #Set axe for data dump + ax_dump = self.fig.add_axes([0.850, 0.045, 0.05, 0.02]) + b_dump = Button(ax_dump, "Dump") + ax_text_dump = self.fig.add_axes([0.3, 0.020, 0.5, 0.025],visible=False) + text_dump = TextBox(ax_text_dump, "Dump to:", initial='') + + def dump(event): + ax_text_dump.set(visible=True) + ax_snr_reset.set(visible=False) + ax_save.set(visible=False) + ax_dump.set(visible=False) + self.fig.canvas.draw_idle() + + shape = np.array(self.I.shape) + center = (shape/2).astype(int) + cdelt_arcsec = self.wcs.wcs.cdelt*3600 + xx, yy = np.indices(shape) + x, y = (xx-center[0])*cdelt_arcsec[0], (yy-center[1])*cdelt_arcsec[1] + + P, PA = np.zeros(shape), np.zeros(shape) + P[self.cut] = self.P[self.cut] + PA[self.cut] = self.PA[self.cut] + dump_list = [] + for i in range(shape[0]): + for j in range(shape[1]): + dump_list.append([x[i,j], y[i,j], self.I[i,j]*self.convert_flux, self.Q[i,j]*self.convert_flux, self.U[i,j]*self.convert_flux, P[i,j], PA[i,j]]) + self.data_dump = np.array(dump_list) + + b_dump.on_clicked(dump) + + def submit_dump(expression): + ax_text_dump.set(visible=False) + if expression != '': + if not expression[-4:] in ['.txt', '.dat']: + expression += '.txt' + np.savetxt(expression, self.data_dump) + text_dump.set_val('') + ax_snr_reset.set(visible=True) + ax_save.set(visible=True) + ax_dump.set(visible=True) + self.fig.canvas.draw_idle() + + text_dump.on_submit(submit_dump) #Set axes for display buttons ax_tf = self.fig.add_axes([0.925, 0.085, 0.05, 0.02]) diff --git a/src/lib/reduction.py b/src/lib/reduction.py index c1c0e33..4f9ad20 100755 --- a/src/lib/reduction.py +++ b/src/lib/reduction.py @@ -500,17 +500,41 @@ def get_error(data_array, headers, sub_shape=(15,15), display=False, ax.set_title("Background flux and error computed for each image") plt.legend() + fig2, ax2 = plt.subplots(figsize=(10,10)) + data0 = data[0]*convert_flux + instr = headers[0]['instrume'] + rootname = headers[0]['rootname'] + exptime = headers[0]['exptime'] + filt = headers[0]['filtnam1'] + #plots + im = ax2.imshow(data0, vmin=data0.min(), vmax=data0.max(), origin='lower', cmap='gray') + x, y, width, height, angle, color = rectangle[0] + ax2.add_patch(Rectangle((x, y),width,height,edgecolor=color,fill=False)) + ax2.annotate(instr+":"+rootname, color='white', fontsize=5, + xy=(0.02, 0.95), xycoords='axes fraction') + ax2.annotate(filt, color='white', fontsize=10, xy=(0.02, 0.02), + xycoords='axes fraction') + ax2.annotate(exptime, color='white', fontsize=5, xy=(0.80, 0.02), + xycoords='axes fraction') + ax2.set(title="Location of background computation.", + xlabel='pixel offset', + ylabel='pixel offset') + + fig2.subplots_adjust(hspace=0, wspace=0, right=0.85) + cbar_ax = fig2.add_axes([0.9, 0.12, 0.02, 0.75]) + fig2.colorbar(im, cax=cbar_ax, label=r"Flux [$ergs \cdot cm^{-2} \cdot s^{-1} \cdot \AA^{-1}$]") + if not(savename is None): - #fig.suptitle(savename+"_background_flux") fig.savefig(plots_folder+savename+"_background_flux.png", bbox_inches='tight') + fig2.savefig(plots_folder+savename+'_'+filt+'_background_location.png', + bbox_inches='tight') vmin = np.min(np.log10(data[data > 0.])) vmax = np.max(np.log10(data[data > 0.])) plot_obs(data, headers, vmin=data.min(), vmax=data.max(), rectangle=rectangle, savename=savename+"_background_location", plots_folder=plots_folder) - else: vmin = np.min(np.log10(data[data > 0.])) vmax = np.max(np.log10(data[data > 0.])) @@ -1186,7 +1210,7 @@ def compute_Stokes(data_array, error_array, data_mask, headers, Stokes_cov[0,0], Stokes_cov[1,1], Stokes_cov[2,2] = Stokes_error**2 #Compute integrated values for P, PA before any rotation - mask = deepcopy(data_mask).astype(bool) + mask = np.logical_and(data_mask.astype(bool), (I_stokes > 0.)) n_pix = I_stokes[mask].size I_diluted = I_stokes[mask].sum() Q_diluted = Q_stokes[mask].sum()