darkb1(10)-0004-60.fit : "darkb1" + T +"-" + i +"-" + exp + ".fit" avec: T = temperature , notée (T) pour les temperatures négatives et i = n° pose unitaire au format ###0
import glob
from astropy.io import fits as fits
from matplotlib import pyplot as plt
from matplotlib.colors import LogNorm
import numpy as np
import pandas as pd
import scipy
import scipy.stats
path = r'D:\Temp\\'
display_infos = 0
Optimisation nombre de bins
# choix image
temp = "0"
exptime = "0"
no = "0001"
#list_images = glob.glob(path + "dark_b1_" + temp + "-" + no+ "-" + exptime + ".fit")
filename = path + "dark_b1_" + temp + "-" + no+ "-" + exptime + ".fit"
hdu=fits.open(filename)
hdr=hdu[0].header
image=hdu[0].data
if display_infos:
print(repr(hdr))
x_size = hdr["NAXIS1"]
y_size = hdr["NAXIS2"]
df = pd.DataFrame(image)
fig = plt.figure()
plt.imshow(image, cmap='gray',norm=LogNorm())
plt.grid(False)
plt.text(20,50,"bias T = 0°C",color = "white", fontsize = 12)
print('Statistics values')
print('Min:', np.min(image))
print('Max:', np.max(image))
print('Mean:', np.round(np.mean(image),0))
print('Stdev:', np.round(np.std(image),1))
NameFig = "F:\_120aa.eps"
plt.savefig(NameFig, format='eps',bbox_inches='tight', dpi = 75)
NameFig = "F:\_120aa.png"
plt.savefig(NameFig, format='png',bbox_inches='tight', dpi = 75)
Statistics values Min: 195 Max: 583 Mean: 344.0 Stdev: 29.3
x = int(x_size/2)
y = int(y_size/2)
w = 30
df = pd.DataFrame(image)
df_slice_horizontal=df.iloc[:][y-w//2:y+w//2]
df_slice_vertical=df_slice_horizontal=df.iloc[x-w//2:x+w//2][:]
fig,(ax1,ax2) = plt.subplots(2,figsize=(3,2))
fig.subplots_adjust(hspace=0.35)
ax1.plot(df_slice_horizontal.median(),"o",markersize=2)
ax2.plot(df_slice_horizontal.std(),"ro",markersize=2)
ax1.set_title("Bias - Coupe horizontale");
fig = plt.figure()
plt.imshow(image, cmap='gray',norm=LogNorm())
plt.grid(False)
plt.text(20,50,"bias T = 0°C",color = "white", fontsize = 12)
from scipy.interpolate import CubicSpline
x = np.arange(x_size)
y = df_slice_horizontal.median()
f = CubicSpline(x, y)
plt.plot(x,(f(x)-350)*10+350,"y-",markersize=2)
[<matplotlib.lines.Line2D at 0x22a37351250>]
x = int(x_size/2)
y = int(y_size/2)
x = 100
y = 100
ws = 10
df = pd.DataFrame(image)
df_cut_square=df.iloc[10:20,10:20]
df_cut_square=df.iloc[x:x+ws,y:y+ws]
#display(df_cut_square)
fig = plt.figure()
ax = plt.axes()
plt.imshow(df_cut_square, cmap='gray',norm=LogNorm())
plt.grid(False)
plt.tick_params(left = False,bottom=False)
ax.set_xticks(np.arange(0,10))
ax.set_yticks(np.arange(0,10))
for i in np.arange(10):
for j in np.arange(10):
s= str(df_cut_square.iloc[i,j])
plt.text(i-0.25,j,s,color = "w",fontsize = 8,fontweight="bold")
plt.title = ""
NameFig = "F:\_120a.eps"
plt.savefig(NameFig, format='eps',bbox_inches='tight', dpi = 75)
NameFig = "F:\_120a.png"
plt.savefig(NameFig, format='png',bbox_inches='tight', dpi = 75)