Commit 19006b99 authored by Holger Niemann's avatar Holger Niemann
Browse files

update to V2.9.6: clear issue #2, use portnr instead of port in same functions

parent c0ee646c
......@@ -3,7 +3,7 @@
Created on Wed Oct 25 15:51:46 2017
updated on Tue Aug 21 10:20:00 2018
Version: 2.9.5
Version: 2.9.6
(Numbering: #of big changes(OP1.2a download V1, OP1.2b download V2, heatflux V3) . #of updates to add functionalities . #number of updates for bug fixes )
@author: holn
"""
......@@ -1578,8 +1578,8 @@ def get_temp_from_raw_by_program(portnr,program,time_s=0,emi=0.8,T_version=2,ver
return False,[0],[0],False
else:
if version==0:
version=get_latest_version(portpathdict[OP]["AEF"+str(port)]+"raw_DATASTREAM")
larchivepath=archivepath+"W7X/"+portpathdict[OP]["AEF"+str(port)]+"raw_DATASTREAM/V"+str(version)+"/0/raw"
version=get_latest_version(portpathdict[OP]["AEF"+str(portnr)]+"raw_DATASTREAM")
larchivepath=archivepath+"W7X/"+portpathdict[OP]["AEF"+str(portnr)]+"raw_DATASTREAM/V"+str(version)+"/0/raw"
if verbose>0:
print(datetime.datetime.now(),"raw download start")
if fastDL:
......@@ -1600,7 +1600,7 @@ def get_temp_from_raw_by_program(portnr,program,time_s=0,emi=0.8,T_version=2,ver
if use_firstframe_as_background:
bim=apply_NUC([frames[0]],gain,offset)
background=get_average_background_recangle(portnr,bim[0])
print(port)
if give_ERROR:
success,frames,error_images=apply_calib_on_raw(frames,background,LUT,refT,gain,offset,gain_error,offset_error,False,give_ERROR,verbose=verbose-1)
else:
......@@ -1648,91 +1648,109 @@ def get_temp_from_raw_by_program_fullthreads(portnr,program,time_s=0,emi=0.8,T_v
if threads==1 or not fastDL:
return get_temp_from_raw_by_program(portnr,program,time_s,emi,T_version,version,threads,give_ERROR)
else:
exist,background,LUT,refT,gain,offset,badpixels,t_exp,cfilter,gain_error,offset_error=get_calib_data(portnr,program,emi,T_version,version)
FOV=get_FOV_mask(portnr)
prog=get_program_from_PID(program)
if prog[0]:
starttime=prog[1]['trigger']['1'][0]
stoptime=prog[1]['trigger']['6'][0]
success=True
OP=get_OP_by_time(starttime)
if version==0:
version=get_latest_version(portpathdict[OP]["AEF"+str(port)]+"raw_DATASTREAM")
larchivepath=archivepath+"W7X/"+portpathdict[OP]["AEF"+str(port)]+"raw_DATASTREAM/V"+str(version)+"/0/raw"
if type(time_s)==list:
tstart=time_s[0]
tstop=time_s[1]
if tstop<tstart:
raise Exception("endtime before starttime")
stdate=datetime.datetime.utcfromtimestamp((starttime-100)/1e9+tstart)
stdate=stdate.isoformat()
enddate=datetime.datetime.utcfromtimestamp((starttime)/1e9+tstop)
enddate=enddate.isoformat()
else:
stdate=datetime.datetime.utcfromtimestamp((starttime-100)/1e9)
stdate=stdate.isoformat()
if time_s==0:
enddate=datetime.datetime.utcfromtimestamp(stoptime/1e9)
if type(portnr) is str:
try:
OP=IR_tools.get_OP_by_time(program_str=program)
camera=portcamdict[OP][portnr]
if camera.split("_")[0]=='FLIR':
FLIR=True
else:
FLIR=False
portnr=int(portnr.split("AEF")[1])
goon=True
except Exception as E:
raise Exception("unknown Port!"+E)
elif type(portnr) is int:
FLIR=False
goon=True
else:
goon=False
if goon and not FLIR:
exist,background,LUT,refT,gain,offset,badpixels,t_exp,cfilter,gain_error,offset_error=get_calib_data(portnr,program,emi,T_version,version)
FOV=get_FOV_mask(portnr)
prog=get_program_from_PID(program)
if prog[0]:
starttime=prog[1]['trigger']['1'][0]
stoptime=prog[1]['trigger']['6'][0]
success=True
OP=get_OP_by_time(starttime)
if version==0:
version=get_latest_version(portpathdict[OP]["AEF"+str(portnr)]+"raw_DATASTREAM")
larchivepath=archivepath+"W7X/"+portpathdict[OP]["AEF"+str(portnr)]+"raw_DATASTREAM/V"+str(version)+"/0/raw"
if type(time_s)==list:
tstart=time_s[0]
tstop=time_s[1]
if tstop<tstart:
raise Exception("endtime before starttime")
stdate=datetime.datetime.utcfromtimestamp((starttime-100)/1e9+tstart)
stdate=stdate.isoformat()
enddate=datetime.datetime.utcfromtimestamp((starttime)/1e9+tstop)
enddate=enddate.isoformat()
else:
enddate=datetime.datetime.utcfromtimestamp((starttime)/1e9+time_s)
enddate=enddate.isoformat()
times=AKF_2.get_time_intervals(larchivepath,stdate.replace("T"," "),enddate.replace("T"," "))#
lnt=len(times)
tim=[]
for i in range(lnt):
tim.append(times[lnt-1-i][0])
intervalls=[]
intervalSize=int(lnt/threads)
for i in range(threads):
intervalls.append(int(i*intervalSize))
intervalls.append(lnt)
jobs = []
resultdict = []
for i in range(threads):
print("Start Thread ",i+1)
# p = multiprocessing.Process(target=convert_raw_to_temp_thread, args=(larchivepath,tim[intervalls[i]:intervalls[i+1]],out_q,i,version,background,LUT,refT,gain,offset,gain_error,offset_error,give_ERROR,FOV,badpixels,))
p=convert_raw_to_temp_thread(larchivepath,tim[intervalls[i]:intervalls[i+1]],resultdict,i,version,background,LUT,refT,gain,offset,gain_error,offset_error,give_ERROR,FOV,badpixels)
jobs.append(p)
p.start()
for p in jobs:
p.join()
print("all threads are done")
order=[]
for ele in resultdict:
order.append(ele[0])
if len(np.where(np.asarray(ele[1])==False)[0])>0:
success=False
times=[]#np.array(resultdict[order.index(0)][2])
images=[]#np.array(resultdict[order.index(0)][3])
for i in range(threads):
images=images+resultdict[order.index(i)][3]
times=times+resultdict[order.index(i)][2]
del resultdict
if check_range:
print(datetime.datetime.now(),"checking temperaturerange")
valid=True
for i in range(len(images)):
try:
check_temperature_range(times[0],np.max(images[i])-273.15,np.min(images[i][np.nonzero(images[i])])-273.15,portnr,t_exp,cfilter)
except Exception as E:
print(E)
valid=False
i=len(images)
stdate=datetime.datetime.utcfromtimestamp((starttime-100)/1e9)
stdate=stdate.isoformat()
if time_s==0:
enddate=datetime.datetime.utcfromtimestamp(stoptime/1e9)
enddate=enddate.isoformat()
else:
enddate=datetime.datetime.utcfromtimestamp((starttime)/1e9+time_s)
enddate=enddate.isoformat()
times=AKF_2.get_time_intervals(larchivepath,stdate.replace("T"," "),enddate.replace("T"," "))#
lnt=len(times)
tim=[]
for i in range(lnt):
tim.append(times[lnt-1-i][0])
intervalls=[]
intervalSize=int(lnt/threads)
for i in range(threads):
intervalls.append(int(i*intervalSize))
intervalls.append(lnt)
jobs = []
resultdict = []
for i in range(threads):
print("Start Thread ",i+1)
# p = multiprocessing.Process(target=convert_raw_to_temp_thread, args=(larchivepath,tim[intervalls[i]:intervalls[i+1]],out_q,i,version,background,LUT,refT,gain,offset,gain_error,offset_error,give_ERROR,FOV,badpixels,))
p=convert_raw_to_temp_thread(larchivepath,tim[intervalls[i]:intervalls[i+1]],resultdict,i,version,background,LUT,refT,gain,offset,gain_error,offset_error,give_ERROR,FOV,badpixels)
jobs.append(p)
p.start()
for p in jobs:
p.join()
print("all threads are done")
order=[]
for ele in resultdict:
order.append(ele[0])
if len(np.where(np.asarray(ele[1])==False)[0])>0:
success=False
times=[]#np.array(resultdict[order.index(0)][2])
images=[]#np.array(resultdict[order.index(0)][3])
for i in range(threads):
images=images+resultdict[order.index(i)][3]
times=times+resultdict[order.index(i)][2]
del resultdict
if check_range:
print(datetime.datetime.now(),"checking temperaturerange")
valid=True
for i in range(len(images)):
try:
check_temperature_range(times[0],np.max(images[i])-273.15,np.min(images[i][np.nonzero(images[i])])-273.15,portnr,t_exp,cfilter)
except Exception as E:
print(E)
valid=False
i=len(images)
else:
valid=True
else:
valid=True
else:
success=False
times=[0]
images=[0]
valid=False
error_images=[0]
if give_ERROR:
return success,np.array(times),images,valid,error_images
else:
return success,np.array(times),images,valid
success=False
times=[0]
images=[0]
valid=False
error_images=[0]
if give_ERROR:
return success,np.array(times),images,valid,error_images
else:
return success,np.array(times),images,valid
def get_nuced_raw_by_program(portnr,program,time_s=0,version=0,threads=1,give_ERROR=False):
background,LUT,refT,gain,offset,badpixels,t_exp,cfilter,gain_error,offset_error=get_calib_data(portnr,program,emi=1,T_version=2,version=version)
......@@ -1778,8 +1796,8 @@ def get_nuced_raw_by_program_fullthreads(portnr,program,time_s=0,emi=0.8,T_versi
success=True
OP=get_OP_by_time(t1)
if version==0:
version=get_latest_version(portpathdict[OP]["AEF"+str(port)]+"raw_DATASTREAM")
larchivepath=archivepath+"W7X/"+portpathdict[OP]["AEF"+str(port)]+"raw_DATASTREAM/V"+str(version)+"/0/raw"
version=get_latest_version(portpathdict[OP]["AEF"+str(portnr)]+"raw_DATASTREAM")
larchivepath=archivepath+"W7X/"+portpathdict[OP]["AEF"+str(portnr)]+"raw_DATASTREAM/V"+str(version)+"/0/raw"
if type(time_s)==list:
tstart=time_s[0]
tstop=time_s[1]
......@@ -2361,7 +2379,7 @@ end of the copied functions
if __name__=='__main__':
print("local function calling")
port=50#"AEF51"
port=51#"AEF51"
prog="20180925.017"
status,time,images,valid=get_temp_from_raw_by_program(port,prog,time_s=[0,0.15],emi=0.82,T_version=2,version=0,threads=4,give_ERROR=False,use_firstframe_as_background=False,verbose=5)
if status:
......
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