lidar_correction_ghk.py

changeset 13
f08818615e3a
parent 11
453b23dd7f94
child 14
82dba9904149
--- a/lidar_correction_ghk.py	Mon Nov 14 23:42:20 2016 +0100
+++ b/lidar_correction_ghk.py	Tue Nov 15 03:37:02 2016 +0100
@@ -111,8 +111,13 @@
 DaT = (1-ERaT)/(1+ERaT)
 TaT = 0.5*(1+ERaT)
 # --- PBS MR reflecting path defined with (RS,RP);  and +-Uncertainty
-RS, dRS, nRS = 1 - TS,  0., 0
-RP, dRP, nRP = 1 - TP,  0., 0
+RS_RP_depend_on_TS_TP = False
+if(RS_RP_depend_on_TS_TP):
+    RP, dRP, nRP        = 1-TP,  0.00, 0
+    RS, dRS, nRS        = 1-TS,  0.00, 0
+else:
+    RP, dRP, nRP        = 0.05,  0.01, 1
+    RS, dRS, nRS        = 0.98,  0.01, 1
 TiR = 0.5 * (RP + RS)
 DiR = (RP-RS)/(RP+RS)
 # PolFilter
@@ -268,7 +273,7 @@
 DiR = (RP-RS)/(RP+RS)
 ZiR = (1. - DiR**2)**0.5
 
-# --------------------------------------------------------
+# --- this subroutine is for the calculation with certain fixed parameters -----------------------------------------------------
 def Calc(RotL, RotE, RetE, DiE, RotO, RetO, DiO, RotC, RetC, DiC, TP, TS, RP, RS, ERaT, RotaT, RetT, ERaR, RotaR, RetR, LDRCal):
     # ---- Do the calculations of bra-ket vectors
     h = -1. if TypeC == 2 else 1
@@ -348,11 +353,11 @@
     #F11sim = TiO*(IinE + DiO*atrue*A)/IinE
     #-------------------------
 
-    # For PollyXT
     # analyser
-    #RS = 1 - TS
-    #RP = 1 - TP
-
+    #For POLLY_XTs
+    if(RS_RP_depend_on_TS_TP):
+        RS = 1 - TS
+        RP = 1 - TP
     TiT = 0.5 * (TP + TS)
     DiT = (TP-TS)/(TP+TS)
     ZiT = (1. - DiT**2)**0.5
@@ -823,8 +828,8 @@
 # --- CALC truth
 GT0, HT0, GR0, HR0, K0, Eta0, LDRsimx, LDRCorr, DTa0, DRa0, TTa0, TRa0, F11sim0 = Calc(RotL0, RotE0, RetE0, DiE0, RotO0, RetO0, DiO0, RotC0, RetC0, DiC0, TP0, TS0, RP0, RS0, ERaT0, RotaT0, RetT0, ERaR0, RotaR0, RetR0, LDRCal0)
 
-# --------------------------------------------------------
-with open('output_' + LID + '.dat', 'w') as f:
+# --- Print parameters to console and output file
+with open('output_files\output_' + LID + '.dat', 'w') as f:
     with redirect_stdout(f):
         print("From ", dname)
         print("Running ", fname)
@@ -844,11 +849,12 @@
         print("{0:12}{1:7.4f}±{2:7.4f}/{9:2d}, {3:7.4f}±{4:7.4f}/{10:2d}, {5:7.4f}±{6:7.4f}/{11:2d},{7:7.4f}±{8:7.4f}/{12:2d}".format("TP,TS,RP,RS     :", TP0, dTP, TS0, dTS, RP0, dRP, RS0, dRS, nTP, nTS, nRP, nRS))
         print("{0:12}{1:7.4f},{2:7.4f}, {3:7.4f},{4:7.4f}, {5:1.0f}".format("DT,TT,DR,TR,Y   :", DiT, TiT, DiR, TiR, Y))
         print("{0:12}".format(" --- Combined PBS + Pol.-filter ---"))
