From d03751bcbf675a5f4d8d0e705dbc277d226221ac Mon Sep 17 00:00:00 2001 From: Peter Drewelow <peter.drewelow@ipp.mpg.de> Date: Thu, 2 May 2019 13:55:45 +0200 Subject: [PATCH] downloadversionIRdata: improved print outputs sample plot scripts: fixed time_window parameter call --- downloadversionIRdata.py | 25 +++++++++++++++---------- plot_IR_data.py | 2 +- plot_heatflux_example.py | 8 ++++---- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/downloadversionIRdata.py b/downloadversionIRdata.py index 944bc33..aaa82ae 100644 --- a/downloadversionIRdata.py +++ b/downloadversionIRdata.py @@ -267,7 +267,7 @@ def get_NUC_by_program(port,program,exposure,version=0,verbose=0): if prog[0]: starttime=prog[1]['trigger']['0'][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: # except: 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= tstop=time_window[1] if tstop<tstart: 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: 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: - 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: print("download_raw_images_by_program: Error! cannot find the program") return False,0,0 @@ -588,7 +588,7 @@ def download_raw_images_by_times(port,starttime,stoptime,version=0,intervalSize= if version==0: 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" - 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): """ @@ -610,7 +610,10 @@ def download_images_by_times(larchivepath,starttime,stoptime,version=0,intervalS success=False for i in range(nrinterv): 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')) res.close() 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 if givealpha: tstart=tstart-1.1e9 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) else: 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 if exist==False: now=datetime.datetime.now() 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: f=open(heatflux_requestlist_path+str(now.year)+str(now.month)+"_q_requests.txt",'a') try: @@ -2637,6 +2640,8 @@ def download_heatflux_by_times(port,tstart,tend,time_window=0,threads=1,testmode programid=str(tstart) f.write(programid+"\tAEF"+str(port)+"\n") 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 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, # 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" ### 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={} if exist: mappings['s']=frames[0] @@ -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} ### go throw the different cases, case: only one if given fingerID=-1 - if finger==None:##combinations there only profile is given + if finger==None:##combinations where only profile is given if type(profile)==int: fingerID=profile success=True diff --git a/plot_IR_data.py b/plot_IR_data.py index 6c34d00..29a58e5 100644 --- a/plot_IR_data.py +++ b/plot_IR_data.py @@ -15,7 +15,7 @@ if __name__=='__main__': #%% loading data 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') #%% plotting data diff --git a/plot_heatflux_example.py b/plot_heatflux_example.py index edbef83..e955ba0 100644 --- a/plot_heatflux_example.py +++ b/plot_heatflux_example.py @@ -9,8 +9,8 @@ import IR_data_access.downloadversionIRdata as IR import matplotlib.pyplot as plt import datetime -port=20 -program="20181004.012" +port=10 # 20 +program="20171207.022" # "20181004.012" if __name__=='__main__': @@ -44,7 +44,7 @@ if __name__=='__main__': plt.xlabel("s [m]",fontsize=26) plt.ylabel("q [MW/m2]",fontsize=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.ylim(bottom=0) plt.show() @@ -58,7 +58,7 @@ if __name__=='__main__': cb=plt.colorbar() cb.set_label('heatflux in MW/m²', rotation=270, labelpad=15,fontsize=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() # status3,mapping=IR.download_heatflux_scene_model_reference(port,program=program,verbose=0) # bild=np.zeros((768,1024)) -- GitLab