Skip to content
Snippets Groups Projects
Commit 6a7b27cf authored by Holger Niemann's avatar Holger Niemann
Browse files

update V3.0.1: extention of the heat flux upload to upload scene model reference also (untested)

parent ed1518ff
Branches
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 21 09:32:29 2018
V3.0.1
@author: holn
"""
import numpy as np
import scipy.io as sio
import matplotlib.pyplot as plt
#import matplotlib.pyplot as plt
import h5py as h5
import uploadingversionIRdata as IRup
import downloadversionIRdata as IR
......@@ -18,8 +18,12 @@ 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\\"
outpfad="F:\\holn\\Documents\\Doktorarbeit\\DATEN\\Mapping\\LinesforStacks\\"
scenepath=""
project="W7XAnalysis"
group="QRT_IRCAM"
......@@ -27,23 +31,45 @@ stream="AEF"+str(port)+"_heatflux"
comment="Test upload"
header={'code_version':4,'alpha_corrected':1}
stream2="Mapping_reference"
upload_Mapping=True
upload_Mapping=False
upload_scene_reference=False
stream_scene="AEF"+str(port)+"_SceneModel_reference"
scene_reference_time=0#ns timestamp goes here!
for program in programlist:
File=sio.loadmat(path+program+"_AEF"+str(port)+"_heatflux_V4.mat")
time=np.asarray(File['time'][0])
tilelist=np.asarray(File['tiles'])
heatpics=np.zeros((125+190+10,108*12+4,len(time)))
alphapic=np.zeros((125+190+10,108*12+4,1))
### 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
alphapic.fill(np.nan)
heatpics.fill(np.nan)
Xpic=alphapic.copy()
Ypic=alphapic.copy()
FXpic=alphapic.copy()
FYpic=alphapic.copy()
profpic=alphapic.copy()
profnpic=alphapic.copy()
tilepic=alphapic.copy()
fingerpic=alphapic.copy()
if upload_Mapping:
### mapping dependent things ###
Xpic=alphapic.copy() #X-Coordiate in the Mapping
Ypic=alphapic.copy() #Y-Coordiate in the Mapping
FXpic=alphapic.copy() #X-Coordiate in the Fingersystem in the Mapping
FYpic=alphapic.copy() #Y-Coordiate in the Fingersystem in the Mapping
profpic=alphapic.copy() #profiles or s coordiante in the Mapping
# profnpic=alphapic.copy()
tilepic=alphapic.copy() #target indentifier, 1: low iota, 2: middle part, 3: high iota, 4: vertical
fingerpic=alphapic.copy() #finger ID from the mapping, last two digits are the profile number, the 3 to 6. digit are the finger id (100*i+j; i:0-136; j:0-16)
if upload_scene_reference:
### Camera ###
PXpic=alphapic.copy() #orignal Pixel X
PYpic=alphapic.copy() #orignal Pixel Y
Xpic3D=alphapic.copy() #CAD 3D X from Scene Model
Ypic3D=alphapic.copy() #CAD 3D Y from Scene Model
Zpic3D=alphapic.copy() #CAD 3D Z from Scene Model
CID=alphapic.copy() #Component ID from the Scene Model
szene=h5.File(scenepath+"AEF"+str(port)+"_scene_model_"+str(scene_reference_time)+".h5",'r')
Xloc=np.asarray(szene['x'])
Yloc=np.asarray(szene['y'])
Zloc=np.asarray(szene['z'])
#CAD=np.asarray(szene['CAD'])
PFC=np.asarray(szene['PFC'])
linedict={'h_l':30,'h_m':54,'h_h':24,'v':29}
numstacks={
......@@ -98,7 +124,15 @@ for tile in tilelist:#['h_l','h_m','h_h','v']:
linid=list(linf['LineNos'])
lines=linf['locationall2D']#
linlocid=linf['rowcountarray']
linrefpoi=linf['refPoi']
linweipoi=linf['weightPoi']
if port==50:
shapi=[1024, 1280]
else:
shapi=[768, 1024]
locations=splitStacktoLines(lines,linlocid)
locpoi=splitStacktoLines(linrefpoi,linlocid)
locwei=splitStacktoLines(linweipoi,linlocid)
linf.close()
xoff+=1
if tile=='h_m' and iko<48 and iko%2==1:
......@@ -118,6 +152,10 @@ for tile in tilelist:#['h_l','h_m','h_h','v']:
lalpha=np.array(File['alpha_'+str(ii)+"_"+str(j2)][0])
lheat=np.array(File['heat_'+str(ii)+"_"+str(j2)])
lXY=np.array(File['plot_profiles_'+str(ii)+"_"+str(j2)])
xf=np.array(np.asarray(locpoi[j2])%shapi[1],dtype=np.int16)
yf=np.array(np.asarray(locpoi[j2])//shapi[1],dtype=np.int16)
PX=np.asarray([np.dot(xf[o],locwei[j2][o]) for o in range(len(xf))])
PY=np.asarray([np.dot(yf[o],locwei[j2][o]) for o in range(len(yf))])
loco=locations[j2]
profilelength=int(np.max(lprof)/3e-3)+1
for k in range(profilelength):
......@@ -126,6 +164,7 @@ for tile in tilelist:#['h_l','h_m','h_h','v']:
if abs(pos-lprof[pid])<2e-3:
alphapic[yoff+yloff,xoff]=lalpha[pid]
heatpics[yoff+yloff,xoff,:]=lheat[:,pid]
if upload_Mapping:
Xpic[yoff+yloff,xoff]=lXY[pid,0]
Ypic[yoff+yloff,xoff]=lXY[pid,1]
FXpic[yoff+yloff,xoff]=loco[pid,0]
......@@ -134,12 +173,19 @@ for tile in tilelist:#['h_l','h_m','h_h','v']:
# profnpic[yoff+yloff,xoff]=j
tilepic[yoff+yloff,xoff]=tn
fingerpic[yoff+yloff,xoff]=ii*100+j
if upload_scene_reference:
PXpic[yoff+yloff,xoff]=int(round(PX[pid],0))
PYpic[yoff+yloff,xoff]=int(round(PY[pid],0))
Xpic3D[yoff+yloff,xoff]=Xloc[int(round(PY[pid],0)),int(round(PX[pid],0))]
Ypic3D[yoff+yloff,xoff]=Yloc[int(round(PY[pid],0)),int(round(PX[pid],0))]
Zpic3D[yoff+yloff,xoff]=Zloc[int(round(PY[pid],0)),int(round(PX[pid],0))]
CID[yoff+yloff,xoff]=PFC[int(round(PY[pid],0)),int(round(PX[pid],0))]
yloff+=1
xoff+=1
if yloff>maxyoff and not shift:
maxyoff=yloff
ii+=1
del lalpha,lheat,lXY,loco,lprof,tn,File
#plt.figure();plt.imshow(alphapic[:,:,0])
#plt.figure();plt.imshow(tilepic[:,:,0])
#plt.figure();plt.imshow(fingerpic[:,:,0])
......@@ -162,15 +208,16 @@ if prog[0]:
url=archivepath+project+"/"+group+"/AEF"+str(port)+"_heatflux"
# url=IR.archivepath+project+"/"+group+"/"+stream
ver=IR.get_latest_version("Test/raw/"+project+"/"+group+"/"+stream+"_PARLOG",project=project,Test=True)
ver=IR.get_latest_version(group+"/"+stream+"_PARLOG",project=project,Test=True)
if ver==None:
reason="Versioning of Data"
IRup.archive_create_stream_version(url, reason, False, "n/a", "n/a" )
print(datetime.datetime.now(),"starting upload")
IRup.upload_Parlog(url,parobj,versionnumber=1)
# 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:
### upload reference stream ###once!
time_ns2=[]
......@@ -192,9 +239,35 @@ if prog[0]:
}
# url=IR.archivepath+project+"/"+group+"/"+stream2
url=archivepath+project+"/"+group+"/"+stream2
ver=IR.get_latest_version("Test/raw/"+project+"/"+group+"/"+stream2+"_PARLOG",project=project,Test=True)
ver=IR.get_latest_version(group+"/"+stream2+"_PARLOG",project=project,Test=True)
if ver==None:
reason="Versioning of Data"
IRup.archive_create_stream_version(url, reason, False, "n/a", "n/a" )
IRup.upload_Parlog(url,parobj,versionnumber=1)
IRup.upload_images(images2,time=time_ns2,group=group,stream=stream2,project=project,version=1,swapping=False,Test=True)
if upload_scene_reference:
### upload scene model camera refrence stream (once per scene model)
time_ns_scene=[]
for t in range(6):
time_ns_scene.append(int(scene_reference_time+10*t))
images3=np.append(PXpic,PYpic,axis=2)
images3=np.append(images3,Xpic3D,axis=2)
images3=np.append(images3,Ypic3D,axis=2)
images3=np.append(images3,Zpic3D,axis=2)
images3=np.append(images3,CID,axis=2)
header3={'Pixel_X':int(scene_reference_time),'Pixel_Y':int(scene_reference_time+10),'CAD_X':int(scene_reference_time+20),'CAD_Y':int(scene_reference_time+30),'CAD_Z':int(scene_reference_time+40),'Component_ID':int(timet1+50)}
chanDesc=[{'name':'scene model reference','physicalQuantity':{'type':'none'},'active':1}]
parobj={"label":"parms",
"description":"scene model reference data for the heat flux",
"values":[{"chanDescs":chanDesc,'header':header3,'comment':comment}],
"dimensions":[int(time_ns_scene[0]),int(time_ns_scene[-1])]
}
# url=IR.archivepath+project+"/"+group+"/"+stream2
url=archivepath+project+"/"+group+"/"+stream_scene
ver=IR.get_latest_version(group+"/"+stream_scene+"_PARLOG",project=project,Test=True)
if ver==None:
reason="Versioning of Data"
IRup.archive_create_stream_version(url, reason, False, "n/a", "n/a" )
IRup.upload_Parlog(url,parobj,versionnumber=1)
IRup.upload_images(images3,time=time_ns_scene,group=group,stream=stream_scene,project=project,version=1,swapping=False,Test=True)
......@@ -950,7 +950,7 @@ def upload_images(images,time,group,stream,newversion=False,reason="",project="W
# archive.write_signals(images,time,group,project,names, datastream_name,units,metadata,2,True)
tmp=writeH5_images(datastream_name,images,time,swapping=swapping)
# uploadH5(group,datastream_name,tmp,True)
response=uploadH5_Versioning(group,datastream_name,tmp,version,True,project=project)
response=uploadH5_Versioning(group,datastream_name,tmp,version,True,project=project,Test=Test)
return response
except Exception as E:
print("Upload Failed")
......@@ -985,8 +985,11 @@ def uploadH5(group,stream, h5file, delete=False, timeout=None,project="W7X"):
# _sup.debug(result,3)
# return result
def uploadH5_Versioning(group,stream, h5file,version, delete=False, timeout=None,project="W7X"):
def uploadH5_Versioning(group,stream, h5file,version, delete=False, timeout=None,project="W7X",Test=False):
# path=Path, h5file=h5-file
if Test:
base="http://archive-webapi.ipp-hgw.mpg.de/Test/raw/"+project+"/"#"http://archive-webapi/Test/raw/W7X/" #"http://sv-coda-wsvc-3/Test/raw/W7X/"#
else:
base=archivepath+project+"/"#"http://archive-webapi/Test/raw/W7X/" #"http://sv-coda-wsvc-3/Test/raw/W7X/"#
#http://sv-coda-wsvc-3/Test/raw/W7X/QRT_IRCAM_TEST?dataPath=/data/AEF100_RAW_TEST2&timePath=/data/timestamps&versionNumber=1
try:
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment