make intermediate display more readable

This commit is contained in:
Thibault Barnouin
2022-04-25 16:22:18 +02:00
parent 3770a78940
commit eaec0729c3
7 changed files with 20 additions and 16 deletions

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 200 KiB

After

Width:  |  Height:  |  Size: 223 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 43 KiB

View File

@@ -98,10 +98,10 @@ def main():
iterations = 5
algo="richardson"
# Initial crop
display_crop = True
display_crop = False
# Error estimation
error_sub_shape = (10,10)
display_error = True
display_error = False
# Data binning
rebin = True
if rebin:
@@ -110,7 +110,7 @@ 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, weighted_gaussian_after, gaussian, weighted_gaussian or combine
smoothing_FWHM = 0.20 #If None, no smoothing is done
@@ -120,7 +120,7 @@ def main():
rotate_data = False #rotation to North convention can give erroneous results
# Final crop
crop = False #Crop to desired ROI
final_display = True
final_display = False
# Polarization map output
figname = 'NGC1068_FOC' #target/intrument name
figtype = '_combine_FWHM020' #additionnal informations

View File

@@ -81,6 +81,7 @@ def plot_obs(data_array, headers, shape=None, vmin=0., vmax=6., rectangle=None,
be saved. Not used if savename is None.
Defaults to current folder.
"""
plt.rcParams.update({'font.size': 10})
if shape is None:
shape = np.array([np.ceil(np.sqrt(data_array.shape[0])).astype(int),]*2)
fig, ax = plt.subplots(shape[0], shape[1], figsize=(10,10), dpi=200,
@@ -147,6 +148,7 @@ def plot_Stokes(Stokes, savename=None, plots_folder=""):
wcs = WCS(Stokes[0]).deepcopy()
# Plot figure
plt.rcParams.update({'font.size': 10})
fig = plt.figure(figsize=(30,10))
ax = fig.add_subplot(131, projection=wcs)

View File

@@ -261,6 +261,7 @@ def crop_array(data_array, headers, error_array=None, data_mask=None, step=5, nu
new_shape = np.array([v_array[1]-v_array[0],v_array[3]-v_array[2]])
rectangle = [v_array[2], v_array[0], new_shape[1], new_shape[0], 0., 'b']
if display:
plt.rcParams.update({'font.size': 20})
fig, ax = plt.subplots(figsize=(10,10))
data = data_array[0]
instr = headers[0]['instrume']
@@ -276,13 +277,13 @@ def crop_array(data_array, headers, error_array=None, data_mask=None, step=5, nu
color='grey', alpha=0.3)
ax.plot([0,data.shape[1]-1], [data.shape[1]/2, data.shape[1]/2], '--', lw=1,
color='grey', alpha=0.3)
ax.annotate(instr+":"+rootname, color='white', fontsize=5,
ax.annotate(instr+":"+rootname, color='white', fontsize=10,
xy=(0.02, 0.95), xycoords='axes fraction')
ax.annotate(filt, color='white', fontsize=10, xy=(0.02, 0.02),
ax.annotate(filt, color='white', fontsize=14, xy=(0.02, 0.02),
xycoords='axes fraction')
ax.annotate(exptime, color='white', fontsize=5, xy=(0.80, 0.02),
ax.annotate(str(exptime)+" s", color='white', fontsize=10, xy=(0.80, 0.02),
xycoords='axes fraction')
ax.set(title="Location of cropped image.",
ax.set(#title="Location of cropped image.",
xlabel='pixel offset',
ylabel='pixel offset')
@@ -430,7 +431,7 @@ def get_error(data_array, headers, error_array=None, data_mask=None, sub_shape=N
if error_array is None:
error_array = np.zeros(data_array.shape)
if not data_mask is None:
data, error, mask = data_array, error_array, data_mask#_ = crop_array(data_array, headers, error_array, data_mask, step=5, null_val=0., inside=False)
data, error, mask = data_array, error_array, data_mask
else:
data, error, _ = crop_array(data_array, headers, error_array, step=5, null_val=0., inside=False)
mask = np.ones(data[0].shape, dtype=bool)
@@ -487,6 +488,7 @@ def get_error(data_array, headers, error_array=None, data_mask=None, sub_shape=N
print(data_array[i])
if display:
plt.rcParams.update({'font.size': 20})
convert_flux = headers[0]['photflam']
date_time = np.array([headers[i]['date-obs']+';'+headers[i]['time-obs']
for i in range(len(headers))])
@@ -500,7 +502,7 @@ def get_error(data_array, headers, error_array=None, data_mask=None, sub_shape=N
for f in np.unique(filt):
mask = [fil==f for fil in filt]
ax.scatter(date_time[mask], background[mask]*convert_flux,
color=dict_filt[f],label="Filter : {0:s}".format(f))
color=dict_filt[f],label="{0:s}".format(f))
ax.errorbar(date_time, background*convert_flux,
yerr=error_array[:,0,0]*convert_flux, fmt='+k',
markersize=0, ecolor=c_filt)
@@ -511,7 +513,7 @@ def get_error(data_array, headers, error_array=None, data_mask=None, sub_shape=N
ax.xaxis.set_major_formatter(formatter)
ax.set_xlabel("Observation date and time")
ax.set_ylabel(r"Flux [$ergs \cdot cm^{-2} \cdot s^{-1} \cdot \AA^{-1}$]")
ax.set_title("Background flux and error computed for each image")
#ax.set_title("Background flux and error computed for each image")
plt.legend()
fig2, ax2 = plt.subplots(figsize=(10,10))
@@ -524,13 +526,13 @@ def get_error(data_array, headers, error_array=None, data_mask=None, sub_shape=N
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,
ax2.annotate(instr+":"+rootname, color='white', fontsize=10,
xy=(0.02, 0.95), xycoords='axes fraction')
ax2.annotate(filt, color='white', fontsize=10, xy=(0.02, 0.02),
ax2.annotate(filt, color='white', fontsize=14, xy=(0.02, 0.02),
xycoords='axes fraction')
ax2.annotate(exptime, color='white', fontsize=5, xy=(0.80, 0.02),
ax2.annotate(str(exptime)+" s", color='white', fontsize=10, xy=(0.80, 0.02),
xycoords='axes fraction')
ax2.set(title="Location of background computation.",
ax2.set(#title="Location of background computation.",
xlabel='pixel offset',
ylabel='pixel offset')
@@ -911,7 +913,7 @@ def smooth_data(data_array, error_array, data_mask, headers, FWHM=1.,
weights = np.ones(error_array[i].shape)
if smoothing.lower()[:6] in ['weight']:
weights = 1./error_array[i]**2
weights /= weights.sum()
#weights /= weights.max()
kernel = gaussian2d(x, y, stdev)
kernel /= kernel.sum()
smoothed[i] = convolve2d(image*weights/image.sum(),kernel,'same')*image.sum()