-        print("{0:12}{1:7.4f},{2:7.4f}, {3:7.4f},{4:7.4f}".format("DTa,TTa,DRa,TRa: ", DTa0, TTa0, DRa0, TRa0))
+        print("{0:12}{1:7.4f},{2:7.4f}, {3:7.4f},{4:7.4f}".format("DT,TT,DR,TR     :", DTa0, TTa0, DRa0, TRa0))
         print()
         print("Rotation Error Epsilon For Normal Measurements = ", RotationErrorEpsilonForNormalMeasurements)
-        #print ('LocC = ', LocC, Loc[LocC], '; TypeC = ',TypeC, Type[TypeC])
-        print(Type[TypeC], Loc[LocC], "; Parallel signal detected in", dY[int(Y+1)])
+        print(Type[TypeC], Loc[LocC])
+        print("Parallel signal detected in", dY[int(Y+1)])
+        print("RS_RP_depend_on_TS_TP = ", RS_RP_depend_on_TS_TP)
         #  end of print actual system parameters
         # ******************************************************************************
 
@@ -873,7 +879,8 @@
             K0List[i] = K0
             LDRsimxList[i] = LDRsimx
 
-        print("{0:8},{1:8},{2:8},{3:8},{4:9},{5:9},{6:9}".format(" GR", " GT", " HR", " HT", " K(0.004)", " K(0.2)", " K(0.45)"))
+        print('========================================================================')
+        print("{0:8},{1:8},{2:8},{3:8},{4:9},{5:8},{6:9}".format(" GR", " GT", " HR", " HT", "  K(0.004)", " K(0.2)", "  K(0.45)"))
         print("{0:8.5f},{1:8.5f},{2:8.5f},{3:8.5f},{4:9.5f},{5:9.5f},{6:9.5f}".format(GR0, GT0, HR0, HT0, K0List[0], K0List[1], K0List[2]))
         print('========================================================================')
 
@@ -884,7 +891,7 @@
             print("{0:9.5f},{1:9.5f},{2:9.5f}".format(LDRtrue, LDRsimx, LDRCorr))
 
 
-file = open('output_' + LID + '.dat', 'r')
+file = open('output_files\output_' + LID + '.dat', 'r')
 print (file.read())
 file.close()
 
@@ -904,7 +911,7 @@
 # --- CALC again truth with LDRCal0 to reset all 0-values
 GT0, HT0, GR0, HR0, K0, Eta0, LDRsimx, LDRCorr, DTa0, DRa0, TTa0, TRa0, F11sim0 = Calc(RotL0, RotE0, RetE0, DiE0, RotO0, RetO0, DiO0, RotC0, RetC0, DiC0, TP0, TS0, RP0, RS0, ERaT0, RotaT0, RetT0, ERaR0, RotaR0, RetR0, LDRCal0)
 
-# --- Start Errors calculation
+# --- Start Errors calculation with variable parameters ------------------------------------------------------------------
 
 iN = -1
 N = ((nRotL*2+1)*
@@ -1092,10 +1099,11 @@
             ZiC = (1. - DiC**2)**0.5
             WiC = (1. - ZiC*CosC)
 
-            #For POLLY_XT
             # analyser
-            #RS = 1 - TS
-            #RP = 1 - TP
+            #For POLLY_XTs
+            if(RS_RP_depend_on_TS_TP):
+                RS = 1 - TS
+                RP = 1 - TP
             TiT = 0.5 * (TP + TS)
             DiT = (TP-TS)/(TP+TS)
             ZiT = (1. - DiT**2)**0.5
@@ -1797,7 +1805,7 @@
 
 # --- Save LDRmin, LDRmax to file
 # http://stackoverflow.com/questions/4675728/redirect-stdout-to-a-file-in-python
-with open('LDR_min_max_ver7_' + LID + '.dat', 'w') as f:
+with open('LDR_min_max_' + LID + '.dat', 'w') as f:
     with redirect_stdout(f):
         print(LID)
         print("LDRtrue, LDRmin, LDRmax")

mercurial