Commit eb8f2e0f authored by Holger Niemann's avatar Holger Niemann
Browse files

fixes of runtime and futurewarining (3.5, errors in 3.6) in the download code

parent a0d613e2
......@@ -413,13 +413,13 @@ def restore_bad_pixels(frames, bad_pixel, by_list=True, check_neighbours=True, p
def generate_new_hot_image(cold,reference_cold,reference_hot):
if cold==None or reference_cold==None or reference_hot==None:
if cold is None or reference_cold is None or reference_hot is None:
raise Exception("Cannot Calculate new Hot image, if images are missing!")
else:
return reference_hot+(cold-reference_cold)
def calculate_gain_offset_image_pix(cold_image,hot_image=None,reference_cold=None,reference_hot=None,bose=1):
if hot_image==None:
if hot_image is None:
hot_image=generate_new_hot_image(cold_image,reference_cold,reference_hot)
if bose>0:
print("calculate gain and offset")
......@@ -432,7 +432,7 @@ def calculate_gain_offset_image_pix(cold_image,hot_image=None,reference_cold=Non
return Gain_rel,Offset_rel
def calculate_gain_offset_image(cold_image,hot_image=None,reference_cold=None,reference_hot=None,bose=1):
if hot_image==None:
if hot_image is None:
hot_image=generate_new_hot_image(cold_image,reference_cold,reference_hot)
if bose>0:
print("calculate gain and offset")
......@@ -443,7 +443,11 @@ def calculate_gain_offset_image(cold_image,hot_image=None,reference_cold=None,re
# print(cold_image[( np.int( np.shape(hot_image)[0]/2) )-2: (np.int( np.shape(hot_image)[0]/2))+3,np.int((np.shape(hot_image)[1]/2))-2:np.int((np.shape(hot_image)[1]/2))+3 ])
Sh_ref = np.mean( hot_image[( np.int( np.shape(hot_image)[0]/2) )-2: (np.int( np.shape(hot_image)[0]/2))+3,np.int((np.shape(hot_image)[1]/2))-2:np.int((np.shape(hot_image)[1]/2))+3 ])
Sc_ref = np.mean(cold_image[( np.int( np.shape(cold_image)[0]/2) )-2: (np.int( np.shape(cold_image)[0]/2))+3,np.int((np.shape(cold_image)[1]/2))-2:np.int((np.shape(cold_image)[1]/2))+3 ])
Gain_rel = ( Sh_ref - Sc_ref ) / ( hot_image - cold_image)
difference_image=hot_image - cold_image
indexlist=np.where(difference_image==0)
difference_image[indexlist]=0.001
Gain_rel = ( Sh_ref - Sc_ref ) / ( difference_image)
Gain_rel[indexlist]=0
Off_h_rel = Sh_ref - hot_image*Gain_rel
Off_c_rel = Sc_ref - cold_image*Gain_rel
Offset_rel = ( Off_h_rel + Off_c_rel ) /2
......
......@@ -504,7 +504,7 @@ def download_background_by_times(port,starttime,stoptime,exposure,camera_filter=
else:
return False,0,0
def get_NUCed_background_by_times(port,t0,t1,t_exp,cfilter,gain,offset,version=0,plot_it=True):
def get_NUCed_background_by_times(port,t0,t1,t_exp,cfilter,gain,offset,version=0,plot_it=False):
"OP1.2b function"
exist,btime,backgroundframes=download_calibration_raw_files_by_time(port,t_exp,t0,t1,frametype=1,version=version)
camera=portcamdict["OP1.2b"]["AEF"+str(port)]
......
......@@ -15,7 +15,7 @@ if __name__=='__main__':
#%% loading data
status,time,images,valid=downIR.get_temp_from_raw_by_program(20,"20171207.006",time_s=3.5,emi=0.8,T_version=2,version=1,threads=8,give_ERROR=False)
status,time,images,valid=downIR.get_temp_from_raw_by_program(20,"20180726.015",time_s=2.5,emi=0.8,T_version=2,version=1,threads=4,give_ERROR=False)
print('fertig')
#%% plotting data
......@@ -33,5 +33,5 @@ if __name__=='__main__':
labelbottom='off') # labels along the bottom edge are off
c_ax = plt.colorbar()
c_ax.set_label('T [K]')
plt.savefig('20171207.006 - 2.2s - AEF20IR - in K.png', dpi=300, bbox_inches='tight')
plt.savefig('20180726.015 - 2.2s - AEF20IR - in K.png', dpi=300, bbox_inches='tight')
plt.show()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment