From ddb72caafcda39a92e3e20f5b984b1738f4fa940 Mon Sep 17 00:00:00 2001 From: Holger Niemann <holger.niemann@ipp.mpg.de> Date: Tue, 12 Mar 2019 16:44:15 +0100 Subject: [PATCH] V3.2.0 part 1: added the CAD reference download for the heat flux data --- downloadversionIRdata.py | 65 ++++++++++++++++++++++++++++++++++++++-- plot_heatflux_example.py | 12 ++++++-- upload_heatflux.py | 8 ++--- 3 files changed, 75 insertions(+), 10 deletions(-) diff --git a/downloadversionIRdata.py b/downloadversionIRdata.py index 35f6838..cb87d27 100644 --- a/downloadversionIRdata.py +++ b/downloadversionIRdata.py @@ -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.1.2 +Version: 3.2.0 (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 """ @@ -644,9 +644,9 @@ def download_images_by_times(larchivepath,starttime,stoptime,version=0,intervalS return success,time,allimages else: try: - res = urllib.request.urlopen(larchivepath+"/_signal.json?from="+str(starttime-10)+"&upto="+str(stoptime)) if verbose>100: print(larchivepath+"/_signal.json?from="+str(starttime-10)+"&upto="+str(stoptime)) + res = urllib.request.urlopen(larchivepath+"/_signal.json?from="+str(starttime-10)+"&upto="+str(stoptime)) signal_list = json.loads(res.read().decode('utf-8')) res.close() images=[np.array(ele, dtype=typo) for ele in signal_list['values']] @@ -2608,7 +2608,66 @@ def download_heatflux_mapping_reference(timepoint=None,version=0,testmode=True,v mappings['Finger_ID']=(frames[5],"legend: first three digits are fingernumber,starting @0, last two are the profile number") mappings['Target']=(frames[6],{1:"TM1-4h",2:"TM5-6h",3:"TM7-9h",4:"TM1-3v"}) return exist,mappings - + +def download_heatflux_scene_model_reference(port,timepoint=None,program=None,version=0,testmode=True,verbose=0): + """ + return exist(boolean) and dictonary of the mappings informations + """ + if type(port)==int or type(port)==float: + portnam="AEF"+str(port) + elif type(port)==str: + portnam=port + if timepoint==None and program==None: + timepoint=int(TimeToNs([2017,8,28],[8,0,0,0])) + elif timepoint==None: + prog=get_program_from_PID(program) + if prog[0]: + timepoint=prog[1]['trigger']['1'][0] + else: + raise Exception("download_heatflux_scene_model_reference: Error! Program "+program+" not found!") + if testmode: + base="http://archive-webapi.ipp-hgw.mpg.de/Test/raw/" + else: + base=archivepath +# OP=IR_tools.get_OP_by_time(time_ns=timepoint) + + if version==0: + version=get_latest_version("QRT_IRCAM/"+str(portnam)+"_SceneModel_reference_DATASTREAM",project=project_ana,Test=testmode) + larchivepath=base+project_ana+"/"+"QRT_IRCAM/"+str(portnam)+"_SceneModel_reference_DATASTREAM/V"+str(version)+"/0/reference" + larchivepath_par=base+project_ana+"/QRT_IRCAM/"+str(portnam)+"_SceneModel_reference_PARLOG/V"+str(version)+"/parms/header/Pixel_X" + + ### test for the testsample### +#============================================================================== +# if version==0: +# version=get_latest_version("QRT_IRCAM_Test/"+str(portnam)+"_SceneModel_reference_PARLOG",project=project_ana,Test=testmode) +# larchivepath=base+project_ana+"/QRT_IRCAM_Test/"+str(portnam)+"_SceneModel_reference_DATASTREAM/V"+str(version)+"/0/scene%20model%20reference" +# larchivepath_par=base+project_ana+"/QRT_IRCAM_Test/"+str(portnam)+"_SceneModel_reference_PARLOG/V"+str(version)+"/parms/header/Pixel_X" +#============================================================================== + ### end of testsample ### + try: + res = urllib.request.urlopen(larchivepath_par+"/_signal.json?from="+str(timepoint)+"&upto="+str(timepoint)) + signal_list = json.loads(res.read().decode('utf-8')) + res.close() + goon=True + except urllib.error.URLError as e: + print('download_heatflux_scene_model_reference: Error! ',e) + goon=False + if goon: + timepoint=signal_list['values'][0] + exist,time,frames=download_images_by_times(larchivepath,starttime=timepoint-10,stoptime=int(timepoint+1e8),version=version,verbose=verbose-1) + mappings={} + if exist: + mappings['Pixel_X']=frames[0] + mappings['Pixel_Y']=frames[1] + mappings['CAD_X']=frames[2] + mappings['CAD_Y']=frames[3] + mappings['CAD_Z']=frames[4] + mappings['PFC']=(frames[5],"legend: https://wikis.ipp-hgw.mpg.de/W7X/images/9/9c/PFC2.pdf") + + return exist,mappings + else: + return False,{} + def give_finger_ID(profile,finger=None): """ profile: string, integer or float, string: "TM3h_5_5" or "1605" or "16.05" or "5", similar for float and integer. single number only if the finger is given! diff --git a/plot_heatflux_example.py b/plot_heatflux_example.py index c3d537d..edbef83 100644 --- a/plot_heatflux_example.py +++ b/plot_heatflux_example.py @@ -1,23 +1,27 @@ # -*- coding: utf-8 -*- """ Created on Thu Nov 29 17:41:40 2018 -V3.0.2 +V3.2.0 @author: holn """ import numpy as np import IR_data_access.downloadversionIRdata as IR import matplotlib.pyplot as plt import datetime + +port=20 +program="20181004.012" + if __name__=='__main__': #%% loading data print(datetime.datetime.now(),"start") - status,times,images=IR.download_heatflux_by_program(20,"20181004.012",time_window=0.9,version=1,threads=1,verbose=5) + status,times,images=IR.download_heatflux_by_program(port,program,time_window=0.9,version=1,threads=1,verbose=5) print('done') #%% plotting data if status: - status2,time,s,q=IR.extract_heatflux_profile_from_DL((np.asarray(times)-times[0])/1e9,images,profile="TM3h_5_5",time_window=0.5,verbose=5) + status2,time,s,q=IR.extract_heatflux_profile_from_DL((np.asarray(times)-times[0])/1e9,images,profile="TM3h_5_5",time_window=0.5,verbose=5) plt.figure() plt.imshow(images[-1]/1e6) plt.clim([0,4]) @@ -56,4 +60,6 @@ if __name__=='__main__': cb.ax.tick_params(labelsize=26) plt.title("20171109.008 heat flux profile for TM3, finger 5, profile 5",fontsize=26) plt.show() +# status3,mapping=IR.download_heatflux_scene_model_reference(port,program=program,verbose=0) +# bild=np.zeros((768,1024)) \ No newline at end of file diff --git a/upload_heatflux.py b/upload_heatflux.py index c47d262..cbd6b31 100644 --- a/upload_heatflux.py +++ b/upload_heatflux.py @@ -16,7 +16,7 @@ import datetime -port=10 +port=20 program="20171109.008" #programlist=["20171011.009"] programlist=["20171114.038"]#"20180814.024"]#,"20181016.016"]#["20171108.018","20171109.040","20171109.045"] @@ -25,15 +25,15 @@ outpfad="F:\\holn\\Documents\\Doktorarbeit\\DATEN\\Mapping\\LinesforStacks\\" scenepath="X:\\E4 Diagnostics\\QIR\\Data\\scene_models\OP1.2a\\" project="W7XAnalysis" -group="QRT_IRCAM_Test" +group="QRT_IRCAM" stream="AEF"+str(port)+"_heatflux" -comment="Test upload" +comment="first upload" header={'code_version':4,'alpha_corrected':1} stream2="Mapping_reference" upload_Mapping=False upload_scene_reference=True#False stream_scene="AEF"+str(port)+"_SceneModel_reference" -scene_reference_time=1503907200000000000#ns timestamp goes here! +scene_reference_time=1512547200000000000#1503907200000000000#ns timestamp goes here! for program in programlist: -- GitLab