diff --git a/plots/3C405_x136060/3C405_FOC.png b/plots/3C405_x136060/3C405_FOC.png index 3e4e33f..6039ec0 100644 Binary files a/plots/3C405_x136060/3C405_FOC.png and b/plots/3C405_x136060/3C405_FOC.png differ diff --git a/plots/3C405_x136060/3C405_FOC_IQU.png b/plots/3C405_x136060/3C405_FOC_IQU.png index 2ff927a..b901eda 100644 Binary files a/plots/3C405_x136060/3C405_FOC_IQU.png and b/plots/3C405_x136060/3C405_FOC_IQU.png differ diff --git a/plots/3C405_x136060/3C405_FOC_P.png b/plots/3C405_x136060/3C405_FOC_P.png index 8a4dcbd..e7a0624 100644 Binary files a/plots/3C405_x136060/3C405_FOC_P.png and b/plots/3C405_x136060/3C405_FOC_P.png differ diff --git a/plots/3C405_x136060/3C405_FOC_P_err.png b/plots/3C405_x136060/3C405_FOC_P_err.png index 9d097e3..0ac67ca 100644 Binary files a/plots/3C405_x136060/3C405_FOC_P_err.png and b/plots/3C405_x136060/3C405_FOC_P_err.png differ diff --git a/plots/3C405_x136060/3C405_FOC_SNRi.png b/plots/3C405_x136060/3C405_FOC_SNRi.png index 7bf918f..262d65a 100644 Binary files a/plots/3C405_x136060/3C405_FOC_SNRi.png and b/plots/3C405_x136060/3C405_FOC_SNRi.png differ diff --git a/plots/3C405_x136060/3C405_FOC_SNRp.png b/plots/3C405_x136060/3C405_FOC_SNRp.png index 182d152..e7f34ec 100644 Binary files a/plots/3C405_x136060/3C405_FOC_SNRp.png and b/plots/3C405_x136060/3C405_FOC_SNRp.png differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM050.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM050.png new file mode 100644 index 0000000..f8844fc Binary files /dev/null and b/plots/3C405_x136060/3C405_FOC_combine_FWHM050.png differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_IQU.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_IQU.png new file mode 100644 index 0000000..fce39e3 Binary files /dev/null and b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_IQU.png differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_P.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_P.png new file mode 100644 index 0000000..d89eef5 Binary files /dev/null and b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_P.png differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_P_err.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_P_err.png new file mode 100644 index 0000000..804669c Binary files /dev/null and b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_P_err.png differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_SNRi.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_SNRi.png new file mode 100644 index 0000000..88d5fc7 Binary files /dev/null and b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_SNRi.png differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_SNRp.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_SNRp.png new file mode 100644 index 0000000..7f97d3c Binary files /dev/null and b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_SNRp.png differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot.png index 04d7c0a..20ecec3 100644 Binary files a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot.png and b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot.png differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot2.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot2.png deleted file mode 100644 index 3badc44..0000000 Binary files a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot2.png and /dev/null differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot2_P.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot2_P.png deleted file mode 100644 index 903b610..0000000 Binary files a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot2_P.png and /dev/null differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot2_P_err.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot2_P_err.png deleted file mode 100644 index 3a163e7..0000000 Binary files a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot2_P_err.png and /dev/null differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot2_SNRi.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot2_SNRi.png deleted file mode 100644 index 59837fa..0000000 Binary files a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot2_SNRi.png and /dev/null differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot2_SNRp.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot2_SNRp.png deleted file mode 100644 index c2aa209..0000000 Binary files a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot2_SNRp.png and /dev/null differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot_IQU.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot_IQU.png new file mode 100644 index 0000000..22ec9a4 Binary files /dev/null and b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot_IQU.png differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot_P.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot_P.png index 571252b..cb52848 100644 Binary files a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot_P.png and b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot_P.png differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot_P_err.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot_P_err.png index 3525564..ae4bfc9 100644 Binary files a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot_P_err.png and b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot_P_err.png differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot_SNRi.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot_SNRi.png index b676114..22f1712 100644 Binary files a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot_SNRi.png and b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot_SNRi.png differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot_SNRp.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot_SNRp.png index 63c1da2..e5238fc 100644 Binary files a/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot_SNRp.png and b/plots/3C405_x136060/3C405_FOC_combine_FWHM050_rot_SNRp.png differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM100.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM100.png new file mode 100644 index 0000000..21b7fb8 Binary files /dev/null and b/plots/3C405_x136060/3C405_FOC_combine_FWHM100.png differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_IQU.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_IQU.png new file mode 100644 index 0000000..47abb7b Binary files /dev/null and b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_IQU.png differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_P.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_P.png new file mode 100644 index 0000000..ae77612 Binary files /dev/null and b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_P.png differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_P_err.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_P_err.png new file mode 100644 index 0000000..4ffb210 Binary files /dev/null and b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_P_err.png differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_SNRi.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_SNRi.png new file mode 100644 index 0000000..a5a7790 Binary files /dev/null and b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_SNRi.png differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_SNRp.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_SNRp.png new file mode 100644 index 0000000..e99ea6a Binary files /dev/null and b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_SNRp.png differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot.png index 737561d..b096eed 100644 Binary files a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot.png and b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot.png differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot2.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot2.png deleted file mode 100644 index 8fd9cd1..0000000 Binary files a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot2.png and /dev/null differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot2_P.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot2_P.png deleted file mode 100644 index 3c700bd..0000000 Binary files a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot2_P.png and /dev/null differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot2_P_err.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot2_P_err.png deleted file mode 100644 index 9b6128d..0000000 Binary files a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot2_P_err.png and /dev/null differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot2_SNRi.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot2_SNRi.png deleted file mode 100644 index 40a780a..0000000 Binary files a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot2_SNRi.png and /dev/null differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot2_SNRp.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot2_SNRp.png deleted file mode 100644 index 4a659fe..0000000 Binary files a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot2_SNRp.png and /dev/null differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot_IQU.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot_IQU.png new file mode 100644 index 0000000..d81a259 Binary files /dev/null and b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot_IQU.png differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot_P.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot_P.png index 10c7c6e..797ef42 100644 Binary files a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot_P.png and b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot_P.png differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot_P_err.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot_P_err.png index 24e2d13..6b8a1c3 100644 Binary files a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot_P_err.png and b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot_P_err.png differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot_SNRi.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot_SNRi.png index e97c3be..3b1080c 100644 Binary files a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot_SNRi.png and b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot_SNRi.png differ diff --git a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot_SNRp.png b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot_SNRp.png index 67967dd..356406b 100644 Binary files a/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot_SNRp.png and b/plots/3C405_x136060/3C405_FOC_combine_FWHM100_rot_SNRp.png differ diff --git a/plots/3C405_x136060/3C405_FOC_rot.png b/plots/3C405_x136060/3C405_FOC_rot.png index 6fc10c2..fab38b2 100644 Binary files a/plots/3C405_x136060/3C405_FOC_rot.png and b/plots/3C405_x136060/3C405_FOC_rot.png differ diff --git a/plots/3C405_x136060/3C405_FOC_rot2.png b/plots/3C405_x136060/3C405_FOC_rot2.png deleted file mode 100644 index 4d4f8e8..0000000 Binary files a/plots/3C405_x136060/3C405_FOC_rot2.png and /dev/null differ diff --git a/plots/3C405_x136060/3C405_FOC_rot2_P.png b/plots/3C405_x136060/3C405_FOC_rot2_P.png deleted file mode 100644 index b834bc7..0000000 Binary files a/plots/3C405_x136060/3C405_FOC_rot2_P.png and /dev/null differ diff --git a/plots/3C405_x136060/3C405_FOC_rot2_P_err.png b/plots/3C405_x136060/3C405_FOC_rot2_P_err.png deleted file mode 100644 index a65ea6d..0000000 Binary files a/plots/3C405_x136060/3C405_FOC_rot2_P_err.png and /dev/null differ diff --git a/plots/3C405_x136060/3C405_FOC_rot2_SNRi.png b/plots/3C405_x136060/3C405_FOC_rot2_SNRi.png deleted file mode 100644 index 85dd654..0000000 Binary files a/plots/3C405_x136060/3C405_FOC_rot2_SNRi.png and /dev/null differ diff --git a/plots/3C405_x136060/3C405_FOC_rot2_SNRp.png b/plots/3C405_x136060/3C405_FOC_rot2_SNRp.png deleted file mode 100644 index 3d4b0ab..0000000 Binary files a/plots/3C405_x136060/3C405_FOC_rot2_SNRp.png and /dev/null differ diff --git a/plots/3C405_x136060/3C405_FOC_rot_IQU.png b/plots/3C405_x136060/3C405_FOC_rot_IQU.png new file mode 100644 index 0000000..5f37938 Binary files /dev/null and b/plots/3C405_x136060/3C405_FOC_rot_IQU.png differ diff --git a/plots/3C405_x136060/3C405_FOC_rot_P.png b/plots/3C405_x136060/3C405_FOC_rot_P.png index 07c5237..f3e7745 100644 Binary files a/plots/3C405_x136060/3C405_FOC_rot_P.png and b/plots/3C405_x136060/3C405_FOC_rot_P.png differ diff --git a/plots/3C405_x136060/3C405_FOC_rot_P_err.png b/plots/3C405_x136060/3C405_FOC_rot_P_err.png index 22b3807..92e0792 100644 Binary files a/plots/3C405_x136060/3C405_FOC_rot_P_err.png and b/plots/3C405_x136060/3C405_FOC_rot_P_err.png differ diff --git a/plots/3C405_x136060/3C405_FOC_rot_SNRi.png b/plots/3C405_x136060/3C405_FOC_rot_SNRi.png index bffd445..2aa266f 100644 Binary files a/plots/3C405_x136060/3C405_FOC_rot_SNRi.png and b/plots/3C405_x136060/3C405_FOC_rot_SNRi.png differ diff --git a/plots/3C405_x136060/3C405_FOC_rot_SNRp.png b/plots/3C405_x136060/3C405_FOC_rot_SNRp.png index 8514e1c..09f7aaf 100644 Binary files a/plots/3C405_x136060/3C405_FOC_rot_SNRp.png and b/plots/3C405_x136060/3C405_FOC_rot_SNRp.png differ diff --git a/src/FOC_reduction.py b/src/FOC_reduction.py index a9a3691..3e9d226 100755 --- a/src/FOC_reduction.py +++ b/src/FOC_reduction.py @@ -87,7 +87,7 @@ def main(): iterations = 10 # Error estimation error_sub_shape = (75,75) - display_error = True + display_error = False # Data binning rebin = True if rebin: @@ -96,17 +96,17 @@ def main(): rebin_operation = 'sum' #sum or average # Alignement align_center = 'image' #If None will align image to image center - display_data = True + display_data = False # Smoothing smoothing_function = 'combine' #gaussian_after, gaussian or combine - smoothing_FWHM = None #If None, no smoothing is done + smoothing_FWHM = 1.00 #If None, no smoothing is done smoothing_scale = 'arcsec' #pixel or arcsec # Rotation rotate_stokes = False #rotation to North convention can give erroneous results rotate_data = False #rotation to North convention can give erroneous results # Polarization map output figname = '3C405_FOC' #target/intrument name - figtype = '' #additionnal informations + figtype = '_combine_FWHM100' #additionnal informations SNRp_cut = 3 #P measurments with SNR>3 SNRi_cut = 30 #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 @@ -165,7 +165,7 @@ def main(): # Rotate images to have North up if rotate_stokes: ref_header = copy.deepcopy(headers[0]) - I_stokes, Q_stokes, U_stokes, Stokes_cov, headers = proj_red.rotate_Stokes(I_stokes, Q_stokes, U_stokes, Stokes_cov, headers, -ref_header['orientat']) + I_stokes, Q_stokes, U_stokes, Stokes_cov, headers = proj_red.rotate_Stokes(I_stokes, Q_stokes, U_stokes, Stokes_cov, headers, -ref_header['orientat'], SNRi_cut=None) # Compute polarimetric parameters (polarization degree and angle). P, debiased_P, s_P, s_P_P, PA, s_PA, s_PA_P = proj_red.compute_pol(I_stokes, Q_stokes, U_stokes, Stokes_cov, headers) diff --git a/src/lib/plots.py b/src/lib/plots.py index 9460122..8e04b70 100755 --- a/src/lib/plots.py +++ b/src/lib/plots.py @@ -184,7 +184,7 @@ def polarization_map(Stokes, SNRp_cut=3., SNRi_cut=30., step_vec=1, pang_err = Stokes[np.argmax([Stokes[i].header['datatype']=='Pol_ang_err' for i in range(len(Stokes))])] pivot_wav = Stokes[0].header['photplam'] - convert_flux = 1.#Stokes[0].header['photflam'] + convert_flux = Stokes[0].header['photflam'] wcs = WCS(Stokes[0]).deepcopy() #Plot Stokes parameters map @@ -194,11 +194,13 @@ def polarization_map(Stokes, SNRp_cut=3., SNRi_cut=30., step_vec=1, #Compute SNR and apply cuts pol.data[pol.data == 0.] = np.nan SNRp = pol.data/pol_err.data + SNRp[np.isnan(SNRp)] = 0. pol.data[SNRp < SNRp_cut] = np.nan SNRi = stkI.data/np.sqrt(stk_cov.data[0,0]) + SNRi[np.isnan(SNRi)] = 0. pol.data[SNRi < SNRi_cut] = np.nan - mask = (SNRp < SNRp_cut) * (SNRi < SNRi_cut) + mask = (SNRp > SNRp_cut) * (SNRi > SNRi_cut) # Look for pixel of max polarization if np.isfinite(pol.data).any(): diff --git a/src/lib/reduction.py b/src/lib/reduction.py index e6bece2..25227a4 100755 --- a/src/lib/reduction.py +++ b/src/lib/reduction.py @@ -646,15 +646,14 @@ def align_data(data_array, error_array=None, upsample_factor=1., ref_data=None, # Create a rescaled null array that can contain any rotation of the #original image (and shifted images) shape = data_array.shape - res_shape = int(np.ceil(np.sqrt(2)*np.max(shape[1:]))) - rescaled_image = np.ones((shape[0],res_shape,res_shape)) + res_shape = int(np.ceil(np.sqrt(2.5)*np.max(shape[1:]))) + rescaled_image = np.zeros((shape[0],res_shape,res_shape)) rescaled_error = np.ones((shape[0],res_shape,res_shape)) res_center = (np.array(rescaled_image.shape[1:])/2).astype(int) shifts, errors = [], [] for i,image in enumerate(data_array): # Initialize rescaled images to background values - rescaled_image[i] *= 0.*background[i] rescaled_error[i] *= background[i] # Get shifts and error by cross-correlation to ref_data shift, error, phase_diff = phase_cross_correlation(ref_data, image, @@ -1004,10 +1003,10 @@ def compute_Stokes(data_array, error_array, headers, FWHM=None, #Remove nan I_stokes[np.isnan(I_stokes)]=0. - Q_stokes[np.isnan(Q_stokes)]=0. Q_stokes[I_stokes == 0.]=0. - U_stokes[np.isnan(U_stokes)]=0. U_stokes[I_stokes == 0.]=0. + Q_stokes[np.isnan(Q_stokes)]=0. + U_stokes[np.isnan(U_stokes)]=0. mask = (Q_stokes**2 + U_stokes**2) > I_stokes**2 if mask.any(): @@ -1114,6 +1113,16 @@ def compute_pol(I_stokes, Q_stokes, U_stokes, Stokes_cov, headers): s_P_P = np.sqrt(2.)/np.sqrt(N_obs)*100. s_PA_P = s_P_P/(2.*P/100.)*180./np.pi + # Nan handling : + fmax = np.finfo(np.float64).max + + P[np.isnan(P)] = 0. + s_P[np.isnan(s_P)] = fmax + s_PA[np.isnan(s_PA)] = fmax + debiased_P[np.isnan(debiased_P)] = 0. + s_P_P[np.isnan(s_P_P)] = fmax + s_PA_P[np.isnan(s_PA_P)] = fmax + return P, debiased_P, s_P, s_P_P, PA, s_PA, s_PA_P @@ -1186,7 +1195,7 @@ def rotate_data(data_array, error_array, headers, ang): return new_data_array, new_error_array, new_headers -def rotate_Stokes(I_stokes, Q_stokes, U_stokes, Stokes_cov, headers, ang): +def rotate_Stokes(I_stokes, Q_stokes, U_stokes, Stokes_cov, headers, ang, SNRi_cut=None): """ Use scipy.ndimage.rotate to rotate I_stokes to an angle, and a rotation matrix to rotate Q, U of a given angle in degrees and update header @@ -1209,6 +1218,10 @@ def rotate_Stokes(I_stokes, Q_stokes, U_stokes, Stokes_cov, headers, ang): ang : float Rotation angle (in degrees) that should be applied to the Stokes parameters + SNRi_cut : float, optional + Cut that should be applied to the signal-to-noise ratio on I. + Any SNR < SNRi_cut won't be displayed. If None, cut won't be applied. + Defaults to None. ---------- Returns: new_I_stokes : numpy.ndarray @@ -1226,6 +1239,18 @@ def rotate_Stokes(I_stokes, Q_stokes, U_stokes, Stokes_cov, headers, ang): Updated list of headers corresponding to the reduced images accounting for the new orientation angle. """ + #Apply cuts + if not(SNRi_cut is None): + SNRi = I_stokes/np.sqrt(Stokes_cov[0,0]) + mask = SNRi < SNRi_cut + eps = 1e-5 + for i in range(I_stokes.shape[0]): + for j in range(I_stokes.shape[1]): + if mask[i,j]: + I_stokes[i,j] = eps*np.sqrt(Stokes_cov[0,0][i,j]) + Q_stokes[i,j] = eps*np.sqrt(Stokes_cov[1,1][i,j]) + U_stokes[i,j] = eps*np.sqrt(Stokes_cov[2,2][i,j]) + #Rotate I_stokes, Q_stokes, U_stokes using rotation matrix alpha = ang*np.pi/180. new_I_stokes = 1.*I_stokes @@ -1275,6 +1300,16 @@ def rotate_Stokes(I_stokes, Q_stokes, U_stokes, Stokes_cov, headers, ang): new_headers.append(new_header) + # Nan handling : + fmax = np.finfo(np.float64).max + + new_I_stokes[np.isnan(new_I_stokes)] = 0. + new_Q_stokes[new_I_stokes == 0.] = 0. + new_U_stokes[new_I_stokes == 0.] = 0. + new_Q_stokes[np.isnan(new_Q_stokes)] = 0. + new_U_stokes[np.isnan(new_U_stokes)] = 0. + new_Stokes_cov[np.isnan(new_Stokes_cov)] = fmax + return new_I_stokes, new_Q_stokes, new_U_stokes, new_Stokes_cov, new_headers