Commit 4aabe354 authored by Holger Niemann's avatar Holger Niemann
Browse files

bug fixes for AEF41 in the bad Pixel correction, bug fixes because of changes...

bug fixes for AEF41 in the bad Pixel correction, bug fixes because of changes in json files downloaded from the Archive
parent c302115b
......@@ -169,7 +169,10 @@ def read_bad_pixels_from_file(port, shot_no=None, program=None):
port_name = 'AEF{0}'.format(port)
bad_pixel_file = 'badpixel_{0}.bpx'.format(portcamdict[OP][port_name][6:])
data = np.genfromtxt(IRCAMBadPixels_path+bad_pixel_file, dtype=int)
bad_pixle_list = list(zip(data[:,1], data[:,0]))
try:
bad_pixle_list = list(zip(data[:,1], data[:,0]))
except:
bad_pixle_list=[]
return bad_pixle_list
......@@ -281,7 +284,10 @@ def restore_bad_pixels(frames, bad_pixel, by_list=True, check_neighbours=True, p
blist = bad_pixel
bmask = np.ones([n_rows, n_cols],dtype=bool)
for pix in blist:
bmask[pix] = False
try:
bmask[pix] = False
except Exception as E:
Warning(E)
bmask = np.invert(bmask)
else:
if np.shape(bad_pixel)[0] == n_rows and np.shape(bad_pixel)[1] == n_cols:
......
......@@ -173,7 +173,7 @@ def download_LUT(port,time,exposure=0,emissivity=0,camera_filter=0,version=0, ve
LUTid=LUTpar[2][0]['structure'][query]
LUTs=read_restdb_old(larchivepath+"DATASTREAM/V"+str(version)+"/0/LUT/_signal.json?from="+str(time-10)+"&upto="+str(time+20))
if LUTs[0]:
LUTs=LUTs[2].swapaxes(1,2)[0]
LUTs=LUTs[2][0]#.swapaxes(1,2)[0] fixed, somehow the archive gives now data in a swaped way back
LUT=[LUTs[0],LUTs[LUTid],LUTs[LUTid+1]]
del LUTpar, LUTs
return True,LUT
......@@ -1415,7 +1415,7 @@ def get_calib_data(port,program,emissivity=0.8,Temp_V=2,version=0,back_emissivit
offset_error=0
exist,time,frames=download_raw_images_by_times(port,t1,int(t1+0.02*1e9),version)
if exist:
frames=[im.swapaxes(0,1) for im in frames]
# frames=[im.swapaxes(0,1) for im in frames]#somehow the archive gives it now already swapped back (09.07.2018)
bim=apply_NUC([frames[0]],gain,offset)
background=get_average_background_recangle(port,bim[0])
else:
......@@ -1435,7 +1435,7 @@ def get_calib_data(port,program,emissivity=0.8,Temp_V=2,version=0,back_emissivit
offset_error=0
exist,time,frames=download_raw_images_by_times(port,t1,int(t1+0.02*1e9),version)
if exist:
frames=[im.swapaxes(0,1) for im in frames]
# frames=[im.swapaxes(0,1) for im in frames]
bim=apply_NUC([frames[0]],gain,offset)
background=get_average_background_recangle(port,bim[0])
else:
......@@ -1488,7 +1488,10 @@ def find_badpixels(port, gain, offset, init_bp_list=None, niterations=3,
if verbose>0:
print("use {0} initial bad pixels from file".format(len(init_bp_list)))
for pix in init_bp_list:
badpixels[pix] = 1
try:
badpixels[pix] = 1
except Exception as E:
Warning(E)
gain = IR_tools.restore_bad_pixels(gain*FOV, init_bp_list)
last_number=0
......@@ -1612,10 +1615,12 @@ if __name__=='__main__':
# #status,time,images,valid=get_temp_from_raw_by_program_V1(51,"20171018.019",time_s=0,emi=0.8,divertorpart="all",version=1)
# status1,time1,images1,valid1=get_temp_from_raw_by_program_V1(41,"20171024.016",time_s=[0.75,0.99],emi=0.8,version=1)
## exist,time1,frames=download_raw_images_by_program_via_png(41,"20171024.016",time_s=[0.75,0.99],version=1,threads=1)
port=51
port=11
# prog="20171108.015"
prog="20171109.021"
# prog="20171025.030"
prog="20171012.035"
# prog="20171012.035"
prog="20171005.024"
status,time,images,valid=get_temp_from_raw_by_program(port,prog,time_s=[0,1],emi=0.82,T_version=2,version=0,threads=1,give_ERROR=False,use_firstframe_as_background=True)
# bla=get_exposure_by_program(port,prog)
......@@ -1629,11 +1634,15 @@ if __name__=='__main__':
CAD=np.asarray(szene['CAD'])
plt.figure()#
plt.imshow(CAD,cmap='gray')
plt.imshow(images[-1],vmin=300,vmax=750,cmap=fu.exJet_trans)
plt.imshow(images[-1],vmin=400,vmax=600,cmap=fu.exJet_trans)
cb=plt.colorbar()
cb.set_label("temperature K", rotation=270,labelpad=26,fontsize=26)
cb.ax.tick_params(labelsize=26)
plt.figure()# # plt.imshow(CAD,cmap='gray')
plt.imshow(images[-1],vmin=400,vmax=600,cmap=fu.exJet)
cb=plt.colorbar()
cb.set_label("temperature K", rotation=270,labelpad=26,fontsize=26)
cb.ax.tick_params(labelsize=26)
# tmax=[]
# port=20
# NUCblock=download_NUC_by_program(port,prog,bla[2][0])
......
Markdown is supported
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