Commit 619f1772 authored by Holger Niemann's avatar Holger Niemann
Browse files

Merge branch 'Holgers' into 'master'

V3.0.2: changes in dtype in the upload, extract profile accepts now also ranges…

See merge request !20
parents 3b8b82f1 43a0dbe8
from . import IR_image_tools
from . import downloadversionIRdata
from . import IR_config_constants
\ No newline at end of file
......@@ -4,7 +4,7 @@ Created on Wed Oct 25 15:51:46 2017
updated on Tue Aug 21 10:20:00 2018
last update on Fr Nov 23 15:37:00 2018
Version: 3.0.0
Version: 3.0.2
(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
"""
......@@ -2290,7 +2290,7 @@ def estimate_offset(port,program,plot_it=False):
else:
return -1
def download_heatflux_by_program(port,program,timewindow=0,threads=1,testmode=True,version=0,verbose=0,givealpha=False):
def download_heatflux_by_program(port,program,timewindow=0,threads=1,testmode=True,version=0,verbose=0,givealpha=False,request=True):
"""
port: string or integer
program: string
......@@ -2310,25 +2310,25 @@ def download_heatflux_by_program(port,program,timewindow=0,threads=1,testmode=Tr
tend=t6
elif type(timewindow)==list or type(timewindow)==np.ndarray:
if len(timewindow)>1:
tstart=t1+timewindow[0]*1e9
tend=t1+timewindow[1]*1e9
tstart=int(t1+timewindow[0]*1e9)
tend=int(t1+timewindow[1]*1e9)
else:
tstart=t1
tend=t1+timewindow[0]*1e9
tstart=int(t1)
tend=int(t1+timewindow[0]*1e9)
elif type(timewindow)==int or type(timewindow)==float:
tstart=t1
tend=t1+timewindow*1e9
tstart=int(t1)
tend=int(t1+timewindow*1e9)
else:
raise Exception("given timewindow type is not supported")
if givealpha:
tstart=tstart-1.1e9
return download_heatflux_by_times(port=port,tstart=tstart,tend=tend,timewindow=0,testmode=testmode,version=version,verbose=verbose-1)
return download_heatflux_by_times(port=port,tstart=tstart,tend=tend,timewindow=0,testmode=testmode,version=version,verbose=verbose-1,request=request)
else:
if verbose>0:
print("program not found")
return False,0,-1
def download_heatflux_by_times(port,tstart,tend,timewindow=0,threads=1,testmode=True,version=0,verbose=1):
def download_heatflux_by_times(port,tstart,tend,timewindow=0,threads=1,testmode=True,version=0,verbose=1,request=True):
"""
port: string or integer
tstart: int64 timestamp in ns from which point the download should start
......@@ -2384,16 +2384,17 @@ def download_heatflux_by_times(port,tstart,tend,timewindow=0,threads=1,testmode=
if exist==False:
now=datetime.datetime.now()
if verbose>0:
print(now,"heat flux data is not available, creating request")
f=open(heatflux_requestlist_path+str(now.year)+str(now.month)+"_q_requests.txt",'a')
try:
programid=AKF_2.get_program_id(tstart)
except Exception as E:
if verbose>0:
print(E)
programid=str(tstart)
f.write(programid+"\tAEF"+str(port)+"\n")
f.close()
print(now,"heat flux data is not available, creating request")
if request:
f=open(heatflux_requestlist_path+str(now.year)+str(now.month)+"_q_requests.txt",'a')
try:
programid=AKF_2.get_program_id(tstart)
except Exception as E:
if verbose>0:
print(E)
programid=str(tstart)
f.write(programid+"\tAEF"+str(port)+"\n")
f.close()
return exist,time,frames
def download_heatflux_mapping_reference(timepoint=None,version=0,testmode=True,verbose=0):
......@@ -2572,13 +2573,37 @@ def get_heatflux_profile(port,profile,finger=None,timepoint=1,program=None,tstar
print("heatflux data could not be downloaded")
return False,0,0,0
def extract_heatflux_profile_from_DL(time,images,profile,finger=None,timepoint=1,inputchecked=False,verbose=0):
def extract_heatflux_profile_from_DL(time,images,profile,finger=None,timewindow=1,inputchecked=False,verbose=0):
"""
return exist,time,s in m, heat flux in W/m2
time_point default (None) returns entire shot.
"""
try:
Tid=IR_tools.find_nearest(time,timepoint)
except Exception as E:
goon=True
if timewindow==None:
Tid_start=0
Tid_end=len(time)
elif type(timewindow)==int or type(timewindow)==float:
try:
Tid_start=IR_tools.find_nearest(time,timewindow)
Tid_end=Tid_start+1
except Exception as E:
goon=False
elif type(timewindow)==list or type(timewindow)==np.ndarray and len(timewindow)>0:
try:
Tid_start=IR_tools.find_nearest(time,timewindow[0])
except Exception as E:
goon=False
if len(timewindow)>1:
try:
Tid_end=IR_tools.find_nearest(time,timewindow[1])
except Exception as E:
goon=False
else:
Tid_end=Tid_start+1
else:
goon=False
E="unknown Case"
if not goon:
if verbose>0:
print(E)
return False,0,0,0
......@@ -2597,8 +2622,8 @@ def extract_heatflux_profile_from_DL(time,images,profile,finger=None,timepoint=1
Fingermap=np.asarray(mapping['Finger_ID'][0],dtype=np.int)
locs=np.where(Fingermap==fingerID)
S=mapping['s'][locs]
q=images[Tid][locs]
return True,time[Tid],S,q
q=images[Tid_start:Tid_end][locs]
return True,time[Tid_start:Tid_end],S,q
else:
if verbose>0:
print("mapping was not found, cannot extract the profile")
......@@ -2727,14 +2752,17 @@ if __name__=='__main__':
# cb.set_label("temperature in K",rotation=270,labelpad=20,fontsize=20)
# cb.ax.tick_params(labelsize=20)
#%% heatflux test
# port=20
# prog="20171109.009"
# status,time,images=download_heatflux_by_program(port,prog,timewindow=4,threads=4,version=1,verbose=5,givealpha=False)
# if status:
port=20
prog="20171108.017"
status,time,images=download_heatflux_by_program(port,prog,timewindow=0.1,threads=1,version=1,verbose=0,givealpha=False,request=False)
if status:
print(prog,port,"OK")
else:
print(prog,port,"missing")
# plt.figure(),plt.imshow(images[0],vmin=0)
# plt.figure(),plt.imshow(images[50],vmin=0)
status,mapping=download_heatflux_mapping_reference(verbose=4)
test=get_heatflux_profile(20,1605,timepoint=1,program="20171109.008",verbose=4)
# status,mapping=download_heatflux_mapping_reference(verbose=4)
# test=get_heatflux_profile(20,1605,timepoint=1,program="20171109.008",verbose=4)
#%% HDF5 writing test
# bla=get_temp_from_raw_by_program_fullthreads(51,prog,time_s=[0,4],threads=4)
# bla2=get_nuced_raw_by_program_fullthreads(51,prog,time_s=[0,4],threads=4)
......
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 21 09:32:29 2018
V3.0.1
V3.0.2
@author: holn
"""
......@@ -19,9 +19,8 @@ import datetime
port=20
program="20171109.008"
#programlist=["20171011.009"]
programlist=["20171011.010","20171011.011","20171011.012","20171011.013","20171011.014","20171011.015","20171011.016","20171011.017","20171011.018","20171011.019","20171011.022","20171011.025","20171011.026","20171011.030","20171011.031","20171011.034","20171011.035","20171011.036","20171011.037","20171011.038","20171011.039","20171011.041","20171011.042","20171011.044","20171109.006","20171109.007","20171109.009","20171109.010","20171109.012","20171109.013","20171109.014","20171109.016","20171109.017","20171109.018","20171109.020","20171109.021","20171109.022","20171109.023","20171109.024","20171109.025","20171109.026"]
programlist.extend(["20171102.007","20171102.009","20171102.011","20171102.012","20171102.014","20171102.022"])
path="F:\\holn\\Documents\\Doktorarbeit\\RESULTS\\OP1.2a\\Fulldivertor_res\\EJM\\He\\"
programlist=["20171108.018","20171109.040","20171109.045"]
path="F:\\holn\\Documents\\Doktorarbeit\\RESULTS\\OP1.2a\\Fulldivertor_res\\EJM\\H\\"
outpfad="F:\\holn\\Documents\\Doktorarbeit\\DATEN\\Mapping\\LinesforStacks\\"
scenepath=""
......@@ -42,8 +41,8 @@ for program in programlist:
time=np.asarray(File['time'][0])
tilelist=np.asarray(File['tiles'])
### camera, program dependent things###
heatpics=np.zeros((125+190+10,108*12+4,len(time)))# define the pictures for the heat flux
alphapic=np.zeros((125+190+10,108*12+4,1)) # define the picture for the alpha values
heatpics=np.zeros((125+190+10,108*12+4,len(time)),dtype=np.float32)# define the pictures for the heat flux
alphapic=np.zeros((125+190+10,108*12+4,1),dtype=np.float32) # define the picture for the alpha values
alphapic.fill(np.nan)
heatpics.fill(np.nan)
if upload_Mapping:
......@@ -215,7 +214,7 @@ for program in programlist:
print(datetime.datetime.now(),"starting upload")
# IRup.upload_Parlog(url,parobj,versionnumber=1)
print(datetime.datetime.now(),"parlog written")
# IRup.upload_images(images,time=time_ns,group=group,stream=stream,project=project,version=1,swapping=False,Test=True)
IRup.upload_images(images,time=time_ns,group=group,stream=stream,project=project,version=1,swapping=False,Test=True)
print(datetime.datetime.now(),"data uploaded")
del images,alphapic,heatpics,time_ns
if upload_Mapping:
......
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