Commit fc2064cf authored by Yu Gao's avatar Yu Gao
Browse files

Merge branch 'peter' into 'master'

Peter

See merge request !51
parents a806d59d a4b6ebb4
......@@ -18,15 +18,13 @@ parameter_file_path = ospath.join(ospath.dirname(__file__), 'data')
try:
# import sys
path=str(repr(__file__)).split("IR_config_constants")[0].split("'")[1]+"upload_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]!="###":
if line.split("=")[0]=='archivedb':
if eval(line.split("=")[1].split("\n")[0]):
archivepath="http://archive-webapi.ipp-hgw.mpg.de/ArchiveDB/raw/"
else:
archivepath="http://archive-webapi.ipp-hgw.mpg.de/Test/raw/"
database = eval(line.split("=")[1].strip())
archivepath = "http://archive-webapi.ipp-hgw.mpg.de/{0}/raw/".format(database)
cFile.close()
except Exception as E:
archivepath="http://archive-webapi.ipp-hgw.mpg.de/Test/raw/"
......
......@@ -15,7 +15,7 @@ Tools for:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from IR_config_constants import portcamdict, IRCAMBadPixels_path, parameter_file_path
from IR_da_config_constants import portcamdict, IRCAMBadPixels_path, parameter_file_path
import os
import datetime
#import h5py
......
......@@ -23,7 +23,8 @@ nuc=False
metastream=True
temperature=False
retry=2
archivedb=True
### target database (ArchiveDB/Test/Sandbox) ###
archivedb='ArchiveDB'
### versioning ###
reupload=False
reason=""
......@@ -16,7 +16,7 @@ version = "V3.4.3"
import numpy as np
import IR_image_tools as IR_tools
from IR_config_constants import archivepath, testarchivepath, portcamdict, camlimdict, \
from IR_da_config_constants import archivepath, testarchivepath, portcamdict, camlimdict, \
valid_FOV_circle, valid_background_rectangle, \
TC_port, TC_channel, IRCamColdframes_fittingpath, \
exJet, portpathdict, project, project_ana, \
......@@ -3223,6 +3223,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))
......@@ -3232,10 +3233,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")
......@@ -3555,7 +3560,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
......@@ -4009,6 +4014,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
......@@ -4021,6 +4027,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:
......@@ -4054,7 +4064,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]
......
......@@ -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)]))
......@@ -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',
......
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