From 6182c147f3073c4eaa4b5e22a37fedd3926f2d50 Mon Sep 17 00:00:00 2001
From: Holger Niemann <holger.niemann@ipp.mpg.de>
Date: Mon, 26 Feb 2018 18:59:56 +0100
Subject: [PATCH] bugfixes for AEF50, infratec camera (LUT,background image,
 checking of temperature range

---
 downloadversionIRdata.py | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/downloadversionIRdata.py b/downloadversionIRdata.py
index 5c59d56..9f348a0 100644
--- a/downloadversionIRdata.py
+++ b/downloadversionIRdata.py
@@ -323,9 +323,9 @@ def download_LUT(port,time,exposure=0,emissivity=0,camera_filter=0,version=0):
     LUTpar=read_restdb_old(larchivepath+"PARLOG/V"+str(version)+"/_signal.json?from="+str(time-10)+"&upto="+str(time+20))
     if LUTpar[0]:
         LUTid=LUTpar[2][0]['structure'][query]
-        LUTs=read_restdb_old(larchivepath+"DATASTREAM/V"+str(version)+"/_signal.json?from="+str(time-10)+"&upto="+str(time+20))
+        LUTs=read_restdb_old(larchivepath+"DATASTREAM/V"+str(version)+"/0/LUT/_signal.json?from="+str(time-10)+"&upto="+str(time+20))
         if LUTs[0]:
-            LUTs=LUTs[2][0]
+            LUTs=LUTs[2].swapaxes(1,2)[0]
             LUT=[LUTs[0],LUTs[LUTid],LUTs[LUTid+1]]
             del LUTpar, LUTs
             return True,LUT
@@ -736,11 +736,13 @@ def get_exposure_by_program(port,program,version=0):
         
 def get_exposure_by_times(port,starttime,stoptime,version=0):
     if port==50:#camera=="INFRATEC" or camera=="infratec" or camera=="Infratec":
-        larchivepath=archivepath+"QRT_INFRATEC/"+"AEF"+str(port)+"_meta_"      
+        larchivepath=archivepath+"QRT_INFRATEC/"+"AEF"+str(port)+"_meta_"   
+        stream="QRT_INFRATEC/"+"AEF"+str(port)+"_meta_" 
     elif port in [10,11,20,21,30,31,40,41,51]:#camera=="IRCAM" or camera=="IRcam" or camera=="ircam":
         larchivepath=archivepath+"QRT_IRCAM/"+"AEF"+str(port)+"_meta_" 
+        stream="QRT_IRCAM/"+"AEF"+str(port)+"_meta_"
     if version==0:
-        version=get_latest_version("QRT_IRCAM/"+"AEF"+str(port)+"_meta_DATASTREAM")
+        version=get_latest_version(stream+"DATASTREAM")
     return AKF_1.read_restdb(larchivepath+"DATASTREAM/V"+str(version)+"/3/exposuretime"+"/_signal.json?from="+str(starttime)+"&upto="+str(stoptime))
       
 def get_camera_temp_by_program(port,program,version=0):
@@ -986,7 +988,10 @@ def terror_from_LUT(LUT,images):
 def check_temperature_range(time,maxvalue_C,minvalue_C,port,exposure,cfilter=0):
     try:
         cam=portcamdict[get_OP_by_time(time)]['AEF'+str(port)]
-        ranges=camlimdict[cam][exposure]
+        if port==50:
+            ranges=camlimdict[cam][cfilter][exposure]
+        else:
+            ranges=camlimdict[cam][exposure]
 #        if minvalue_C>=ranges[0] and maxvalue_C<=ranges[1]:
 #            return True
         if minvalue_C<ranges[0] and maxvalue_C<=ranges[1]:
@@ -1310,7 +1315,7 @@ def get_calib_data(port,program,emissivity=0.8,Temp_V=2,version=0):
             if LUT_DL[0]:
                 LUT=LUT_DL[1]
                 del LUT_DL
-                back_DL=download_background_by_times(port,t0,t1,t_exp,version)
+                back_DL=download_background_by_times(port,t0,t1,t_exp,cfilter,version)
                 if back_DL[0]:
                     background=back_DL[2]
                     if Temp_V==1:
@@ -1568,7 +1573,7 @@ if __name__=='__main__':
 #    #status,time,images,valid=get_temp_from_raw_by_program_V1(51,"20171018.019",time_s=0,emi=0.8,divertorpart="all",version=1)
 ##    status1,time1,images1,valid1=get_temp_from_raw_by_program_V1(41,"20171024.016",time_s=[0.75,0.99],emi=0.8,version=1)
 ##    exist,time1,frames=download_raw_images_by_program_via_png(41,"20171024.016",time_s=[0.75,0.99],version=1,threads=1)
-    status,time,images,valid=get_temp_from_raw_by_program(20,"20171207.006",time_s=[2,2.2],emi=0.8,T_version=2,version=0,threads=4,give_ERROR=False)
+    status,time,images,valid=get_temp_from_raw_by_program(50,"20171207.039",time_s=[2,2.2],emi=0.82,T_version=2,version=0,threads=1,give_ERROR=False)
 #    status2,time2,images2,valid2=get_temp_from_raw_by_program(20,"201129.036",time_s=4.5,emi=0.8,T_version=2,version=0,threads=4,give_ERROR=False)    
 #    max1=[]
 #    max2=[]
-- 
GitLab