diff --git a/IR_da_config_constants.py b/IR_da_config_constants.py index 3eb2145cac9e884ebf4c41e5fa47a4f53145c41f..a24c7b6fa5d12838b5e6f50daf78b0ecd45aebd6 100644 --- a/IR_da_config_constants.py +++ b/IR_da_config_constants.py @@ -18,7 +18,7 @@ parameter_file_path = ospath.join(ospath.dirname(__file__), 'data') try: # import sys - path=str(repr(__file__)).split("IR_config_constants")[0].split("'")[1]+"download_config" + path=str(repr(__file__)).split("IR_da_config_constants")[0].split("'")[1]+"download_config" cFile=open(path.replace('\\\\',"\\"))#+"upload_config") for line in cFile: if line[0:3]!="###": @@ -441,4 +441,4 @@ c2dict={ c3dict=c2dict.copy() exJet=cm.colors.LinearSegmentedColormap('mod_Jet', c2dict, 1024) c3dict['alpha']=((0.0,0.0,0.0),(0.33,0.99,0.99),(1.0,1.0,1.0)) -exJet_trans=cm.colors.LinearSegmentedColormap('mod_Jet_trans', c3dict, 1024) \ No newline at end of file +exJet_trans=cm.colors.LinearSegmentedColormap('mod_Jet_trans', c3dict, 1024) diff --git a/download_config b/download_config index 985e0d97a28beaaa8fe2e1bd8c3e6d057b34252a..0396f341825a6616d36ad264cf1d4032f9046c1a 100644 --- a/download_config +++ b/download_config @@ -1,8 +1,30 @@ ### specifications ### +port="AEF10" local=True +delayupload=True +starttime="20:00:00" +singleupload=False +use_today=True +upload_only_lattest=False +dates=[[2017,11,9]] +singlelist=[] ### settings ### +logpath="C:\\QIR\\Upload\\" +temppath="C:\\QIR\\Upload\\" +delete_Files=True +rawdata=True +raw1=True +raw2=True +raw_parlog=True +back_parlog=False +background=False +nuc_parlog=False +nuc=False +metastream=True +temperature=False retry=2 ### target database (ArchiveDB/Test/Sandbox) ### - archivedb='ArchiveDB' - +### versioning ### +reupload=False +reason="" diff --git a/downloadversionIRdata.py b/downloadversionIRdata.py index b96297196ee6fc0720bba5587bebf071a8c7dc72..b67e7ec57278aeb326eb2bd614c1aa2db89bc557 100644 --- a/downloadversionIRdata.py +++ b/downloadversionIRdata.py @@ -3228,6 +3228,7 @@ def get_temp_from_raw_by_program_V1(portnr, program, time_window=0, emi=0.8,dive intervalls.append(stoptime) temperatureimages=[] times=[] + error_images=[] for i in range(nrinterv): raw_dl=download_raw_images_by_times(portnr, intervalls[i], intervalls[i+1], version, intervalSize, testmode=testmode, verbose=verbose-1) print(datetime.datetime.now(), "get_temp_from_raw_by_program_V1: download of raw images part {0} of {1} finished".format(i+1, nrinterv)) @@ -3237,10 +3238,14 @@ def get_temp_from_raw_by_program_V1(portnr, program, time_window=0, emi=0.8,dive del raw_dl # images=images.swapaxes(1,2) images=[im.swapaxes(0,1) for im in images] - success, images=apply_calib_on_raw(images, background, LUT,refT, gain, offset, True, verbose=verbose-1) - temperatureimages=temperatureimages+images - times=times+time - del time, images + if give_ERROR: + success, images, images_err=apply_calib_on_raw(images, background, LUT, refT, gain, offset, gain_error, offset_error, True, give_ERROR, verbose=verbose-1) + else: + success, images=apply_calib_on_raw(images, background, LUT, refT, gain, offset, gain_error, offset_error, True, give_ERROR, verbose=verbose-1) + temperatureimages += images + times += time + error_images += images_err + del time, images, images_err else: # raise Exception("get_temp_from_raw_by_program_V1: cannot download the raw images") logging.warning("get_temp_from_raw_by_program_V1: cannot download the raw images") @@ -3561,7 +3566,7 @@ def get_temp_from_raw_by_program(portnr, program, time_window=0, emi=0.8, T_vers if toff > 10e6: print("get_temp_from_raw_by_program: time offset of {0}ns detected, correcting".format(toff)) time[:] = time[:]-toff - if give_ERROR: + if give_ERROR and not FLIR: return exist, time, frames, valid, error_images else: return exist, time, frames, valid @@ -4015,6 +4020,7 @@ def apply_calib_on_raw(images, background, LUT,refT=28.5, gain=0, offset=0, gain # del raw # images=images.swapaxes(1,2) if type(gain)!=int and type(offset)!=int: + # images has to be NUCed (e.g. IRcam Caleo image) if verbose > 0: print(datetime.datetime.now(), "apply_calib_on_raw: NUCing") # eliminate bad offset and gain points @@ -4027,6 +4033,10 @@ def apply_calib_on_raw(images, background, LUT,refT=28.5, gain=0, offset=0, gain images, error_images=apply_NUC(images, gain, offset, gain_error, offset_error, give_ERROR) else: images=apply_NUC(images, gain, offset) + else: + # images does not have to be NUCed (e.g. Infratech image), + # but error propagation requires an initial error image + error_images = np.zeros([len(images)], dtype='uint16') if verbose > 0: print(datetime.datetime.now(), "apply_calib_on_raw: background treatment") # if fullbackground: @@ -4060,7 +4070,7 @@ def apply_calib_on_raw(images, background, LUT,refT=28.5, gain=0, offset=0, gain return True, images except Exception as E: # raise Warning('apply_calib_on_raw: '+E) - logging.warning('apply_calib_on_raw: '+E) + logging.warning('apply_calib_on_raw: '+str(E)) return False, [0] @@ -6792,4 +6802,4 @@ if __name__=='__main__': # if exist: # print('data of port {0} in program {1}:\n t_preparation {2}ns\n t_start {3}ns\n t_end {4}ns'.format(port, program, t0, t1, t6)) - \ No newline at end of file + diff --git a/plot_IR_data.py b/plot_IR_data.py index 7f552b86bcd573df6f62f90a90dd2c3a74d3355e..240b61627635eef52fc330c36a9733879b17027b 100644 --- a/plot_IR_data.py +++ b/plot_IR_data.py @@ -11,27 +11,33 @@ loading IR data and printing plots import datetime import downloadversionIRdata as downIR import matplotlib.pyplot as plt +import numpy as np if __name__ == '__main__': - + + camera = 50 + program_str = "20171207.054" + time_window = [0, 1] + T_0 = 273.15 # [K] of 0°C + #%% loading data print(datetime.datetime.now(), "start") - status, time, images, valid = downIR.get_temp_from_raw_by_program(51, - "20171206.045", - time_window=[1, 1.1], + status, time, images, valid, error_images = downIR.get_temp_from_raw_by_program(camera, + program_str, + time_window=time_window, emi=0.8, T_version=2, version=0, threads=1, - give_ERROR=False, + give_ERROR=True, verbose=5) print('fertig') #%% plotting data plt.figure() - plt.imshow(images[0], cmap=plt.jet()) - plt.clim([280, 630]) + plt.imshow(images[50]-T_0, cmap=plt.jet()) + plt.clim([0, np.max(images[50])-T_0]) plt.tick_params(axis='both', # changes apply to the x-axis which='both', # both major and minor ticks are affected bottom='off', # ticks along the bottom edge are off @@ -41,6 +47,28 @@ if __name__ == '__main__': labelleft='off', labelbottom='off') # labels along the bottom edge are off c_ax = plt.colorbar() - c_ax.set_label('T [K]') - plt.savefig('20180726.028 - 2.2s - AEF50IR - in K.png', dpi=300, bbox_inches='tight') + c_ax.set_label('T [°C]') + plt.title('W7-X #{0} - camera AEF{1}'.format(program_str, camera)) + save_file_name = '{0} - {1:.1f}s - AEF{2}IR - image.png'.format(program_str, time_window[0]+0.5, camera) + plt.savefig(save_file_name, dpi=300, bbox_inches='tight') + plt.show() + + #%% plotting time trace + + position = [255,505] # in pixel + plt.figure() + images = np.array(images) + error_images = np.array(error_images) + timetrace = images[:,position[0], position[1]] + timetrace_error = error_images[:,position[0], position[1]] +# plt.plot((time-time[0])/1E9+time_window[0], timetrace-T_0) + plt.errorbar((time-time[0])/1E9+time_window[0], timetrace-T_0, yerr=timetrace_error, + linestyle='', marker='.', markersize=2, color='k', capsize=3, ecolor='r') + plt.xlabel('time [s]') + plt.ylabel('T [°C]') + plt.title('W7-X #{0} - camera AEF{1}'.format(program_str, camera)) + save_file_name = '{0} - pixel {1} - AEF{2}IR - timetrace.png'.format(program_str, position, camera) + plt.savefig(save_file_name, dpi=300, bbox_inches='tight') plt.show() + + print('max. T: {0:.1f}°C at t={1}ns'.format(np.max(timetrace-T_0), time[np.argmax(timetrace)])) diff --git a/setup.py b/setup.py index fdc3dc64b422de23f553172fe186f7f7e7fe3fbd..71dba4b8b7b20890af31b4277294851f1eb55084 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ setup( py_modules = [ 'downloadversionIRdata', 'IR_image_tools', - 'IR_config_constants', + 'IR_da_config_constants', 'IR_image_tools', 'plot_IR_data' , 'Create_HDF5_from_archive_data', diff --git a/upload_config b/upload_config deleted file mode 100644 index 79785e14d07fd5984cf14b132c3899d54bb4a478..0000000000000000000000000000000000000000 --- a/upload_config +++ /dev/null @@ -1,29 +0,0 @@ -### specifications ### -port="AEF10" -local=True -delayupload=True -starttime="20:00:00" -singleupload=False -use_today=True -upload_only_lattest=False -dates=[[2017,11,9]] -singlelist=[] -### settings ### -logpath="C:\\QIR\\Upload\\" -temppath="C:\\QIR\\Upload\\" -delete_Files=True -rawdata=True -raw1=True -raw2=True -raw_parlog=True -back_parlog=False -background=False -nuc_parlog=False -nuc=False -metastream=True -temperature=False -retry=2 -archivedb=True -### versioning ### -reupload=False -reason=""