Commit d03751bc authored by Peter Drewelow's avatar Peter Drewelow
Browse files

downloadversionIRdata: improved print outputs

sample plot scripts: fixed time_window parameter call
parent 85dec559
...@@ -267,7 +267,7 @@ def get_NUC_by_program(port,program,exposure,version=0,verbose=0): ...@@ -267,7 +267,7 @@ def get_NUC_by_program(port,program,exposure,version=0,verbose=0):
if prog[0]: if prog[0]:
starttime=prog[1]['trigger']['0'][0] starttime=prog[1]['trigger']['0'][0]
stoptime=prog[1]['trigger']['1'][0] stoptime=prog[1]['trigger']['1'][0]
return get_NUC_by_times(port,starttime,stoptime,exposure,version=0,verbose=verbose-1) return get_NUC_by_times(port,starttime,stoptime,exposure,version=0,verbose=verbose)
else: else:
# except: # except:
print("get_NUC_by_program: Error! cannot find the program") print("get_NUC_by_program: Error! cannot find the program")
...@@ -571,12 +571,12 @@ def download_raw_images_by_program(port,program,time_window=0,version=0,verbose= ...@@ -571,12 +571,12 @@ def download_raw_images_by_program(port,program,time_window=0,version=0,verbose=
tstop=time_window[1] tstop=time_window[1]
if tstop<tstart: if tstop<tstart:
raise Exception("download_raw_images_by_program: endtime before starttime") raise Exception("download_raw_images_by_program: endtime before starttime")
return download_raw_images_by_times(port,int(starttime+tstart*1e9),int(starttime+tstop*1e9),version,verbose=verbose-1) return download_raw_images_by_times(port,int(starttime+tstart*1e9),int(starttime+tstop*1e9),version,verbose=verbose)
else: else:
if time_window==0: if time_window==0:
return download_raw_images_by_times(port,starttime,stoptime,version,verbose=verbose-1) return download_raw_images_by_times(port,starttime,stoptime,version,verbose=verbose)
else: else:
return download_raw_images_by_times(port,starttime,int(starttime+time_window*1e9),version,verbose=verbose-1) return download_raw_images_by_times(port,starttime,int(starttime+time_window*1e9),version,verbose=verbose)
except: except:
print("download_raw_images_by_program: Error! cannot find the program") print("download_raw_images_by_program: Error! cannot find the program")
return False,0,0 return False,0,0
...@@ -588,7 +588,7 @@ def download_raw_images_by_times(port,starttime,stoptime,version=0,intervalSize= ...@@ -588,7 +588,7 @@ def download_raw_images_by_times(port,starttime,stoptime,version=0,intervalSize=
if version==0: if version==0:
version=get_latest_version(portpathdict[OP]["AEF"+str(port)]+"raw_DATASTREAM",t_from=starttime,t_to=stoptime) version=get_latest_version(portpathdict[OP]["AEF"+str(port)]+"raw_DATASTREAM",t_from=starttime,t_to=stoptime)
larchivepath=archivepath+"W7X/"+portpathdict[OP]["AEF"+str(port)]+"raw_DATASTREAM/V"+str(version)+"/0/raw" larchivepath=archivepath+"W7X/"+portpathdict[OP]["AEF"+str(port)]+"raw_DATASTREAM/V"+str(version)+"/0/raw"
return download_images_by_times(larchivepath,starttime=starttime,stoptime=stoptime,version=version,intervalSize=intervalSize,verbose=verbose-1) return download_images_by_times(larchivepath,starttime=starttime,stoptime=stoptime,version=version,intervalSize=intervalSize,verbose=verbose)
def download_images_by_times(larchivepath,starttime,stoptime,version=0,intervalSize=1E9,verbose=0): def download_images_by_times(larchivepath,starttime,stoptime,version=0,intervalSize=1E9,verbose=0):
""" """
...@@ -610,7 +610,10 @@ def download_images_by_times(larchivepath,starttime,stoptime,version=0,intervalS ...@@ -610,7 +610,10 @@ def download_images_by_times(larchivepath,starttime,stoptime,version=0,intervalS
success=False success=False
for i in range(nrinterv): for i in range(nrinterv):
try: try:
res = urllib.request.urlopen(larchivepath+"/_signal.json?from="+str(intervalls[i])+"&upto="+str(intervalls[i+1])) url = larchivepath+"/_signal.json?from="+str(intervalls[i])+"&upto="+str(intervalls[i+1])
if verbose>2:
print("download_images_by_times: reading from\n {0}".format(url))
res = urllib.request.urlopen(url)
signal_list = json.loads(res.read().decode('utf-8')) signal_list = json.loads(res.read().decode('utf-8'))
res.close() res.close()
images=[np.array(ele, dtype=typo) for ele in signal_list['values']] images=[np.array(ele, dtype=typo) for ele in signal_list['values']]
...@@ -2561,7 +2564,7 @@ def download_heatflux_by_program(port,program,time_window=0,threads=1,testmode=F ...@@ -2561,7 +2564,7 @@ def download_heatflux_by_program(port,program,time_window=0,threads=1,testmode=F
if givealpha: if givealpha:
tstart=tstart-1.1e9 tstart=tstart-1.1e9
return download_heatflux_by_times(port=port,tstart=tstart,tend=tend,time_window=0, return download_heatflux_by_times(port=port,tstart=tstart,tend=tend,time_window=0,
testmode=testmode,version=version,verbose=verbose-1, testmode=testmode,version=version,verbose=verbose,
request=request) request=request)
else: else:
print("download_heatflux_by_program: Error! program not found") print("download_heatflux_by_program: Error! program not found")
...@@ -2626,7 +2629,7 @@ def download_heatflux_by_times(port,tstart,tend,time_window=0,threads=1,testmode ...@@ -2626,7 +2629,7 @@ def download_heatflux_by_times(port,tstart,tend,time_window=0,threads=1,testmode
if exist==False: if exist==False:
now=datetime.datetime.now() now=datetime.datetime.now()
if verbose>0: if verbose>0:
print(now,"download_heatflux_by_times: heat flux data is not available, creating request") print(now,"download_heatflux_by_times: heat flux data is not available")
if request: if request:
f=open(heatflux_requestlist_path+str(now.year)+str(now.month)+"_q_requests.txt",'a') f=open(heatflux_requestlist_path+str(now.year)+str(now.month)+"_q_requests.txt",'a')
try: try:
...@@ -2637,6 +2640,8 @@ def download_heatflux_by_times(port,tstart,tend,time_window=0,threads=1,testmode ...@@ -2637,6 +2640,8 @@ def download_heatflux_by_times(port,tstart,tend,time_window=0,threads=1,testmode
programid=str(tstart) programid=str(tstart)
f.write(programid+"\tAEF"+str(port)+"\n") f.write(programid+"\tAEF"+str(port)+"\n")
f.close() f.close()
if verbose>0:
print("download_heatflux_by_times: heat flux calculation request logged for automatic processing (within ca. 1 day)")
return exist,time,frames return exist,time,frames
def download_heatflux_mapping_reference(timepoint=None,version=0,testmode=False,verbose=0): def download_heatflux_mapping_reference(timepoint=None,version=0,testmode=False,verbose=0):
...@@ -2658,7 +2663,7 @@ def download_heatflux_mapping_reference(timepoint=None,version=0,testmode=False, ...@@ -2658,7 +2663,7 @@ def download_heatflux_mapping_reference(timepoint=None,version=0,testmode=False,
# version=get_latest_version("QRT_IRCAM_Test/Mapping_reference_Test_1_PARLOG",project=project_ana,Test=testmode) # version=get_latest_version("QRT_IRCAM_Test/Mapping_reference_Test_1_PARLOG",project=project_ana,Test=testmode)
# larchivepath=base+project_ana+"/QRT_IRCAM_Test/Mapping_reference_Test_1_DATASTREAM/V"+str(version)+"/0/reference" # larchivepath=base+project_ana+"/QRT_IRCAM_Test/Mapping_reference_Test_1_DATASTREAM/V"+str(version)+"/0/reference"
### end of testsample ### ### end of testsample ###
exist,time,frames=download_images_by_times(larchivepath,starttime=timepoint,stoptime=int(timepoint+1e9),version=version,verbose=verbose-1) exist,time,frames=download_images_by_times(larchivepath,starttime=timepoint,stoptime=int(timepoint+1e9),version=version,verbose=verbose)
mappings={} mappings={}
if exist: if exist:
mappings['s']=frames[0] mappings['s']=frames[0]
...@@ -2737,7 +2742,7 @@ def give_finger_ID(profile,finger=None): ...@@ -2737,7 +2742,7 @@ def give_finger_ID(profile,finger=None):
"tm1h":0,"tm2h":6,"tm3h":13,"tm4h":21,"tm5h":29,"tm6h":53,"tm7h":77,"tm8h":83,"tm9h":95,"tm1v":107,"tm2v":117,"tm3v":127} "tm1h":0,"tm2h":6,"tm3h":13,"tm4h":21,"tm5h":29,"tm6h":53,"tm7h":77,"tm8h":83,"tm9h":95,"tm1v":107,"tm2v":117,"tm3v":127}
### go throw the different cases, case: only one if given ### go throw the different cases, case: only one if given
fingerID=-1 fingerID=-1
if finger==None:##combinations there only profile is given if finger==None:##combinations where only profile is given
if type(profile)==int: if type(profile)==int:
fingerID=profile fingerID=profile
success=True success=True
......
...@@ -15,7 +15,7 @@ if __name__=='__main__': ...@@ -15,7 +15,7 @@ if __name__=='__main__':
#%% loading data #%% loading data
print(datetime.datetime.now(),"start") print(datetime.datetime.now(),"start")
status,time,images,valid=downIR.get_temp_from_raw_by_program(10,"20180801.017",time_s=2.5,emi=0.8,T_version=2,version=0,threads=1,give_ERROR=False,verbose=5) status,time,images,valid=downIR.get_temp_from_raw_by_program(10,"20180801.017",time_window=2.5,emi=0.8,T_version=2,version=0,threads=1,give_ERROR=False,verbose=5)
print('fertig') print('fertig')
#%% plotting data #%% plotting data
......
...@@ -9,8 +9,8 @@ import IR_data_access.downloadversionIRdata as IR ...@@ -9,8 +9,8 @@ import IR_data_access.downloadversionIRdata as IR
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import datetime import datetime
port=20 port=10 # 20
program="20181004.012" program="20171207.022" # "20181004.012"
if __name__=='__main__': if __name__=='__main__':
...@@ -44,7 +44,7 @@ if __name__=='__main__': ...@@ -44,7 +44,7 @@ if __name__=='__main__':
plt.xlabel("s [m]",fontsize=26) plt.xlabel("s [m]",fontsize=26)
plt.ylabel("q [MW/m2]",fontsize=26) plt.ylabel("q [MW/m2]",fontsize=26)
plt.tick_params(labelsize=26) plt.tick_params(labelsize=26)
plt.title("20171109.008 heat flux profile for TM3, finger 5, profile 5 @1s",fontsize=26) plt.title("{0} heat flux profile for TM3, finger 5, profile 5 @1s".format(program),fontsize=26)
plt.grid() plt.grid()
plt.ylim(bottom=0) plt.ylim(bottom=0)
plt.show() plt.show()
...@@ -58,7 +58,7 @@ if __name__=='__main__': ...@@ -58,7 +58,7 @@ if __name__=='__main__':
cb=plt.colorbar() cb=plt.colorbar()
cb.set_label('heatflux in MW/m²', rotation=270, labelpad=15,fontsize=26) cb.set_label('heatflux in MW/m²', rotation=270, labelpad=15,fontsize=26)
cb.ax.tick_params(labelsize=26) cb.ax.tick_params(labelsize=26)
plt.title("20171109.008 heat flux profile for TM3, finger 5, profile 5",fontsize=26) plt.title("{0} heat flux profile for TM3, finger 5, profile 5".format(program),fontsize=26)
plt.show() plt.show()
# status3,mapping=IR.download_heatflux_scene_model_reference(port,program=program,verbose=0) # status3,mapping=IR.download_heatflux_scene_model_reference(port,program=program,verbose=0)
# bild=np.zeros((768,1024)) # bild=np.zeros((768,1024))
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