Commit 2b574e87 authored by Holger Niemann's avatar Holger Niemann
Browse files

add function to upload reference images, tested and uploaded

parent 58a1b396
......@@ -48,7 +48,7 @@ def get_OP_by_time(time_ns=None, shot_no=None, program_str=None):
if dateOP.year == 2017:
if dateOP.month>8 and dateOP.month<12:
return "OP1.2a"
elif dateOP.month==8 and dateOP.day>28:
elif dateOP.month==8 and dateOP.day>=28:
return "OP1.2a"
elif dateOP.month==12 and dateOP.day<8:
return "OP1.2a"
......
......@@ -49,7 +49,7 @@ def get_OP_by_time(time_ns):
if dateOP.year==2017:
if dateOP.month>8 and dateOP.month<12:
return "OP1.2a"
elif dateOP.month==8 and dateOP.day>28:
elif dateOP.month==8 and dateOP.day>=28:
return "OP1.2a"
elif dateOP.month==12 and dateOP.day<8:
return "OP1.2a"
......
......@@ -14,8 +14,8 @@ import numpy as np
#from binfilesreadingv2 import BinVideoReader as bvreader
import os
import datetime as dt
from IR_config_constants import archivepath,portcamdict
from IR_image_tools import get_OP_by_time
try:
import h5py as h5reader
......@@ -696,20 +696,93 @@ def upload_LUT_tables(LUTs,LUTref,camera,portnum,time,newversion=False,reason=""
upload_fulldataset(url,parobj,dataobj,version)
def upload_hot_cold_reference(port,path):
def upload_hot_cold_reference(port,path,time=1503907200000000000,newversion=False,reason=""):
"""
"""
uploads the reference hot and cold images
"""
camera="IRCAM"
group="QRT_IRCAM_TEST"#+camera#+"_TEST" # test part will be removed in final version
name=["raw"]
group="QRT_IRCAM"#+camera#+"_TEST" # test part will be removed in final version
name=["raw"]
### get the files in folder, sort it, check whether port in filename fit the expected setting
OP=get_OP_by_time(time_ns=time)
camera=portcamdict[OP]["AEF"+str(port)]
files=os.listdir(path)
testfile=files[0]
Fragments=testfile.split(".")[0].split("_")
for ele in camera.split("_"):
if not ele in Fragments:
raise Exception("filenames does not fit the expected camera, "+camera+", missing part is "+ele)
serialnumber=camera.split("_")[2]
cameramodell=camera.split("_")[0]+" "+camera.split("_")[1]
time_ns_list=[]
framelist=[]
structurenames=[]
for i in range(len(files)):
filep=files[i].split(".")[0].split("_")
if len(Fragments)==len(filep):
if serialnumber in filep:
camfilter=filep[filep.index('filter')+1]
if "cold" in filep:
frame_type="cold"
elif "hot" in filep:
frame_type="hot"
else:
raise Exception("cannot indentify the type")
texp=filep[filep.index('texp')+1]
H5File=h5reader.File(os.path.join(path,files[i]),'r')
if len(list(H5File.keys()))==1:
key=list(H5File.keys())[0]
time_ns_list.append(int(time+i*10e6))
framelist.append(np.asarray(H5File[key]))
structurenames.append(frame_type+"_"+texp)
H5File.close()
else:
H5File.close()
raise Warning("unexpected HDF5 structure, to much content")
else:
raise Warning("serialnumber not found in the file, file will be ignored")
else:
raise Warning("different file format detected! (differnt from the first one. it will be ignored")
###
datastream_name="AEF"+str(port)+"_raw"
print("not ready")
url=archivepath+group+"/"+datastream_name
if newversion:
archive_create_stream_version(url, reason, False, "n/a", "n/a" )
ver=get_latest_version("Test/raw/"+project+"/"+group+"/"+datastream_name+"_PARLOG")
version=ver
else:
ver=get_latest_version("Test/raw/"+project+"/"+group+"/"+datastream_name+"_PARLOG")
if ver==None:
reason="Versioning of Data"
archive_create_stream_version(url, reason, False, "n/a", "n/a" )
version=1
else:
version=ver
structure={
'serialnumber':serialnumber,
'cameraname':cameramodell,
'filter':camfilter
}
for i in range(len(time_ns_list)):
structure[structurenames[i]]=time_ns_list[i]
# structure in the parlog, should contain something like cold_1us etc. with given timestamp inside
chanDesc={"[0]":{'name':name[0],'physicalQuantity':{'type':'none'},'active':1}}
parobj={"label":"parms",
"description":"reference data for AEF"+str(port),
"values":[{"chanDescs":chanDesc,"structure":structure}],
"dimensions":[time_ns_list[0],time_ns_list[-1]]
}
dataobj={"datatype":"integer",
"values":np.array(framelist).tolist(),
"dimensions":time_ns_list
}
upload_fulldataset(url,parobj,dataobj,version)
def upload_scene_model(port,time_ns,path="\\\\sv-e4-fs-1\\E4-Mitarbeiter\\E4 Diagnostics\\QIR\\Calibrations\\scene_models",newversion=False,reason=""):
camera="IRCAM"
group="QRT_IRCAM"#+camera#+"_TEST" # test part will be removed in final version
group="QRT_IRCAM_TEST"#+camera#+"_TEST" # test part will be removed in final version
name=["scene_model"]
datastream_name="AEF"+str(port)+"_scene_model"
url="http://archive-webapi.ipp-hgw.mpg.de/Test/raw/"+project+"/"+group+"/"+datastream_name
......
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