lidar_correction_ghk.py

Mon, 14 Nov 2016 16:31:32 +0100

author
Volker Freudenthaler <volker.freudenthaler@lmu.de>
date
Mon, 14 Nov 2016 16:31:32 +0100
changeset 10
a69e0c8ca55c
parent 9
349178d9e658
child 11
453b23dd7f94
permissions
-rw-r--r--

Code under MIT licence removed and replaced by
def user_yes_no_query(question)

ulalume3@0 1 # -*- coding: utf-8 -*-
ulalume3@0 2 """
ulalume3@0 3 Copyright 2016 Volker Freudenthaler
ulalume3@0 4
ulalume3@0 5 Licensed under the EUPL, Version 1.1 only (the "Licence").
ulalume3@0 6
ulalume3@0 7 You may not use this work except in compliance with the Licence.
ulalume3@0 8 A copy of the licence is distributed with the code. Alternatively, you may obtain
ulalume3@0 9 a copy of the Licence at:
ulalume3@0 10
ulalume3@0 11 https://joinup.ec.europa.eu/community/eupl/og_page/eupl
ulalume3@0 12
ulalume3@0 13 Unless required by applicable law or agreed to in writing, software distributed
ulalume3@0 14 under the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS
ulalume3@0 15 OF ANY KIND, either express or implied. See the Licence for the specific language governing
ulalume3@0 16 permissions and limitations under the Licence.
ulalume3@0 17
ulalume3@0 18 Equation reference: http://www.atmos-meas-tech-discuss.net/amt-2015-338/amt-2015-338.pdf
ulalume3@0 19 With equations code from Appendix C
volker@7 20 Python 3.4.2 ,,
ulalume3@0 21 """
ulalume3@0 22 #!/usr/bin/env python3
ulalume3@0 23 from __future__ import print_function
ulalume3@0 24 #import math
ulalume3@0 25 import numpy as np
ulalume3@0 26 import sys
ulalume3@0 27 import os
ulalume3@0 28
ulalume3@0 29 #import seaborn as sns
ulalume3@0 30 import matplotlib.pyplot as plt
ulalume3@0 31 from time import clock
ulalume3@0 32
binietoglou@8 33
binietoglou@8 34
ulalume3@0 35 #from matplotlib.backends.backend_pdf import PdfPages
ulalume3@0 36 #pdffile = '{}.pdf'.format('path')
ulalume3@0 37 #pp = PdfPages(pdffile)
ulalume3@0 38 ## pp.savefig can be called multiple times to save to multiple pages
ulalume3@0 39 #pp.savefig()
ulalume3@0 40 #pp.close()
ulalume3@0 41
ulalume3@0 42 from contextlib import contextmanager
ulalume3@0 43 @contextmanager
ulalume3@0 44 def redirect_stdout(new_target):
ulalume3@0 45 old_target, sys.stdout = sys.stdout, new_target # replace sys.stdout
ulalume3@0 46 try:
ulalume3@0 47 yield new_target # run some code with the replaced stdout
ulalume3@0 48 finally:
ulalume3@0 49 sys.stdout.flush()
ulalume3@0 50 sys.stdout = old_target # restore to the previous value
ulalume3@0 51 '''
ulalume3@0 52 real_raw_input = vars(__builtins__).get('raw_input',input)
ulalume3@0 53 '''
ulalume3@0 54 try:
ulalume3@0 55 import __builtin__
ulalume3@0 56 input = getattr(__builtin__, 'raw_input')
ulalume3@0 57 except (ImportError, AttributeError):
ulalume3@0 58 pass
ulalume3@0 59
ulalume3@0 60 from distutils.util import strtobool
ulalume3@0 61 def user_yes_no_query(question):
ulalume3@0 62 sys.stdout.write('%s [y/n]\n' % question)
ulalume3@0 63 while True:
ulalume3@0 64 try:
ulalume3@0 65 return strtobool(input().lower())
ulalume3@0 66 except ValueError:
ulalume3@0 67 sys.stdout.write('Please respond with \'y\' or \'n\'.\n')
ulalume3@0 68
ulalume3@0 69 #if user_yes_no_query('want to exit?') == 1: sys.exit()
ulalume3@0 70
ulalume3@0 71 abspath = os.path.abspath(__file__)
ulalume3@0 72 dname = os.path.dirname(abspath)
ulalume3@0 73 fname = os.path.basename(abspath)
ulalume3@0 74 os.chdir(dname)
ulalume3@0 75
ulalume3@0 76 #PrintToOutputFile = True
ulalume3@0 77
ulalume3@0 78 sqr05 = 0.5**0.5
ulalume3@0 79
ulalume3@0 80 # ---- Initial definition of variables; the actual values will be read in with exec(open('./optic_input.py').read()) below
ulalume3@0 81 LID = "internal"
ulalume3@0 82 EID = "internal"
ulalume3@0 83 # --- IL Laser IL and +-Uncertainty
ulalume3@0 84 bL = 1. #degree of linear polarization; default 1
ulalume3@0 85 RotL, dRotL, nRotL = 0.0, 0.0, 1 #alpha; rotation of laser polarization in degrees; default 0
ulalume3@0 86 # --- ME Emitter and +-Uncertainty
ulalume3@0 87 DiE, dDiE, nDiE = 0., 0.00, 1 # Diattenuation
ulalume3@0 88 TiE = 1. # Unpolarized transmittance
ulalume3@0 89 RetE, dRetE, nRetE = 0., 180.0, 0 # Retardance in degrees
ulalume3@0 90 RotE, dRotE, nRotE = 0., 0.0, 0 # beta: Rotation of optical element in degrees
ulalume3@0 91 # --- MO Receiver Optics including telescope
ulalume3@0 92 DiO, dDiO, nDiO = -0.055, 0.003, 1
ulalume3@0 93 TiO = 0.9
ulalume3@0 94 RetO, dRetO, nRetO = 0., 180.0, 2
ulalume3@0 95 RotO, dRotO, nRotO = 0., 0.1, 1 #gamma
ulalume3@0 96 # --- PBS MT transmitting path defined with (TS,TP); and +-Uncertainty
ulalume3@0 97 TP, dTP, nTP = 0.98, 0.02, 1
ulalume3@0 98 TS, dTS, nTS = 0.001, 0.001, 1
ulalume3@0 99 TiT = 0.5 * (TP + TS)
ulalume3@0 100 DiT = (TP-TS)/(TP+TS)
ulalume3@0 101 # PolFilter
ulalume3@0 102 RetT, dRetT, nRetT = 0., 180., 0
ulalume3@0 103 ERaT, dERaT, nERaT = 0.001, 0.001, 1
ulalume3@0 104 RotaT, dRotaT, nRotaT = 0., 3., 1
ulalume3@0 105 DaT = (1-ERaT)/(1+ERaT)
ulalume3@0 106 TaT = 0.5*(1+ERaT)
ulalume3@0 107 # --- PBS MR reflecting path defined with (RS,RP); and +-Uncertainty
ulalume3@0 108 RS, dRS, nRS = 1 - TS, 0., 0
ulalume3@0 109 RP, dRP, nRP = 1 - TP, 0., 0
ulalume3@0 110 TiR = 0.5 * (RP + RS)
ulalume3@0 111 DiR = (RP-RS)/(RP+RS)
ulalume3@0 112 # PolFilter
ulalume3@0 113 RetR, dRetR, nRetR = 0., 180., 0
ulalume3@0 114 ERaR, dERaR, nERaR = 0.001, 0.001, 1
ulalume3@0 115 RotaR,dRotaR,nRotaR = 90., 3., 1
ulalume3@0 116 DaR = (1-ERaR)/(1+ERaR)
ulalume3@0 117 TaR = 0.5*(1+ERaR)
ulalume3@0 118
ulalume3@0 119 # Parellel signal detected in the transmitted channel => Y = 1, or in the reflected channel => Y = -1
ulalume3@0 120 Y = -1.
ulalume3@0 121
ulalume3@0 122 # Calibrator = type defined by matrix values
ulalume3@0 123 LocC = 4 # location of calibrator: behind laser = 1; behind emitter = 2; before receiver = 3; before PBS = 4
ulalume3@0 124
ulalume3@0 125 TypeC = 3 # linear polarizer calibrator
ulalume3@0 126 # example with extinction ratio 0.001
ulalume3@0 127 DiC, dDiC, nDiC = 1.0, 0., 0 # ideal 1.0
ulalume3@0 128 TiC = 0.5 # ideal 0.5
ulalume3@0 129 RetC, dRetC, nRetC = 0., 0., 0
ulalume3@0 130 RotC, dRotC, nRotC = 0.0, 0.1, 0 #constant calibrator offset epsilon
ulalume3@0 131 RotationErrorEpsilonForNormalMeasurements = False # is in general False for TypeC == 3 calibrator
ulalume3@0 132
ulalume3@0 133 # Rotation error without calibrator: if False, then epsilon = 0 for normal measurements
ulalume3@0 134 RotationErrorEpsilonForNormalMeasurements = True
ulalume3@0 135
ulalume3@0 136 # LDRCal assumed atmospheric linear depolarization ratio during the calibration measurements (first guess)
ulalume3@0 137 LDRCal0,dLDRCal,nLDRCal= 0.25, 0.04, 1
ulalume3@0 138 LDRCal = LDRCal0
ulalume3@0 139 # measured LDRm will be corrected with calculated parameters
ulalume3@0 140 LDRmeas = 0.015
ulalume3@0 141 # LDRtrue for simulation of measurement => LDRsim
ulalume3@0 142 LDRtrue = 0.5
ulalume3@0 143 LDRtrue2 = 0.004
ulalume3@0 144
ulalume3@0 145 # Initialize other values to 0
ulalume3@0 146 ER, nER, dER = 0.001, 0, 0.001
ulalume3@0 147 K = 0.
ulalume3@0 148 Km = 0.
ulalume3@0 149 Kp = 0.
ulalume3@0 150 LDRcorr = 0.
ulalume3@0 151 Eta = 0.
ulalume3@0 152 Ir = 0.
ulalume3@0 153 It = 0.
ulalume3@0 154 h = 1.
ulalume3@0 155
ulalume3@0 156 Loc = ['', 'behind laser', 'behind emitter', 'before receiver', 'before PBS']
ulalume3@0 157 Type = ['', 'mechanical rotator', 'hwp rotator', 'linear polarizer', 'qwp rotator', 'circular polarizer', 'real HWP +-22.5°']
ulalume3@0 158 dY = ['reflected channel', '', 'transmitted channel']
ulalume3@0 159
ulalume3@0 160 # end of initial definition of variables
ulalume3@0 161 # *******************************************************************************************************************************
ulalume3@0 162
ulalume3@0 163 # --- Read actual lidar system parameters from ./optic_input.py (must be in the same directory)
ulalume3@0 164
ulalume3@0 165 #InputFile = 'optic_input_ver6e_POLIS_355.py'
ulalume3@0 166 #InputFile = 'optic_input_ver6e_POLIS_355_JA.py'
ulalume3@0 167 #InputFile = 'optic_input_ver6c_POLIS_532.py'
ulalume3@0 168 #InputFile = 'optic_input_ver6e_POLIS_532.py'
ulalume3@0 169 #InputFile = 'optic_input_ver8c_POLIS_532.py'
ulalume3@0 170 #InputFile = 'optic_input_ver6e_MUSA.py'
ulalume3@0 171 #InputFile = 'optic_input_ver6e_MUSA_JA.py'
ulalume3@0 172 #InputFile = 'optic_input_ver6e_PollyXTSea.py'
ulalume3@0 173 #InputFile = 'optic_input_ver6e_PollyXTSea_JA.py'
ulalume3@0 174 #InputFile = 'optic_input_ver6e_PollyXT_RALPH.py'
ulalume3@0 175 #InputFile = 'optic_input_ver8c_PollyXT_RALPH.py'
ulalume3@0 176 #InputFile = 'optic_input_ver8c_PollyXT_RALPH_2.py'
ulalume3@0 177 #InputFile = 'optic_input_ver8c_PollyXT_RALPH_3.py'
ulalume3@0 178 #InputFile = 'optic_input_ver8c_PollyXT_RALPH_4.py'
ulalume3@0 179 #InputFile = 'optic_input_ver8c_PollyXT_RALPH_5.py'
ulalume3@0 180 #InputFile = 'optic_input_ver8c_PollyXT_RALPH_6.py'
ulalume3@0 181 InputFile = 'optic_input_ver8c_PollyXT_RALPH_7.py'
ulalume3@0 182 #InputFile = 'optic_input_ver8a_MOHP_DPL_355.py'
ulalume3@0 183 #InputFile = 'optic_input_ver9_MOHP_DPL_355.py'
ulalume3@0 184 #InputFile = 'optic_input_ver6e_RALI.py'
ulalume3@0 185 #InputFile = 'optic_input_ver6e_RALI_JA.py'
ulalume3@0 186 #InputFile = 'optic_input_ver6e_RALI_new.py'
ulalume3@0 187 #InputFile = 'optic_input_ver6e_RALI_act.py'
ulalume3@0 188 #InputFile = 'optic_input_ver6e_MULHACEN.py'
ulalume3@0 189 #InputFile = 'optic_input_ver6e_MULHACEN_JA.py'
ulalume3@0 190 #InputFile = 'optic_input_ver6e-IPRAL.py'
ulalume3@0 191 #InputFile = 'optic_input_ver6e-IPRAL_JA.py'
ulalume3@0 192 #InputFile = 'optic_input_ver6e-LB21.py'
ulalume3@0 193 #InputFile = 'optic_input_ver6e-LB21_JA.py'
ulalume3@0 194 #InputFile = 'optic_input_ver6e_Bertha_b_355.py'
ulalume3@0 195 #InputFile = 'optic_input_ver6e_Bertha_b_532.py'
ulalume3@0 196 #InputFile = 'optic_input_ver6e_Bertha_b_1064.py'
ulalume3@0 197
ulalume3@0 198 '''
ulalume3@0 199 print("From ", dname)
ulalume3@0 200 print("Running ", fname)
ulalume3@0 201 print("Reading input file ", InputFile, " for")
ulalume3@0 202 '''
ulalume3@0 203 input_path = os.path.join('.', 'system_settings', InputFile)
ulalume3@0 204 # this works with Python 2 - and 3?
ulalume3@0 205 exec(open(input_path).read(), globals())
ulalume3@0 206 # end of read actual system parameters
ulalume3@0 207
ulalume3@0 208 # --- Manual Parameter Change ---
ulalume3@0 209 # (use for quick parameter changes without changing the input file )
ulalume3@0 210 #DiO = 0.
ulalume3@0 211 #LDRtrue = 0.45
ulalume3@0 212 #LDRtrue2 = 0.004
ulalume3@0 213 #Y = -1
ulalume3@0 214 #LocC = 4 #location of calibrator: 1 = behind laser; 2 = behind emitter; 3 = before receiver; 4 = before PBS
ulalume3@0 215 ##TypeC = 6 Don't change the TypeC here
ulalume3@0 216 #RotationErrorEpsilonForNormalMeasurements = True
ulalume3@0 217 #LDRCal = 0.25
ulalume3@0 218 #bL = 0.8
ulalume3@0 219 ## --- Errors
ulalume3@0 220 RotL0, dRotL, nRotL = RotL, dRotL, nRotL
ulalume3@0 221
ulalume3@0 222 DiE0, dDiE, nDiE = DiE, dDiE, nDiE
ulalume3@0 223 RetE0, dRetE, nRetE = RetE, dRetE, nRetE
ulalume3@0 224 RotE0, dRotE, nRotE = RotE, dRotE, nRotE
ulalume3@0 225
ulalume3@0 226 DiO0, dDiO, nDiO = DiO, dDiO, nDiO
ulalume3@0 227 RetO0, dRetO, nRetO = RetO, dRetO, nRetO
ulalume3@0 228 RotO0, dRotO, nRotO = RotO, dRotO, nRotO
ulalume3@0 229
ulalume3@0 230 DiC0, dDiC, nDiC = DiC, dDiC, nDiC
ulalume3@0 231 RetC0, dRetC, nRetC = RetC, dRetC, nRetC
ulalume3@0 232 RotC0, dRotC, nRotC = RotC, dRotC, nRotC
ulalume3@0 233
ulalume3@0 234 TP0, dTP, nTP = TP, dTP, nTP
ulalume3@0 235 TS0, dTS, nTS = TS, dTS, nTS
ulalume3@0 236 RetT0, dRetT, nRetT = RetT, dRetT, nRetT
ulalume3@0 237
ulalume3@0 238 ERaT0, dERaT, nERaT = ERaT, dERaT, nERaT
ulalume3@0 239 RotaT0,dRotaT,nRotaT= RotaT,dRotaT,nRotaT
ulalume3@0 240
ulalume3@0 241 RP0, dRP, nRP = RP, dRP, nRP
ulalume3@0 242 RS0, dRS, nRS = RS, dRS, nRS
ulalume3@0 243 RetR0, dRetR, nRetR = RetR, dRetR, nRetR
ulalume3@0 244
ulalume3@0 245 ERaR0, dERaR, nERaR = ERaR, dERaR, nERaR
ulalume3@0 246 RotaR0,dRotaR,nRotaR= RotaR,dRotaR,nRotaR
ulalume3@0 247
ulalume3@0 248 LDRCal0,dLDRCal,nLDRCal=LDRCal,dLDRCal,nLDRCal
ulalume3@0 249 #LDRCal0,dLDRCal,nLDRCal=LDRCal,dLDRCal,0
ulalume3@0 250 # ---------- End of manual parameter change
ulalume3@0 251
ulalume3@0 252 RotL, RotE, RetE, DiE, RotO, RetO, DiO, RotC, RetC, DiC = RotL0, RotE0, RetE0, DiE0, RotO0, RetO0, DiO0, RotC0, RetC0, DiC0
ulalume3@0 253 TP, TS, RP, RS, ERaT, RotaT, RetT, ERaR, RotaR, RetR = TP0, TS0, RP0, RS0 , ERaT0, RotaT0, RetT0, ERaR0, RotaR0, RetR0
ulalume3@0 254 LDRCal = LDRCal0
ulalume3@0 255 DTa0, TTa0, DRa0, TRa0, LDRsimx, LDRCorr = 0,0,0,0,0,0
ulalume3@0 256
ulalume3@0 257 TiT = 0.5 * (TP + TS)
ulalume3@0 258 DiT = (TP-TS)/(TP+TS)
ulalume3@0 259 ZiT = (1. - DiT**2)**0.5
ulalume3@0 260 TiR = 0.5 * (RP + RS)
ulalume3@0 261 DiR = (RP-RS)/(RP+RS)
ulalume3@0 262 ZiR = (1. - DiR**2)**0.5
ulalume3@0 263
ulalume3@0 264 # --------------------------------------------------------
ulalume3@0 265 def Calc(RotL, RotE, RetE, DiE, RotO, RetO, DiO, RotC, RetC, DiC, TP, TS, RP, RS, ERaT, RotaT, RetT, ERaR, RotaR, RetR, LDRCal):
ulalume3@0 266 # ---- Do the calculations of bra-ket vectors
ulalume3@0 267 h = -1. if TypeC == 2 else 1
ulalume3@0 268 # from input file: assumed LDRCal for calibration measurements
ulalume3@0 269 aCal = (1.-LDRCal)/(1+LDRCal)
ulalume3@0 270 # from input file: measured LDRm and true LDRtrue, LDRtrue2 =>
ulalume3@0 271 #ameas = (1.-LDRmeas)/(1+LDRmeas)
ulalume3@0 272 atrue = (1.-LDRtrue)/(1+LDRtrue)
ulalume3@0 273 #atrue2 = (1.-LDRtrue2)/(1+LDRtrue2)
ulalume3@0 274
ulalume3@0 275 # angles of emitter and laser and calibrator and receiver optics
ulalume3@0 276 # RotL = alpha, RotE = beta, RotO = gamma, RotC = epsilon
ulalume3@0 277 S2a = np.sin(2*np.deg2rad(RotL))
ulalume3@0 278 C2a = np.cos(2*np.deg2rad(RotL))
ulalume3@0 279 S2b = np.sin(2*np.deg2rad(RotE))
ulalume3@0 280 C2b = np.cos(2*np.deg2rad(RotE))
ulalume3@0 281 S2ab = np.sin(np.deg2rad(2*RotL-2*RotE))
ulalume3@0 282 C2ab = np.cos(np.deg2rad(2*RotL-2*RotE))
ulalume3@0 283 S2g = np.sin(np.deg2rad(2*RotO))
ulalume3@0 284 C2g = np.cos(np.deg2rad(2*RotO))
ulalume3@0 285
ulalume3@0 286 # Laser with Degree of linear polarization DOLP = bL
ulalume3@0 287 IinL = 1.
ulalume3@0 288 QinL = bL
ulalume3@0 289 UinL = 0.
ulalume3@0 290 VinL = (1. - bL**2)**0.5
ulalume3@0 291
ulalume3@0 292 # Stokes Input Vector rotation Eq. E.4
ulalume3@0 293 A = C2a*QinL - S2a*UinL
ulalume3@0 294 B = S2a*QinL + C2a*UinL
ulalume3@0 295 # Stokes Input Vector rotation Eq. E.9
ulalume3@0 296 C = C2ab*QinL - S2ab*UinL
ulalume3@0 297 D = S2ab*QinL + C2ab*UinL
ulalume3@0 298
ulalume3@0 299 # emitter optics
ulalume3@0 300 CosE = np.cos(np.deg2rad(RetE))
ulalume3@0 301 SinE = np.sin(np.deg2rad(RetE))
ulalume3@0 302 ZiE = (1. - DiE**2)**0.5
ulalume3@0 303 WiE = (1. - ZiE*CosE)
ulalume3@0 304
ulalume3@0 305 # Stokes Input Vector after emitter optics equivalent to Eq. E.9 with already rotated input vector from Eq. E.4
ulalume3@0 306 # b = beta
ulalume3@0 307 IinE = (IinL + DiE*C)
ulalume3@0 308 QinE = (C2b*DiE*IinL + A + S2b*(WiE*D - ZiE*SinE*VinL))
ulalume3@0 309 UinE = (S2b*DiE*IinL + B - C2b*(WiE*D - ZiE*SinE*VinL))
ulalume3@0 310 VinE = (-ZiE*SinE*D + ZiE*CosE*VinL)
ulalume3@0 311
ulalume3@0 312 # Stokes Input Vector before receiver optics Eq. E.19 (after atmosphere F)
ulalume3@0 313 IinF = IinE
ulalume3@0 314 QinF = aCal*QinE
ulalume3@0 315 UinF = -aCal*UinE
ulalume3@0 316 VinF = (1.-2.*aCal)*VinE
ulalume3@0 317
ulalume3@0 318 # receiver optics
ulalume3@0 319 CosO = np.cos(np.deg2rad(RetO))
ulalume3@0 320 SinO = np.sin(np.deg2rad(RetO))
ulalume3@0 321 ZiO = (1. - DiO**2)**0.5
ulalume3@0 322 WiO = (1. - ZiO*CosO)
ulalume3@0 323
ulalume3@0 324 # calibrator
ulalume3@0 325 CosC = np.cos(np.deg2rad(RetC))
ulalume3@0 326 SinC = np.sin(np.deg2rad(RetC))
ulalume3@0 327 ZiC = (1. - DiC**2)**0.5
ulalume3@0 328 WiC = (1. - ZiC*CosC)
ulalume3@0 329
ulalume3@0 330 # Stokes Input Vector before the polarising beam splitter Eq. E.31
ulalume3@0 331 A = C2g*QinE - S2g*UinE
ulalume3@0 332 B = S2g*QinE + C2g*UinE
ulalume3@0 333
ulalume3@0 334 IinP = (IinE + DiO*aCal*A)
ulalume3@0 335 QinP = (C2g*DiO*IinE + aCal*QinE - S2g*(WiO*aCal*B + ZiO*SinO*(1-2*aCal)*VinE))
ulalume3@0 336 UinP = (S2g*DiO*IinE - aCal*UinE + C2g*(WiO*aCal*B + ZiO*SinO*(1-2*aCal)*VinE))
ulalume3@0 337 VinP = (ZiO*SinO*aCal*B + ZiO*CosO*(1-2*aCal)*VinE)
ulalume3@0 338
ulalume3@0 339 #-------------------------
ulalume3@0 340 # F11 assuemd to be = 1 => measured: F11m = IinP / IinE with atrue
ulalume3@0 341 #F11sim = TiO*(IinE + DiO*atrue*A)/IinE
ulalume3@0 342 #-------------------------
ulalume3@0 343
ulalume3@0 344 # For PollyXT
ulalume3@0 345 # analyser
ulalume3@0 346 #RS = 1 - TS
ulalume3@0 347 #RP = 1 - TP
ulalume3@0 348
ulalume3@0 349 TiT = 0.5 * (TP + TS)
ulalume3@0 350 DiT = (TP-TS)/(TP+TS)
ulalume3@0 351 ZiT = (1. - DiT**2)**0.5
ulalume3@0 352 TiR = 0.5 * (RP + RS)
ulalume3@0 353 DiR = (RP-RS)/(RP+RS)
ulalume3@0 354 ZiR = (1. - DiR**2)**0.5
ulalume3@0 355 CosT = np.cos(np.deg2rad(RetT))
ulalume3@0 356 SinT = np.sin(np.deg2rad(RetT))
ulalume3@0 357 CosR = np.cos(np.deg2rad(RetR))
ulalume3@0 358 SinR = np.sin(np.deg2rad(RetR))
ulalume3@0 359
ulalume3@0 360 DaT = (1-ERaT)/(1+ERaT)
ulalume3@0 361 DaR = (1-ERaR)/(1+ERaR)
ulalume3@0 362 TaT = 0.5*(1+ERaT)
ulalume3@0 363 TaR = 0.5*(1+ERaR)
ulalume3@0 364
ulalume3@0 365 S2aT = np.sin(np.deg2rad(h*2*RotaT))
ulalume3@0 366 C2aT = np.cos(np.deg2rad(2*RotaT))
ulalume3@0 367 S2aR = np.sin(np.deg2rad(h*2*RotaR))
ulalume3@0 368 C2aR = np.cos(np.deg2rad(2*RotaR))
ulalume3@0 369
ulalume3@0 370 # Aanalyzer As before the PBS Eq. D.5
ulalume3@0 371 ATP1 = (1+C2aT*DaT*DiT)
ulalume3@0 372 ATP2 = Y*(DiT+C2aT*DaT)
ulalume3@0 373 ATP3 = Y*S2aT*DaT*ZiT*CosT
ulalume3@0 374 ATP4 = S2aT*DaT*ZiT*SinT
ulalume3@0 375 ATP = np.array([ATP1,ATP2,ATP3,ATP4])
ulalume3@0 376
ulalume3@0 377 ARP1 = (1+C2aR*DaR*DiR)
ulalume3@0 378 ARP2 = Y*(DiR+C2aR*DaR)
ulalume3@0 379 ARP3 = Y*S2aR*DaR*ZiR*CosR
ulalume3@0 380 ARP4 = S2aR*DaR*ZiR*SinR
ulalume3@0 381 ARP = np.array([ARP1,ARP2,ARP3,ARP4])
ulalume3@0 382
ulalume3@0 383 DTa = ATP2*Y/ATP1
ulalume3@0 384 DRa = ARP2*Y/ARP1
ulalume3@0 385
ulalume3@0 386 # ---- Calculate signals and correction parameters for diffeent locations and calibrators
ulalume3@0 387 if LocC == 4: # Calibrator before the PBS
ulalume3@0 388 #print("Calibrator location not implemented yet")
ulalume3@0 389
ulalume3@0 390 #S2ge = np.sin(np.deg2rad(2*RotO + h*2*RotC))
ulalume3@0 391 #C2ge = np.cos(np.deg2rad(2*RotO + h*2*RotC))
ulalume3@0 392 S2e = np.sin(np.deg2rad(h*2*RotC))
ulalume3@0 393 C2e = np.cos(np.deg2rad(2*RotC))
ulalume3@0 394 # rotated AinP by epsilon Eq. C.3
ulalume3@0 395 ATP2e = C2e*ATP2 + S2e*ATP3
ulalume3@0 396 ATP3e = C2e*ATP3 - S2e*ATP2
ulalume3@0 397 ARP2e = C2e*ARP2 + S2e*ARP3
ulalume3@0 398 ARP3e = C2e*ARP3 - S2e*ARP2
ulalume3@0 399 ATPe = np.array([ATP1,ATP2e,ATP3e,ATP4])
ulalume3@0 400 ARPe = np.array([ARP1,ARP2e,ARP3e,ARP4])
ulalume3@0 401 # Stokes Input Vector before the polarising beam splitter Eq. E.31
ulalume3@0 402 A = C2g*QinE - S2g*UinE
ulalume3@0 403 B = S2g*QinE + C2g*UinE
ulalume3@0 404 #C = (WiO*aCal*B + ZiO*SinO*(1-2*aCal)*VinE)
ulalume3@0 405 Co = ZiO*SinO*VinE
ulalume3@0 406 Ca = (WiO*B - 2*ZiO*SinO*VinE)
ulalume3@0 407 #C = Co + aCal*Ca
ulalume3@0 408 #IinP = (IinE + DiO*aCal*A)
ulalume3@0 409 #QinP = (C2g*DiO*IinE + aCal*QinE - S2g*C)
ulalume3@0 410 #UinP = (S2g*DiO*IinE - aCal*UinE + C2g*C)
ulalume3@0 411 #VinP = (ZiO*SinO*aCal*B + ZiO*CosO*(1-2*aCal)*VinE)
ulalume3@0 412 IinPo = IinE
ulalume3@0 413 QinPo = (C2g*DiO*IinE - S2g*Co)
ulalume3@0 414 UinPo = (S2g*DiO*IinE + C2g*Co)
ulalume3@0 415 VinPo = ZiO*CosO*VinE
ulalume3@0 416
ulalume3@0 417 IinPa = DiO*A
ulalume3@0 418 QinPa = QinE - S2g*Ca
ulalume3@0 419 UinPa = -UinE + C2g*Ca
ulalume3@0 420 VinPa = ZiO*(SinO*B - 2*CosO*VinE)
ulalume3@0 421
ulalume3@0 422 IinP = IinPo + aCal*IinPa
ulalume3@0 423 QinP = QinPo + aCal*QinPa
ulalume3@0 424 UinP = UinPo + aCal*UinPa
ulalume3@0 425 VinP = VinPo + aCal*VinPa
ulalume3@0 426 # Stokes Input Vector before the polarising beam splitter rotated by epsilon Eq. C.3
ulalume3@0 427 #QinPe = C2e*QinP + S2e*UinP
ulalume3@0 428 #UinPe = C2e*UinP - S2e*QinP
ulalume3@0 429 QinPoe = C2e*QinPo + S2e*UinPo
ulalume3@0 430 UinPoe = C2e*UinPo - S2e*QinPo
ulalume3@0 431 QinPae = C2e*QinPa + S2e*UinPa
ulalume3@0 432 UinPae = C2e*UinPa - S2e*QinPa
ulalume3@0 433 QinPe = C2e*QinP + S2e*UinP
ulalume3@0 434 UinPe = C2e*UinP - S2e*QinP
ulalume3@0 435
ulalume3@0 436 # Calibration signals and Calibration correction K from measurements with LDRCal / aCal
ulalume3@0 437 if (TypeC == 2) or (TypeC == 1): # rotator calibration Eq. C.4
ulalume3@0 438 # parameters for calibration with aCal
ulalume3@0 439 AT = ATP1*IinP + h*ATP4*VinP
ulalume3@0 440 BT = ATP3e*QinP - h*ATP2e*UinP
ulalume3@0 441 AR = ARP1*IinP + h*ARP4*VinP
ulalume3@0 442 BR = ARP3e*QinP - h*ARP2e*UinP
ulalume3@0 443 # Correction paremeters for normal measurements; they are independent of LDR
ulalume3@0 444 if (not RotationErrorEpsilonForNormalMeasurements): # calibrator taken out
ulalume3@0 445 IS1 = np.array([IinPo,QinPo,UinPo,VinPo])
ulalume3@0 446 IS2 = np.array([IinPa,QinPa,UinPa,VinPa])
ulalume3@0 447 GT = np.dot(ATP,IS1)
ulalume3@0 448 GR = np.dot(ARP,IS1)
ulalume3@0 449 HT = np.dot(ATP,IS2)
ulalume3@0 450 HR = np.dot(ARP,IS2)
ulalume3@0 451 else:
ulalume3@0 452 IS1 = np.array([IinPo,QinPo,UinPo,VinPo])
ulalume3@0 453 IS2 = np.array([IinPa,QinPa,UinPa,VinPa])
ulalume3@0 454 GT = np.dot(ATPe,IS1)
ulalume3@0 455 GR = np.dot(ARPe,IS1)
ulalume3@0 456 HT = np.dot(ATPe,IS2)
ulalume3@0 457 HR = np.dot(ARPe,IS2)
ulalume3@0 458 elif (TypeC == 3) or (TypeC == 4): # linear polariser calibration Eq. C.5
ulalume3@0 459 # parameters for calibration with aCal
ulalume3@0 460 AT = ATP1*IinP + ATP3e*UinPe + ZiC*CosC*(ATP2e*QinPe + ATP4*VinP)
ulalume3@0 461 BT = DiC*(ATP1*UinPe + ATP3e*IinP) - ZiC*SinC*(ATP2e*VinP - ATP4*QinPe)
ulalume3@0 462 AR = ARP1*IinP + ARP3e*UinPe + ZiC*CosC*(ARP2e*QinPe + ARP4*VinP)
ulalume3@0 463 BR = DiC*(ARP1*UinPe + ARP3e*IinP) - ZiC*SinC*(ARP2e*VinP - ARP4*QinPe)
ulalume3@0 464 # Correction paremeters for normal measurements; they are independent of LDR
ulalume3@0 465 if (not RotationErrorEpsilonForNormalMeasurements): # calibrator taken out
ulalume3@0 466 IS1 = np.array([IinPo,QinPo,UinPo,VinPo])
ulalume3@0 467 IS2 = np.array([IinPa,QinPa,UinPa,VinPa])
ulalume3@0 468 GT = np.dot(ATP,IS1)
ulalume3@0 469 GR = np.dot(ARP,IS1)
ulalume3@0 470 HT = np.dot(ATP,IS2)
ulalume3@0 471 HR = np.dot(ARP,IS2)
ulalume3@0 472 else:
ulalume3@0 473 IS1e = np.array([IinPo+DiC*QinPoe,DiC*IinPo+QinPoe,ZiC*(CosC*UinPoe+SinC*VinPo),-ZiC*(SinC*UinPoe-CosC*VinPo)])
ulalume3@0 474 IS2e = np.array([IinPa+DiC*QinPae,DiC*IinPa+QinPae,ZiC*(CosC*UinPae+SinC*VinPa),-ZiC*(SinC*UinPae-CosC*VinPa)])
ulalume3@0 475 GT = np.dot(ATPe,IS1e)
ulalume3@0 476 GR = np.dot(ARPe,IS1e)
ulalume3@0 477 HT = np.dot(ATPe,IS2e)
ulalume3@0 478 HR = np.dot(ARPe,IS2e)
ulalume3@0 479 elif (TypeC == 6): # diattenuator calibration +-22.5° rotated_diattenuator_X22x5deg.odt
ulalume3@0 480 # parameters for calibration with aCal
ulalume3@0 481 AT = ATP1*IinP + sqr05*DiC*(ATP1*QinPe + ATP2e*IinP) + (1-0.5*WiC)*(ATP2e*QinPe + ATP3e*UinPe) + ZiC*(sqr05*SinC*(ATP3e*VinP-ATP4*UinPe) + ATP4*CosC*VinP)
ulalume3@0 482 BT = sqr05*DiC*(ATP1*UinPe + ATP3e*IinP) + 0.5*WiC*(ATP2e*UinPe + ATP3e*QinPe) - sqr05*ZiC*SinC*(ATP2e*VinP - ATP4*QinPe)
ulalume3@0 483 AR = ARP1*IinP + sqr05*DiC*(ARP1*QinPe + ARP2e*IinP) + (1-0.5*WiC)*(ARP2e*QinPe + ARP3e*UinPe) + ZiC*(sqr05*SinC*(ARP3e*VinP-ARP4*UinPe) + ARP4*CosC*VinP)
ulalume3@0 484 BR = sqr05*DiC*(ARP1*UinPe + ARP3e*IinP) + 0.5*WiC*(ARP2e*UinPe + ARP3e*QinPe) - sqr05*ZiC*SinC*(ARP2e*VinP - ARP4*QinPe)
ulalume3@0 485 # Correction paremeters for normal measurements; they are independent of LDR
ulalume3@0 486 if (not RotationErrorEpsilonForNormalMeasurements): # calibrator taken out
ulalume3@0 487 IS1 = np.array([IinPo,QinPo,UinPo,VinPo])
ulalume3@0 488 IS2 = np.array([IinPa,QinPa,UinPa,VinPa])
ulalume3@0 489 GT = np.dot(ATP,IS1)
ulalume3@0 490 GR = np.dot(ARP,IS1)
ulalume3@0 491 HT = np.dot(ATP,IS2)
ulalume3@0 492 HR = np.dot(ARP,IS2)
ulalume3@0 493 else:
ulalume3@0 494 IS1e = np.array([IinPo+DiC*QinPoe,DiC*IinPo+QinPoe,ZiC*(CosC*UinPoe+SinC*VinPo),-ZiC*(SinC*UinPoe-CosC*VinPo)])
ulalume3@0 495 IS2e = np.array([IinPa+DiC*QinPae,DiC*IinPa+QinPae,ZiC*(CosC*UinPae+SinC*VinPa),-ZiC*(SinC*UinPae-CosC*VinPa)])
ulalume3@0 496 GT = np.dot(ATPe,IS1e)
ulalume3@0 497 GR = np.dot(ARPe,IS1e)
ulalume3@0 498 HT = np.dot(ATPe,IS2e)
ulalume3@0 499 HR = np.dot(ARPe,IS2e)
ulalume3@0 500 else:
ulalume3@0 501 print("Calibrator not implemented yet")
ulalume3@0 502 sys.exit()
ulalume3@0 503
ulalume3@0 504 elif LocC == 3: # C before receiver optics Eq.57
ulalume3@0 505
ulalume3@0 506 #S2ge = np.sin(np.deg2rad(2*RotO - 2*RotC))
ulalume3@0 507 #C2ge = np.cos(np.deg2rad(2*RotO - 2*RotC))
ulalume3@0 508 S2e = np.sin(np.deg2rad(2*RotC))
ulalume3@0 509 C2e = np.cos(np.deg2rad(2*RotC))
ulalume3@0 510
ulalume3@0 511 # As with C before the receiver optics (rotated_diattenuator_X22x5deg.odt)
ulalume3@0 512 AF1 = np.array([1,C2g*DiO,S2g*DiO,0])
ulalume3@0 513 AF2 = np.array([C2g*DiO,1-S2g**2*WiO,S2g*C2g*WiO,-S2g*ZiO*SinO])
ulalume3@0 514 AF3 = np.array([S2g*DiO,S2g*C2g*WiO,1-C2g**2*WiO,C2g*ZiO*SinO])
ulalume3@0 515 AF4 = np.array([0,S2g*SinO,-C2g*SinO,CosO])
ulalume3@0 516
ulalume3@0 517 ATF = (ATP1*AF1+ATP2*AF2+ATP3*AF3+ATP4*AF4)
ulalume3@0 518 ARF = (ARP1*AF1+ARP2*AF2+ARP3*AF3+ARP4*AF4)
ulalume3@0 519 ATF2 = ATF[1]
ulalume3@0 520 ATF3 = ATF[2]
ulalume3@0 521 ARF2 = ARF[1]
ulalume3@0 522 ARF3 = ARF[2]
ulalume3@0 523
ulalume3@0 524 # rotated AinF by epsilon
ulalume3@0 525 ATF1 = ATF[0]
ulalume3@0 526 ATF4 = ATF[3]
ulalume3@0 527 ATF2e = C2e*ATF[1] + S2e*ATF[2]
ulalume3@0 528 ATF3e = C2e*ATF[2] - S2e*ATF[1]
ulalume3@0 529 ARF1 = ARF[0]
ulalume3@0 530 ARF4 = ARF[3]
ulalume3@0 531 ARF2e = C2e*ARF[1] + S2e*ARF[2]
ulalume3@0 532 ARF3e = C2e*ARF[2] - S2e*ARF[1]
ulalume3@0 533
ulalume3@0 534 ATFe = np.array([ATF1,ATF2e,ATF3e,ATF4])
ulalume3@0 535 ARFe = np.array([ARF1,ARF2e,ARF3e,ARF4])
ulalume3@0 536
ulalume3@0 537 QinEe = C2e*QinE + S2e*UinE
ulalume3@0 538 UinEe = C2e*UinE - S2e*QinE
ulalume3@0 539
ulalume3@0 540 # Stokes Input Vector before receiver optics Eq. E.19 (after atmosphere F)
ulalume3@0 541 IinF = IinE
ulalume3@0 542 QinF = aCal*QinE
ulalume3@0 543 UinF = -aCal*UinE
ulalume3@0 544 VinF = (1.-2.*aCal)*VinE
ulalume3@0 545
ulalume3@0 546 IinFo = IinE
ulalume3@0 547 QinFo = 0.
ulalume3@0 548 UinFo = 0.
ulalume3@0 549 VinFo = VinE
ulalume3@0 550
ulalume3@0 551 IinFa = 0.
ulalume3@0 552 QinFa = QinE
ulalume3@0 553 UinFa = -UinE
ulalume3@0 554 VinFa = -2.*VinE
ulalume3@0 555
ulalume3@0 556 # Stokes Input Vector before receiver optics rotated by epsilon Eq. C.3
ulalume3@0 557 QinFe = C2e*QinF + S2e*UinF
ulalume3@0 558 UinFe = C2e*UinF - S2e*QinF
ulalume3@0 559 QinFoe = C2e*QinFo + S2e*UinFo
ulalume3@0 560 UinFoe = C2e*UinFo - S2e*QinFo
ulalume3@0 561 QinFae = C2e*QinFa + S2e*UinFa
ulalume3@0 562 UinFae = C2e*UinFa - S2e*QinFa
ulalume3@0 563
ulalume3@0 564 # Calibration signals and Calibration correction K from measurements with LDRCal / aCal
ulalume3@0 565 if (TypeC == 2) or (TypeC == 1): # rotator calibration Eq. C.4
ulalume3@0 566 # parameters for calibration with aCal
ulalume3@0 567 AT = ATF1*IinF + ATF4*h*VinF
ulalume3@0 568 BT = ATF3e*QinF - ATF2e*h*UinF
ulalume3@0 569 AR = ARF1*IinF + ARF4*h*VinF
ulalume3@0 570 BR = ARF3e*QinF - ARF2e*h*UinF
ulalume3@0 571 # Correction paremeters for normal measurements; they are independent of LDR
ulalume3@0 572 if (not RotationErrorEpsilonForNormalMeasurements):
ulalume3@0 573 GT = ATF1*IinE + ATF4*VinE
ulalume3@0 574 GR = ARF1*IinE + ARF4*VinE
ulalume3@0 575 HT = ATF2*QinE - ATF3*UinE - ATF4*2*VinE
ulalume3@0 576 HR = ARF2*QinE - ARF3*UinE - ARF4*2*VinE
ulalume3@0 577 else:
ulalume3@0 578 GT = ATF1*IinE + ATF4*h*VinE
ulalume3@0 579 GR = ARF1*IinE + ARF4*h*VinE
ulalume3@0 580 HT = ATF2e*QinE - ATF3e*h*UinE - ATF4*h*2*VinE
ulalume3@0 581 HR = ARF2e*QinE - ARF3e*h*UinE - ARF4*h*2*VinE
ulalume3@0 582 elif (TypeC == 3) or (TypeC == 4): # linear polariser calibration Eq. C.5
ulalume3@0 583 # p = +45°, m = -45°
ulalume3@0 584 IF1e = np.array([IinF, ZiC*CosC*QinFe, UinFe, ZiC*CosC*VinF])
ulalume3@0 585 IF2e = np.array([DiC*UinFe, -ZiC*SinC*VinF, DiC*IinF, ZiC*SinC*QinFe])
ulalume3@0 586 AT = np.dot(ATFe,IF1e)
ulalume3@0 587 AR = np.dot(ARFe,IF1e)
ulalume3@0 588 BT = np.dot(ATFe,IF2e)
ulalume3@0 589 BR = np.dot(ARFe,IF2e)
ulalume3@0 590
ulalume3@0 591 # Correction paremeters for normal measurements; they are independent of LDR --- the same as for TypeC = 6
ulalume3@0 592 if (not RotationErrorEpsilonForNormalMeasurements): # calibrator taken out
ulalume3@0 593 IS1 = np.array([IinE,0,0,VinE])
ulalume3@0 594 IS2 = np.array([0,QinE,-UinE,-2*VinE])
ulalume3@0 595 GT = np.dot(ATF,IS1)
ulalume3@0 596 GR = np.dot(ARF,IS1)
ulalume3@0 597 HT = np.dot(ATF,IS2)
ulalume3@0 598 HR = np.dot(ARF,IS2)
ulalume3@0 599 else:
ulalume3@0 600 IS1e = np.array([IinFo+DiC*QinFoe,DiC*IinFo+QinFoe,ZiC*(CosC*UinFoe+SinC*VinFo),-ZiC*(SinC*UinFoe-CosC*VinFo)])
ulalume3@0 601 IS2e = np.array([IinFa+DiC*QinFae,DiC*IinFa+QinFae,ZiC*(CosC*UinFae+SinC*VinFa),-ZiC*(SinC*UinFae-CosC*VinFa)])
ulalume3@0 602 GT = np.dot(ATFe,IS1e)
ulalume3@0 603 GR = np.dot(ARFe,IS1e)
ulalume3@0 604 HT = np.dot(ATFe,IS2e)
ulalume3@0 605 HR = np.dot(ARFe,IS2e)
ulalume3@0 606
ulalume3@0 607 elif (TypeC == 6): # diattenuator calibration +-22.5° rotated_diattenuator_X22x5deg.odt
ulalume3@0 608 # parameters for calibration with aCal
ulalume3@0 609 IF1e = np.array([IinF+sqr05*DiC*QinFe, sqr05*DiC*IinF+(1-0.5*WiC)*QinFe, (1-0.5*WiC)*UinFe+sqr05*ZiC*SinC*VinF, -sqr05*ZiC*SinC*UinFe+ZiC*CosC*VinF])
ulalume3@0 610 IF2e = np.array([sqr05*DiC*UinFe, 0.5*WiC*UinFe-sqr05*ZiC*SinC*VinF, sqr05*DiC*IinF+0.5*WiC*QinFe, sqr05*ZiC*SinC*QinFe])
ulalume3@0 611 AT = np.dot(ATFe,IF1e)
ulalume3@0 612 AR = np.dot(ARFe,IF1e)
ulalume3@0 613 BT = np.dot(ATFe,IF2e)
ulalume3@0 614 BR = np.dot(ARFe,IF2e)
ulalume3@0 615
ulalume3@0 616 # Correction paremeters for normal measurements; they are independent of LDR
ulalume3@0 617 if (not RotationErrorEpsilonForNormalMeasurements): # calibrator taken out
ulalume3@0 618 #IS1 = np.array([IinE,0,0,VinE])
ulalume3@0 619 #IS2 = np.array([0,QinE,-UinE,-2*VinE])
ulalume3@0 620 IS1 = np.array([IinFo,0,0,VinFo])
ulalume3@0 621 IS2 = np.array([0,QinFa,UinFa,VinFa])
ulalume3@0 622 GT = np.dot(ATF,IS1)
ulalume3@0 623 GR = np.dot(ARF,IS1)
ulalume3@0 624 HT = np.dot(ATF,IS2)
ulalume3@0 625 HR = np.dot(ARF,IS2)
ulalume3@0 626 else:
ulalume3@0 627 IS1e = np.array([IinFo+DiC*QinFoe,DiC*IinFo+QinFoe,ZiC*(CosC*UinFoe+SinC*VinFo),-ZiC*(SinC*UinFoe-CosC*VinFo)])
ulalume3@0 628 IS2e = np.array([IinFa+DiC*QinFae,DiC*IinFa+QinFae,ZiC*(CosC*UinFae+SinC*VinFa),-ZiC*(SinC*UinFae-CosC*VinFa)])
ulalume3@0 629 #IS1e = np.array([IinFo,0,0,VinFo])
ulalume3@0 630 #IS2e = np.array([0,QinFae,UinFae,VinFa])
ulalume3@0 631 GT = np.dot(ATFe,IS1e)
ulalume3@0 632 GR = np.dot(ARFe,IS1e)
ulalume3@0 633 HT = np.dot(ATFe,IS2e)
ulalume3@0 634 HR = np.dot(ARFe,IS2e)
ulalume3@0 635
ulalume3@0 636 else:
ulalume3@0 637 print('Calibrator not implemented yet')
ulalume3@0 638 sys.exit()
ulalume3@0 639
ulalume3@0 640 elif LocC == 2: # C behind emitter optics Eq.57 -------------------------------------------------------
ulalume3@0 641 #print("Calibrator location not implemented yet")
ulalume3@0 642 S2e = np.sin(np.deg2rad(2*RotC))
ulalume3@0 643 C2e = np.cos(np.deg2rad(2*RotC))
ulalume3@0 644
ulalume3@0 645 # AS with C before the receiver optics (see document rotated_diattenuator_X22x5deg.odt)
ulalume3@0 646 AF1 = np.array([1,C2g*DiO,S2g*DiO,0])
ulalume3@0 647 AF2 = np.array([C2g*DiO,1-S2g**2*WiO,S2g*C2g*WiO,-S2g*ZiO*SinO])
ulalume3@0 648 AF3 = np.array([S2g*DiO, S2g*C2g*WiO, 1-C2g**2*WiO, C2g*ZiO*SinO])
ulalume3@0 649 AF4 = np.array([0, S2g*SinO, -C2g*SinO, CosO])
ulalume3@0 650
ulalume3@0 651 ATF = (ATP1*AF1+ATP2*AF2+ATP3*AF3+ATP4*AF4)
ulalume3@0 652 ARF = (ARP1*AF1+ARP2*AF2+ARP3*AF3+ARP4*AF4)
ulalume3@0 653 ATF1 = ATF[0]
ulalume3@0 654 ATF2 = ATF[1]
ulalume3@0 655 ATF3 = ATF[2]
ulalume3@0 656 ATF4 = ATF[3]
ulalume3@0 657 ARF1 = ARF[0]
ulalume3@0 658 ARF2 = ARF[1]
ulalume3@0 659 ARF3 = ARF[2]
ulalume3@0 660 ARF4 = ARF[3]
ulalume3@0 661
ulalume3@0 662 # AS with C behind the emitter
ulalume3@0 663 # terms without aCal
ulalume3@0 664 ATE1o, ARE1o = ATF1, ARF1
ulalume3@0 665 ATE2o, ARE2o = 0., 0.
ulalume3@0 666 ATE3o, ARE3o = 0., 0.
ulalume3@0 667 ATE4o, ARE4o = ATF4, ARF4
ulalume3@0 668 # terms with aCal
ulalume3@0 669 ATE1a, ARE1a = 0. , 0.
ulalume3@0 670 ATE2a, ARE2a = ATF2, ARF2
ulalume3@0 671 ATE3a, ARE3a = -ATF3, -ARF3
ulalume3@0 672 ATE4a, ARE4a = -2*ATF4, -2*ARF4
ulalume3@0 673 # rotated AinEa by epsilon
ulalume3@0 674 ATE2ae = C2e*ATF2 + S2e*ATF3
ulalume3@0 675 ATE3ae = -S2e*ATF2 - C2e*ATF3
ulalume3@0 676 ARE2ae = C2e*ARF2 + S2e*ARF3
ulalume3@0 677 ARE3ae = -S2e*ARF2 - C2e*ARF3
ulalume3@0 678
ulalume3@0 679 ATE1 = ATE1o
ulalume3@0 680 ATE2e = aCal*ATE2ae
ulalume3@0 681 ATE3e = aCal*ATE3ae
ulalume3@0 682 ATE4 = (1-2*aCal)*ATF4
ulalume3@0 683 ARE1 = ARE1o
ulalume3@0 684 ARE2e = aCal*ARE2ae
ulalume3@0 685 ARE3e = aCal*ARE3ae
ulalume3@0 686 ARE4 = (1-2*aCal)*ARF4
ulalume3@0 687
ulalume3@0 688 # rotated IinE
ulalume3@0 689 QinEe = C2e*QinE + S2e*UinE
ulalume3@0 690 UinEe = C2e*UinE - S2e*QinE
ulalume3@0 691
ulalume3@0 692 # Calibration signals and Calibration correction K from measurements with LDRCal / aCal
ulalume3@0 693 if (TypeC == 2) or (TypeC == 1): # +++++++++ rotator calibration Eq. C.4
ulalume3@0 694 AT = ATE1o*IinE + (ATE4o+aCal*ATE4a)*h*VinE
ulalume3@0 695 BT = aCal * (ATE3ae*QinEe - ATE2ae*h*UinEe)
ulalume3@0 696 AR = ARE1o*IinE + (ARE4o+aCal*ARE4a)*h*VinE
ulalume3@0 697 BR = aCal * (ARE3ae*QinEe - ARE2ae*h*UinEe)
ulalume3@0 698
ulalume3@0 699 # Correction paremeters for normal measurements; they are independent of LDR
ulalume3@0 700 if (not RotationErrorEpsilonForNormalMeasurements):
ulalume3@0 701 # Stokes Input Vector before receiver optics Eq. E.19 (after atmosphere F)
ulalume3@0 702 GT = ATE1o*IinE + ATE4o*h*VinE
ulalume3@0 703 GR = ARE1o*IinE + ARE4o*h*VinE
ulalume3@0 704 HT = ATE2a*QinE + ATE3a*h*UinEe + ATE4a*h*VinE
ulalume3@0 705 HR = ARE2a*QinE + ARE3a*h*UinEe + ARE4a*h*VinE
ulalume3@0 706 else:
ulalume3@0 707 GT = ATE1o*IinE + ATE4o*h*VinE
ulalume3@0 708 GR = ARE1o*IinE + ARE4o*h*VinE
ulalume3@0 709 HT = ATE2ae*QinE + ATE3ae*h*UinEe + ATE4a*h*VinE
ulalume3@0 710 HR = ARE2ae*QinE + ARE3ae*h*UinEe + ARE4a*h*VinE
ulalume3@0 711
ulalume3@0 712 elif (TypeC == 3) or (TypeC == 4): # +++++++++ linear polariser calibration Eq. C.5
ulalume3@0 713 # p = +45°, m = -45°
ulalume3@0 714 AT = ATE1*IinE + ZiC*CosC*(ATE2e*QinEe + ATE4*VinE) + ATE3e*UinEe
ulalume3@0 715 BT = DiC*(ATE1*UinEe + ATE3e*IinE) + ZiC*SinC*(ATE4*QinEe - ATE2e*VinE)
ulalume3@0 716 AR = ARE1*IinE + ZiC*CosC*(ARE2e*QinEe + ARE4*VinE) + ARE3e*UinEe
ulalume3@0 717 BR = DiC*(ARE1*UinEe + ARE3e*IinE) + ZiC*SinC*(ARE4*QinEe - ARE2e*VinE)
ulalume3@0 718
ulalume3@0 719 # Correction paremeters for normal measurements; they are independent of LDR
ulalume3@0 720 if (not RotationErrorEpsilonForNormalMeasurements):
ulalume3@0 721 # Stokes Input Vector before receiver optics Eq. E.19 (after atmosphere F)
ulalume3@0 722 GT = ATE1o*IinE + ATE4o*VinE
ulalume3@0 723 GR = ARE1o*IinE + ARE4o*VinE
ulalume3@0 724 HT = ATE2a*QinE + ATE3a*UinE + ATE4a*VinE
ulalume3@0 725 HR = ARE2a*QinE + ARE3a*UinE + ARE4a*VinE
ulalume3@0 726 else:
ulalume3@0 727 D = IinE + DiC*QinEe
ulalume3@0 728 A = DiC*IinE + QinEe
ulalume3@0 729 B = ZiC*(CosC*UinEe + SinC*VinE)
ulalume3@0 730 C = -ZiC*(SinC*UinEe - CosC*VinE)
ulalume3@0 731 GT = ATE1o*D + ATE4o*C
ulalume3@0 732 GR = ARE1o*D + ARE4o*C
ulalume3@0 733 HT = ATE2a*A + ATE3a*B + ATE4a*C
ulalume3@0 734 HR = ARE2a*A + ARE3a*B + ARE4a*C
ulalume3@0 735
ulalume3@0 736 elif (TypeC == 6): # real HWP calibration +-22.5° rotated_diattenuator_X22x5deg.odt
ulalume3@0 737 # p = +22.5°, m = -22.5°
ulalume3@0 738 IE1e = np.array([IinE+sqr05*DiC*QinEe, sqr05*DiC*IinE+(1-0.5*WiC)*QinEe, (1-0.5*WiC)*UinEe+sqr05*ZiC*SinC*VinE, -sqr05*ZiC*SinC*UinEe+ZiC*CosC*VinE])
ulalume3@0 739 IE2e = np.array([sqr05*DiC*UinEe, 0.5*WiC*UinEe-sqr05*ZiC*SinC*VinE, sqr05*DiC*IinE+0.5*WiC*QinEe, sqr05*ZiC*SinC*QinEe])
ulalume3@0 740 ATEe = np.array([ATE1,ATE2e,ATE3e,ATE4])
ulalume3@0 741 AREe = np.array([ARE1,ARE2e,ARE3e,ARE4])
ulalume3@0 742 AT = np.dot(ATEe,IE1e)
ulalume3@0 743 AR = np.dot(AREe,IE1e)
ulalume3@0 744 BT = np.dot(ATEe,IE2e)
ulalume3@0 745 BR = np.dot(AREe,IE2e)
ulalume3@0 746
ulalume3@0 747 # Correction paremeters for normal measurements; they are independent of LDR
ulalume3@0 748 if (not RotationErrorEpsilonForNormalMeasurements): # calibrator taken out
ulalume3@0 749 GT = ATE1o*IinE + ATE4o*VinE
ulalume3@0 750 GR = ARE1o*IinE + ARE4o*VinE
ulalume3@0 751 HT = ATE2a*QinE + ATE3a*UinE + ATE4a*VinE
ulalume3@0 752 HR = ARE2a*QinE + ARE3a*UinE + ARE4a*VinE
ulalume3@0 753 else:
ulalume3@0 754 D = IinE + DiC*QinEe
ulalume3@0 755 A = DiC*IinE + QinEe
ulalume3@0 756 B = ZiC*(CosC*UinEe + SinC*VinE)
ulalume3@0 757 C = -ZiC*(SinC*UinEe - CosC*VinE)
ulalume3@0 758 GT = ATE1o*D + ATE4o*C
ulalume3@0 759 GR = ARE1o*D + ARE4o*C
ulalume3@0 760 HT = ATE2a*A + ATE3a*B + ATE4a*C
ulalume3@0 761 HR = ARE2a*A + ARE3a*B + ARE4a*C
ulalume3@0 762
ulalume3@0 763 else:
ulalume3@0 764 print('Calibrator not implemented yet')
ulalume3@0 765 sys.exit()
ulalume3@0 766
ulalume3@0 767 else:
ulalume3@0 768 print("Calibrator location not implemented yet")
ulalume3@0 769 sys.exit()
ulalume3@0 770
ulalume3@0 771 # Determination of the correction K of the calibration factor
ulalume3@0 772 IoutTp = TaT*TiT*TiO*TiE*(AT + BT)
ulalume3@0 773 IoutTm = TaT*TiT*TiO*TiE*(AT - BT)
ulalume3@0 774 IoutRp = TaR*TiR*TiO*TiE*(AR + BR)
ulalume3@0 775 IoutRm = TaR*TiR*TiO*TiE*(AR - BR)
ulalume3@0 776
ulalume3@0 777 # --- Results and Corrections; electronic etaR and etaT are assumed to be 1
ulalume3@0 778 Etapx = IoutRp/IoutTp
ulalume3@0 779 Etamx = IoutRm/IoutTm
ulalume3@0 780 Etax = (Etapx*Etamx)**0.5
ulalume3@0 781
ulalume3@0 782 Eta = (TaR*TiR)/(TaT*TiT) # Eta = Eta*/K Eq. 84
ulalume3@0 783 K = Etax / Eta
ulalume3@0 784
ulalume3@0 785 # For comparison with Volkers Libreoffice Müller Matrix spreadsheet
ulalume3@0 786 #Eta_test_p = (IoutRp/IoutTp)
ulalume3@0 787 #Eta_test_m = (IoutRm/IoutTm)
ulalume3@0 788 #Eta_test = (Eta_test_p*Eta_test_m)**0.5
ulalume3@0 789
ulalume3@0 790 # ----- Forward simulated signals and LDRsim with atrue; from input file
ulalume3@0 791 It = TaT*TiT*TiO*TiE*(GT+atrue*HT)
ulalume3@0 792 Ir = TaR*TiR*TiO*TiE*(GR+atrue*HR)
ulalume3@0 793 # LDRsim = 1/Eta*Ir/It # simulated LDR* with Y from input file
ulalume3@0 794 LDRsim = Ir/It # simulated uncorrected LDR with Y from input file
ulalume3@0 795 # Corrected LDRsimCorr from forward simulated LDRsim (atrue)
ulalume3@0 796 # LDRsimCorr = (1./Eta*LDRsim*(GT+HT)-(GR+HR))/((GR-HR)-1./Eta*LDRsim*(GT-HT))
ulalume3@0 797 if Y == -1.:
ulalume3@0 798 LDRsimx = 1./LDRsim
ulalume3@0 799 else:
ulalume3@0 800 LDRsimx = LDRsim
ulalume3@0 801
ulalume3@0 802 # The following is correct without doubt
ulalume3@0 803 #LDRCorr = (LDRsim*K/Etax*(GT+HT)-(GR+HR))/((GR-HR)-LDRsim*K/Etax*(GT-HT))
ulalume3@0 804
ulalume3@0 805 # The following is a test whether the equations for calibration Etax and normal signal (GHK, LDRsim) are consistent
ulalume3@0 806 LDRCorr = (LDRsim/Eta*(GT+HT)-(GR+HR))/((GR-HR)-LDRsim*K/Etax*(GT-HT))
ulalume3@0 807
ulalume3@0 808 TTa = TiT*TaT #*ATP1
ulalume3@0 809 TRa = TiR*TaR #*ARP1
ulalume3@0 810
ulalume3@0 811 F11sim = 1/(TiO*TiE)*((HR*Etax/K*It/TTa-HT*Ir/TRa)/(HR*GT-HT*GR)) # IL = 1, Etat = Etar = 1
ulalume3@0 812
ulalume3@0 813 return (GT, HT, GR, HR, K, Eta, LDRsimx, LDRCorr, DTa, DRa, TTa, TRa, F11sim)
ulalume3@0 814 # *******************************************************************************************************************************
ulalume3@0 815
ulalume3@0 816 # --- CALC truth
ulalume3@0 817 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)
ulalume3@0 818
ulalume3@0 819 # --------------------------------------------------------
ulalume3@0 820 with open('output_' + LID + '.dat', 'w') as f:
ulalume3@0 821 with redirect_stdout(f):
ulalume3@0 822 print("From ", dname)
ulalume3@0 823 print("Running ", fname)
ulalume3@0 824 print("Reading input file ", InputFile) #, " for Lidar system :", EID, ", ", LID)
ulalume3@0 825 print("for Lidar system: ", EID, ", ", LID)
ulalume3@0 826 # --- Print iput information*********************************
ulalume3@0 827 print(" --- Input parameters: value ±error / ±steps ----------------------")
ulalume3@0 828 print("{0:8} {1:8} {2:8.5f}; {3:8} {4:7.4f}±{5:7.4f}/{6:2d}".format("Laser: ", "DOLP = ", bL, " rotation alpha = ", RotL0, dRotL, nRotL))
ulalume3@0 829 print(" Diatt., Tunpol, Retard., Rotation (deg)")
ulalume3@0 830 print("{0:12} {1:7.4f}±{2:7.4f}/{8:2d}, {3:7.4f}, {4:3.0f}±{5:3.0f}/{9:2d}, {6:7.4f}±{7:7.4f}/{10:2d}".format("Emitter ", DiE0, dDiE, TiE, RetE0, dRetE, RotE0, dRotE, nDiE, nRetE, nRotE))
ulalume3@0 831 print("{0:12} {1:7.4f}±{2:7.4f}/{8:2d}, {3:7.4f}, {4:3.0f}±{5:3.0f}/{9:2d}, {6:7.4f}±{7:7.4f}/{10:2d}".format("Receiver ", DiO0, dDiO, TiO, RetO0, dRetO, RotO0, dRotO, nDiO, nRetO, nRotO))
ulalume3@0 832 print("{0:12} {1:7.4f}±{2:7.4f}/{8:2d}, {3:7.4f}, {4:3.0f}±{5:3.0f}/{9:2d}, {6:7.4f}±{7:7.4f}/{10:2d}".format("Calibrator ", DiC0, dDiC, TiC, RetC0, dRetC, RotC0, dRotC, nDiC, nRetC, nRotC))
ulalume3@0 833 print("{0:12}".format(" --- Pol.-filter ---"))
ulalume3@0 834 print("{0:12}{1:7.4f}±{2:7.4f}/{3:2d}, {4:7.4f}±{5:7.4f}/{6:2d}".format("ERT, ERR :", ERaT0, dERaT, nERaT, ERaR0, dERaR, nERaR))
ulalume3@0 835 print("{0:12}{1:7.4f}±{2:7.4f}/{3:2d}, {4:7.4f}±{5:7.4f}/{6:2d}".format("RotaT , RotaR :", RotaT0, dRotaT, nRotaT, RotaR0,dRotaR,nRotaR))
ulalume3@0 836 print("{0:12}".format(" --- PBS ---"))
ulalume3@0 837 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))
ulalume3@0 838 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))
ulalume3@0 839 print("{0:12}".format(" --- Combined PBS + Pol.-filter ---"))
ulalume3@0 840 print("{0:12}{1:7.4f},{2:7.4f}, {3:7.4f},{4:7.4f}".format("DTa,TTa,DRa,TRa: ", DTa0, TTa0, DRa0, TRa0))
ulalume3@0 841 print()
ulalume3@0 842 print("Rotation Error Epsilon For Normal Measurements = ", RotationErrorEpsilonForNormalMeasurements)
ulalume3@0 843 #print ('LocC = ', LocC, Loc[LocC], '; TypeC = ',TypeC, Type[TypeC])
ulalume3@0 844 print(Type[TypeC], Loc[LocC], "; Parallel signal detected in", dY[int(Y+1)])
ulalume3@0 845 # end of print actual system parameters
ulalume3@0 846 # ******************************************************************************
ulalume3@0 847
ulalume3@0 848 #print()
ulalume3@0 849 #print(" --- LDRCal during calibration | simulated and corrected LDRs -------------")
ulalume3@0 850 #print("{0:8} |{1:8}->{2:8},{3:9}->{4:9} |{5:8}->{6:8}".format(" LDRCal"," LDRtrue", " LDRsim"," LDRtrue2", " LDRsim2", " LDRmeas", " LDRcorr"))
ulalume3@0 851 #print("{0:8.5f} |{1:8.5f}->{2:8.5f},{3:9.5f}->{4:9.5f} |{5:8.5f}->{6:8.5f}".format(LDRCal, LDRtrue, LDRsim, LDRtrue2, LDRsim2, LDRmeas, LDRCorr))
ulalume3@0 852 #print("{0:8} |{1:8}->{2:8}->{3:8}".format(" LDRCal"," LDRtrue", " LDRsimx", " LDRcorr"))
ulalume3@0 853 #print("{0:6.3f}±{1:5.3f}/{2:2d}|{3:8.5f}->{4:8.5f}->{5:8.5f}".format(LDRCal0, dLDRCal, nLDRCal, LDRtrue, LDRsimx, LDRCorr))
ulalume3@0 854 #print("{0:8} |{1:8}->{2:8}->{3:8}".format(" LDRCal"," LDRtrue", " LDRsimx", " LDRcorr"))
ulalume3@0 855 #print(" --- LDRCal during calibration")
ulalume3@0 856 print("{0:26}: {1:6.3f}±{2:5.3f}/{3:2d}".format("LDRCal during calibration", LDRCal0, dLDRCal, nLDRCal))
ulalume3@0 857
ulalume3@0 858 #print("{0:8}={1:8.5f};{2:8}={3:8.5f}".format(" IinP",IinP," F11sim",F11sim))
ulalume3@0 859 print()
ulalume3@0 860
ulalume3@0 861 K0List = np.zeros(3)
ulalume3@0 862 LDRsimxList = np.zeros(3)
ulalume3@0 863 LDRCalList = 0.004, 0.2, 0.45
ulalume3@0 864 for i,LDRCal in enumerate(LDRCalList):
ulalume3@0 865 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, LDRCal)
ulalume3@0 866 K0List[i] = K0
ulalume3@0 867 LDRsimxList[i] = LDRsimx
ulalume3@0 868
ulalume3@0 869 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)"))
ulalume3@0 870 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]))
ulalume3@0 871 print('========================================================================')
ulalume3@0 872
ulalume3@0 873 print("{0:9},{1:9},{2:9}".format(" LDRtrue", " LDRsimx", " LDRCorr"))
ulalume3@0 874 LDRtrueList = 0.004, 0.02, 0.2, 0.45
ulalume3@0 875 for i,LDRtrue in enumerate(LDRtrueList):
ulalume3@0 876 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)
ulalume3@0 877 print("{0:9.5f},{1:9.5f},{2:9.5f}".format(LDRtrue, LDRsimx, LDRCorr))
ulalume3@0 878
ulalume3@0 879
ulalume3@0 880 file = open('output_' + LID + '.dat', 'r')
ulalume3@0 881 print (file.read())
ulalume3@0 882 file.close()
ulalume3@0 883
ulalume3@0 884 '''
ulalume3@0 885 if(PrintToOutputFile):
ulalume3@0 886 f = open('output_ver7.dat', 'w')
ulalume3@0 887 old_target = sys.stdout
ulalume3@0 888 sys.stdout = f
ulalume3@0 889
ulalume3@0 890 print("something")
ulalume3@0 891
ulalume3@0 892 if(PrintToOutputFile):
ulalume3@0 893 sys.stdout.flush()
ulalume3@0 894 f.close
ulalume3@0 895 sys.stdout = old_target
ulalume3@0 896 '''
ulalume3@0 897 # --- CALC again truth with LDRCal0 to reset all 0-values
ulalume3@0 898 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)
ulalume3@0 899
ulalume3@0 900 # --- Start Errors calculation
ulalume3@0 901
ulalume3@0 902 iN = -1
ulalume3@0 903 N = ((nRotL*2+1)*
ulalume3@0 904 (nRotE*2+1)*(nRetE*2+1)*(nDiE*2+1)*
ulalume3@0 905 (nRotO*2+1)*(nRetO*2+1)*(nDiO*2+1)*
ulalume3@0 906 (nRotC*2+1)*(nRetC*2+1)*(nDiC*2+1)*
ulalume3@0 907 (nTP*2+1)*(nTS*2+1)*(nRP*2+1)*(nRS*2+1)*(nERaT*2+1)*(nERaR*2+1)*
ulalume3@0 908 (nRotaT*2+1)*(nRotaR*2+1)*(nRetT*2+1)*(nRetR*2+1)*(nLDRCal*2+1))
ulalume3@0 909 print("N = ",N ," ", end="")
ulalume3@0 910
ulalume3@0 911 if N > 1e6:
ulalume3@0 912 if user_yes_no_query('Warning: processing ' + str(N) + ' samples will take very long. Do you want to proceed?') == 0: sys.exit()
ulalume3@0 913 if N > 5e6:
ulalume3@0 914 if user_yes_no_query('Warning: the memory required for ' + str(N) + ' samples might be ' + '{0:5.1f}'.format(N/4e6) + ' GB. Do you anyway want to proceed?') == 0: sys.exit()
ulalume3@0 915
ulalume3@0 916 #if user_yes_no_query('Warning: processing' + str(N) + ' samples will take very long. Do you want to proceed?') == 0: sys.exit()
ulalume3@0 917
ulalume3@0 918 # --- Arrays for plotting ------
ulalume3@0 919 LDRmin = np.zeros(5)
ulalume3@0 920 LDRmax = np.zeros(5)
ulalume3@0 921 F11min = np.zeros(5)
ulalume3@0 922 F11max = np.zeros(5)
ulalume3@0 923
ulalume3@0 924 LDRrange = np.zeros(5)
ulalume3@0 925 LDRrange = 0.004, 0.02, 0.1, 0.3, 0.45
ulalume3@0 926 #aLDRsimx = np.zeros(N)
ulalume3@0 927 #aLDRsimx2 = np.zeros(N)
ulalume3@0 928 #aLDRcorr = np.zeros(N)
ulalume3@0 929 #aLDRcorr2 = np.zeros(N)
ulalume3@0 930 aERaT = np.zeros(N)
ulalume3@0 931 aERaR = np.zeros(N)
ulalume3@0 932 aRotaT = np.zeros(N)
ulalume3@0 933 aRotaR = np.zeros(N)
ulalume3@0 934 aRetT = np.zeros(N)
ulalume3@0 935 aRetR = np.zeros(N)
ulalume3@0 936 aTP = np.zeros(N)
ulalume3@0 937 aTS = np.zeros(N)
ulalume3@0 938 aRP = np.zeros(N)
ulalume3@0 939 aRS = np.zeros(N)
ulalume3@0 940 aDiE = np.zeros(N)
ulalume3@0 941 aDiO = np.zeros(N)
ulalume3@0 942 aDiC = np.zeros(N)
ulalume3@0 943 aRotC = np.zeros(N)
ulalume3@0 944 aRetC = np.zeros(N)
ulalume3@0 945 aRotL = np.zeros(N)
ulalume3@0 946 aRetE = np.zeros(N)
ulalume3@0 947 aRotE = np.zeros(N)
ulalume3@0 948 aRetO = np.zeros(N)
ulalume3@0 949 aRotO = np.zeros(N)
ulalume3@0 950 aLDRCal = np.zeros(N)
ulalume3@0 951 aA = np.zeros((5,N))
ulalume3@0 952 aX = np.zeros((5,N))
ulalume3@0 953 aF11corr = np.zeros((5,N))
ulalume3@0 954
ulalume3@0 955 atime = clock()
ulalume3@0 956 dtime = clock()
ulalume3@0 957
ulalume3@0 958 # --- Calc Error signals
ulalume3@0 959 #GT, HT, GR, HR, K, Eta, LDRsim = Calc(RotL, RotE, RetE, DiE, RotO, RetO, DiO, RotC, RetC, DiC, TP, TS)
ulalume3@0 960 # ---- Do the calculations of bra-ket vectors
ulalume3@0 961 h = -1. if TypeC == 2 else 1
ulalume3@0 962
ulalume3@0 963 # from input file: measured LDRm and true LDRtrue, LDRtrue2 =>
ulalume3@0 964 ameas = (1.-LDRmeas)/(1+LDRmeas)
ulalume3@0 965 atrue = (1.-LDRtrue)/(1+LDRtrue)
ulalume3@0 966 atrue2 = (1.-LDRtrue2)/(1+LDRtrue2)
ulalume3@0 967
ulalume3@0 968 for iLDRCal in range(-nLDRCal,nLDRCal+1):
ulalume3@0 969 # from input file: assumed LDRCal for calibration measurements
ulalume3@0 970 LDRCal = LDRCal0
ulalume3@0 971 if nLDRCal > 0: LDRCal = LDRCal0 + iLDRCal*dLDRCal/nLDRCal
ulalume3@0 972
ulalume3@0 973 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, LDRCal)
ulalume3@0 974 aCal = (1.-LDRCal)/(1+LDRCal)
ulalume3@0 975 for iRotL, iRotE, iRetE, iDiE \
ulalume3@0 976 in [(iRotL,iRotE,iRetE,iDiE)
ulalume3@0 977 for iRotL in range(-nRotL,nRotL+1)
ulalume3@0 978 for iRotE in range(-nRotE,nRotE+1)
ulalume3@0 979 for iRetE in range(-nRetE,nRetE+1)
ulalume3@0 980 for iDiE in range(-nDiE,nDiE+1)]:
ulalume3@0 981
ulalume3@0 982 if nRotL > 0: RotL = RotL0 + iRotL*dRotL/nRotL
ulalume3@0 983 if nRotE > 0: RotE = RotE0 + iRotE*dRotE/nRotE
ulalume3@0 984 if nRetE > 0: RetE = RetE0 + iRetE*dRetE/nRetE
ulalume3@0 985 if nDiE > 0: DiE = DiE0 + iDiE*dDiE/nDiE
ulalume3@0 986
ulalume3@0 987 # angles of emitter and laser and calibrator and receiver optics
ulalume3@0 988 # RotL = alpha, RotE = beta, RotO = gamma, RotC = epsilon
ulalume3@0 989 S2a = np.sin(2*np.deg2rad(RotL))
ulalume3@0 990 C2a = np.cos(2*np.deg2rad(RotL))
ulalume3@0 991 S2b = np.sin(2*np.deg2rad(RotE))
ulalume3@0 992 C2b = np.cos(2*np.deg2rad(RotE))
ulalume3@0 993 S2ab = np.sin(np.deg2rad(2*RotL-2*RotE))
ulalume3@0 994 C2ab = np.cos(np.deg2rad(2*RotL-2*RotE))
ulalume3@0 995
ulalume3@0 996 # Laser with Degree of linear polarization DOLP = bL
ulalume3@0 997 IinL = 1.
ulalume3@0 998 QinL = bL
ulalume3@0 999 UinL = 0.
ulalume3@0 1000 VinL = (1. - bL**2)**0.5
ulalume3@0 1001
ulalume3@0 1002 # Stokes Input Vector rotation Eq. E.4
ulalume3@0 1003 A = C2a*QinL - S2a*UinL
ulalume3@0 1004 B = S2a*QinL + C2a*UinL
ulalume3@0 1005 # Stokes Input Vector rotation Eq. E.9
ulalume3@0 1006 C = C2ab*QinL - S2ab*UinL
ulalume3@0 1007 D = S2ab*QinL + C2ab*UinL
ulalume3@0 1008
ulalume3@0 1009 # emitter optics
ulalume3@0 1010 CosE = np.cos(np.deg2rad(RetE))
ulalume3@0 1011 SinE = np.sin(np.deg2rad(RetE))
ulalume3@0 1012 ZiE = (1. - DiE**2)**0.5
ulalume3@0 1013 WiE = (1. - ZiE*CosE)
ulalume3@0 1014
ulalume3@0 1015 # Stokes Input Vector after emitter optics equivalent to Eq. E.9 with already rotated input vector from Eq. E.4
ulalume3@0 1016 # b = beta
ulalume3@0 1017 IinE = (IinL + DiE*C)
ulalume3@0 1018 QinE = (C2b*DiE*IinL + A + S2b*(WiE*D - ZiE*SinE*VinL))
ulalume3@0 1019 UinE = (S2b*DiE*IinL + B - C2b*(WiE*D - ZiE*SinE*VinL))
ulalume3@0 1020 VinE = (-ZiE*SinE*D + ZiE*CosE*VinL)
ulalume3@0 1021
ulalume3@0 1022 #-------------------------
ulalume3@0 1023 # F11 assuemd to be = 1 => measured: F11m = IinP / IinE with atrue
ulalume3@0 1024 #F11sim = (IinE + DiO*atrue*(C2g*QinE - S2g*UinE))/IinE
ulalume3@0 1025 #-------------------------
ulalume3@0 1026
ulalume3@0 1027 for iRotO, iRetO, iDiO, iRotC, iRetC, iDiC, iTP, iTS, iRP, iRS, iERaT, iRotaT, iRetT, iERaR, iRotaR, iRetR \
ulalume3@0 1028 in [(iRotO,iRetO,iDiO,iRotC,iRetC,iDiC,iTP,iTS,iRP,iRS,iERaT,iRotaT,iRetT,iERaR,iRotaR,iRetR )
ulalume3@0 1029 for iRotO in range(-nRotO,nRotO+1)
ulalume3@0 1030 for iRetO in range(-nRetO,nRetO+1)
ulalume3@0 1031 for iDiO in range(-nDiO,nDiO+1)
ulalume3@0 1032 for iRotC in range(-nRotC,nRotC+1)
ulalume3@0 1033 for iRetC in range(-nRetC,nRetC+1)
ulalume3@0 1034 for iDiC in range(-nDiC,nDiC+1)
ulalume3@0 1035 for iTP in range(-nTP,nTP+1)
ulalume3@0 1036 for iTS in range(-nTS,nTS+1)
ulalume3@0 1037 for iRP in range(-nRP,nRP+1)
ulalume3@0 1038 for iRS in range(-nRS,nRS+1)
ulalume3@0 1039 for iERaT in range(-nERaT,nERaT+1)
ulalume3@0 1040 for iRotaT in range(-nRotaT,nRotaT+1)
ulalume3@0 1041 for iRetT in range(-nRetT,nRetT+1)
ulalume3@0 1042 for iERaR in range(-nERaR,nERaR+1)
ulalume3@0 1043 for iRotaR in range(-nRotaR,nRotaR+1)
ulalume3@0 1044 for iRetR in range(-nRetR,nRetR+1)]:
ulalume3@0 1045
ulalume3@0 1046 iN = iN + 1
ulalume3@0 1047 if (iN == 10001):
ulalume3@0 1048 ctime = clock()
ulalume3@0 1049 print(" estimated time ", "{0:4.2f}".format(N/10000 * (ctime-atime)), "sec ") #, end="")
ulalume3@0 1050 print("\r elapsed time ", "{0:5.0f}".format((ctime-atime)), "sec ", end="\r")
ulalume3@0 1051 ctime = clock()
ulalume3@0 1052 if ((ctime - dtime) > 10):
ulalume3@0 1053 print("\r elapsed time ", "{0:5.0f}".format((ctime-atime)), "sec ", end="\r")
ulalume3@0 1054 dtime = ctime
ulalume3@0 1055
ulalume3@0 1056 if nRotO > 0: RotO = RotO0 + iRotO*dRotO/nRotO
ulalume3@0 1057 if nRetO > 0: RetO = RetO0 + iRetO*dRetO/nRetO
ulalume3@0 1058 if nDiO > 0: DiO = DiO0 + iDiO*dDiO/nDiO
ulalume3@0 1059 if nRotC > 0: RotC = RotC0 + iRotC*dRotC/nRotC
ulalume3@0 1060 if nRetC > 0: RetC = RetC0 + iRetC*dRetC/nRetC
ulalume3@0 1061 if nDiC > 0: DiC = DiC0 + iDiC*dDiC/nDiC
ulalume3@0 1062 if nTP > 0: TP = TP0 + iTP*dTP/nTP
ulalume3@0 1063 if nTS > 0: TS = TS0 + iTS*dTS/nTS
ulalume3@0 1064 if nRP > 0: RP = RP0 + iRP*dRP/nRP
ulalume3@0 1065 if nRS > 0: RS = RS0 + iRS*dRS/nRS
ulalume3@0 1066 if nERaT > 0: ERaT = ERaT0 + iERaT*dERaT/nERaT
ulalume3@0 1067 if nRotaT > 0:RotaT= RotaT0+ iRotaT*dRotaT/nRotaT
ulalume3@0 1068 if nRetT > 0: RetT = RetT0 + iRetT*dRetT/nRetT
ulalume3@0 1069 if nERaR > 0: ERaR = ERaR0 + iERaR*dERaR/nERaR
ulalume3@0 1070 if nRotaR > 0:RotaR= RotaR0+ iRotaR*dRotaR/nRotaR
ulalume3@0 1071 if nRetR > 0: RetR = RetR0 + iRetR*dRetR/nRetR
ulalume3@0 1072
ulalume3@0 1073 #print("{0:5.2f}, {1:5.2f}, {2:5.2f}, {3:10d}".format(RotL, RotE, RotO, iN))
ulalume3@0 1074
ulalume3@0 1075 # receiver optics
ulalume3@0 1076 CosO = np.cos(np.deg2rad(RetO))
ulalume3@0 1077 SinO = np.sin(np.deg2rad(RetO))
ulalume3@0 1078 ZiO = (1. - DiO**2)**0.5
ulalume3@0 1079 WiO = (1. - ZiO*CosO)
ulalume3@0 1080 S2g = np.sin(np.deg2rad(2*RotO))
ulalume3@0 1081 C2g = np.cos(np.deg2rad(2*RotO))
ulalume3@0 1082 # calibrator
ulalume3@0 1083 CosC = np.cos(np.deg2rad(RetC))
ulalume3@0 1084 SinC = np.sin(np.deg2rad(RetC))
ulalume3@0 1085 ZiC = (1. - DiC**2)**0.5
ulalume3@0 1086 WiC = (1. - ZiC*CosC)
ulalume3@0 1087
ulalume3@0 1088 #For POLLY_XT
ulalume3@0 1089 # analyser
ulalume3@0 1090 #RS = 1 - TS
ulalume3@0 1091 #RP = 1 - TP
ulalume3@0 1092 TiT = 0.5 * (TP + TS)
ulalume3@0 1093 DiT = (TP-TS)/(TP+TS)
ulalume3@0 1094 ZiT = (1. - DiT**2)**0.5
ulalume3@0 1095 TiR = 0.5 * (RP + RS)
ulalume3@0 1096 DiR = (RP-RS)/(RP+RS)
ulalume3@0 1097 ZiR = (1. - DiR**2)**0.5
ulalume3@0 1098 CosT = np.cos(np.deg2rad(RetT))
ulalume3@0 1099 SinT = np.sin(np.deg2rad(RetT))
ulalume3@0 1100 CosR = np.cos(np.deg2rad(RetR))
ulalume3@0 1101 SinR = np.sin(np.deg2rad(RetR))
ulalume3@0 1102
ulalume3@0 1103 DaT = (1-ERaT)/(1+ERaT)
ulalume3@0 1104 DaR = (1-ERaR)/(1+ERaR)
ulalume3@0 1105 TaT = 0.5*(1+ERaT)
ulalume3@0 1106 TaR = 0.5*(1+ERaR)
ulalume3@0 1107
ulalume3@0 1108 S2aT = np.sin(np.deg2rad(h*2*RotaT))
ulalume3@0 1109 C2aT = np.cos(np.deg2rad(2*RotaT))
ulalume3@0 1110 S2aR = np.sin(np.deg2rad(h*2*RotaR))
ulalume3@0 1111 C2aR = np.cos(np.deg2rad(2*RotaR))
ulalume3@0 1112
ulalume3@0 1113 # Aanalyzer As before the PBS Eq. D.5
ulalume3@0 1114 ATP1 = (1+C2aT*DaT*DiT)
ulalume3@0 1115 ATP2 = Y*(DiT+C2aT*DaT)
ulalume3@0 1116 ATP3 = Y*S2aT*DaT*ZiT*CosT
ulalume3@0 1117 ATP4 = S2aT*DaT*ZiT*SinT
ulalume3@0 1118 ATP = np.array([ATP1,ATP2,ATP3,ATP4])
ulalume3@0 1119
ulalume3@0 1120 ARP1 = (1+C2aR*DaR*DiR)
ulalume3@0 1121 ARP2 = Y*(DiR+C2aR*DaR)
ulalume3@0 1122 ARP3 = Y*S2aR*DaR*ZiR*CosR
ulalume3@0 1123 ARP4 = S2aR*DaR*ZiR*SinR
ulalume3@0 1124 ARP = np.array([ARP1,ARP2,ARP3,ARP4])
ulalume3@0 1125
ulalume3@0 1126 TTa = TiT*TaT #*ATP1
ulalume3@0 1127 TRa = TiR*TaR #*ARP1
ulalume3@0 1128
ulalume3@0 1129 # ---- Calculate signals and correction parameters for diffeent locations and calibrators
ulalume3@0 1130 if LocC == 4: # Calibrator before the PBS
ulalume3@0 1131 #print("Calibrator location not implemented yet")
ulalume3@0 1132
ulalume3@0 1133 #S2ge = np.sin(np.deg2rad(2*RotO + h*2*RotC))
ulalume3@0 1134 #C2ge = np.cos(np.deg2rad(2*RotO + h*2*RotC))
ulalume3@0 1135 S2e = np.sin(np.deg2rad(h*2*RotC))
ulalume3@0 1136 C2e = np.cos(np.deg2rad(2*RotC))
ulalume3@0 1137 # rotated AinP by epsilon Eq. C.3
ulalume3@0 1138 ATP2e = C2e*ATP2 + S2e*ATP3
ulalume3@0 1139 ATP3e = C2e*ATP3 - S2e*ATP2
ulalume3@0 1140 ARP2e = C2e*ARP2 + S2e*ARP3
ulalume3@0 1141 ARP3e = C2e*ARP3 - S2e*ARP2
ulalume3@0 1142 ATPe = np.array([ATP1,ATP2e,ATP3e,ATP4])
ulalume3@0 1143 ARPe = np.array([ARP1,ARP2e,ARP3e,ARP4])
ulalume3@0 1144 # Stokes Input Vector before the polarising beam splitter Eq. E.31
ulalume3@0 1145 A = C2g*QinE - S2g*UinE
ulalume3@0 1146 B = S2g*QinE + C2g*UinE
ulalume3@0 1147 #C = (WiO*aCal*B + ZiO*SinO*(1-2*aCal)*VinE)
ulalume3@0 1148 Co = ZiO*SinO*VinE
ulalume3@0 1149 Ca = (WiO*B - 2*ZiO*SinO*VinE)
ulalume3@0 1150 #C = Co + aCal*Ca
ulalume3@0 1151 #IinP = (IinE + DiO*aCal*A)
ulalume3@0 1152 #QinP = (C2g*DiO*IinE + aCal*QinE - S2g*C)
ulalume3@0 1153 #UinP = (S2g*DiO*IinE - aCal*UinE + C2g*C)
ulalume3@0 1154 #VinP = (ZiO*SinO*aCal*B + ZiO*CosO*(1-2*aCal)*VinE)
ulalume3@0 1155 IinPo = IinE
ulalume3@0 1156 QinPo = (C2g*DiO*IinE - S2g*Co)
ulalume3@0 1157 UinPo = (S2g*DiO*IinE + C2g*Co)
ulalume3@0 1158 VinPo = ZiO*CosO*VinE
ulalume3@0 1159
ulalume3@0 1160 IinPa = DiO*A
ulalume3@0 1161 QinPa = QinE - S2g*Ca
ulalume3@0 1162 UinPa = -UinE + C2g*Ca
ulalume3@0 1163 VinPa = ZiO*(SinO*B - 2*CosO*VinE)
ulalume3@0 1164
ulalume3@0 1165 IinP = IinPo + aCal*IinPa
ulalume3@0 1166 QinP = QinPo + aCal*QinPa
ulalume3@0 1167 UinP = UinPo + aCal*UinPa
ulalume3@0 1168 VinP = VinPo + aCal*VinPa
ulalume3@0 1169 # Stokes Input Vector before the polarising beam splitter rotated by epsilon Eq. C.3
ulalume3@0 1170 #QinPe = C2e*QinP + S2e*UinP
ulalume3@0 1171 #UinPe = C2e*UinP - S2e*QinP
ulalume3@0 1172 QinPoe = C2e*QinPo + S2e*UinPo
ulalume3@0 1173 UinPoe = C2e*UinPo - S2e*QinPo
ulalume3@0 1174 QinPae = C2e*QinPa + S2e*UinPa
ulalume3@0 1175 UinPae = C2e*UinPa - S2e*QinPa
ulalume3@0 1176 QinPe = C2e*QinP + S2e*UinP
ulalume3@0 1177 UinPe = C2e*UinP - S2e*QinP
ulalume3@0 1178
ulalume3@0 1179 # Calibration signals and Calibration correction K from measurements with LDRCal / aCal
ulalume3@0 1180 if (TypeC == 2) or (TypeC == 1): # rotator calibration Eq. C.4
ulalume3@0 1181 # parameters for calibration with aCal
ulalume3@0 1182 AT = ATP1*IinP + h*ATP4*VinP
ulalume3@0 1183 BT = ATP3e*QinP - h*ATP2e*UinP
ulalume3@0 1184 AR = ARP1*IinP + h*ARP4*VinP
ulalume3@0 1185 BR = ARP3e*QinP - h*ARP2e*UinP
ulalume3@0 1186 # Correction paremeters for normal measurements; they are independent of LDR
ulalume3@0 1187 if (not RotationErrorEpsilonForNormalMeasurements): # calibrator taken out
ulalume3@0 1188 IS1 = np.array([IinPo,QinPo,UinPo,VinPo])
ulalume3@0 1189 IS2 = np.array([IinPa,QinPa,UinPa,VinPa])
ulalume3@0 1190 GT = np.dot(ATP,IS1)
ulalume3@0 1191 GR = np.dot(ARP,IS1)
ulalume3@0 1192 HT = np.dot(ATP,IS2)
ulalume3@0 1193 HR = np.dot(ARP,IS2)
ulalume3@0 1194 else:
ulalume3@0 1195 IS1 = np.array([IinPo,QinPo,UinPo,VinPo])
ulalume3@0 1196 IS2 = np.array([IinPa,QinPa,UinPa,VinPa])
ulalume3@0 1197 GT = np.dot(ATPe,IS1)
ulalume3@0 1198 GR = np.dot(ARPe,IS1)
ulalume3@0 1199 HT = np.dot(ATPe,IS2)
ulalume3@0 1200 HR = np.dot(ARPe,IS2)
ulalume3@0 1201 elif (TypeC == 3) or (TypeC == 4): # linear polariser calibration Eq. C.5
ulalume3@0 1202 # parameters for calibration with aCal
ulalume3@0 1203 AT = ATP1*IinP + ATP3e*UinPe + ZiC*CosC*(ATP2e*QinPe + ATP4*VinP)
ulalume3@0 1204 BT = DiC*(ATP1*UinPe + ATP3e*IinP) - ZiC*SinC*(ATP2e*VinP - ATP4*QinPe)
ulalume3@0 1205 AR = ARP1*IinP + ARP3e*UinPe + ZiC*CosC*(ARP2e*QinPe + ARP4*VinP)
ulalume3@0 1206 BR = DiC*(ARP1*UinPe + ARP3e*IinP) - ZiC*SinC*(ARP2e*VinP - ARP4*QinPe)
ulalume3@0 1207 # Correction paremeters for normal measurements; they are independent of LDR
ulalume3@0 1208 if (not RotationErrorEpsilonForNormalMeasurements): # calibrator taken out
ulalume3@0 1209 IS1 = np.array([IinPo,QinPo,UinPo,VinPo])
ulalume3@0 1210 IS2 = np.array([IinPa,QinPa,UinPa,VinPa])
ulalume3@0 1211 GT = np.dot(ATP,IS1)
ulalume3@0 1212 GR = np.dot(ARP,IS1)
ulalume3@0 1213 HT = np.dot(ATP,IS2)
ulalume3@0 1214 HR = np.dot(ARP,IS2)
ulalume3@0 1215 else:
ulalume3@0 1216 IS1e = np.array([IinPo+DiC*QinPoe,DiC*IinPo+QinPoe,ZiC*(CosC*UinPoe+SinC*VinPo),-ZiC*(SinC*UinPoe-CosC*VinPo)])
ulalume3@0 1217 IS2e = np.array([IinPa+DiC*QinPae,DiC*IinPa+QinPae,ZiC*(CosC*UinPae+SinC*VinPa),-ZiC*(SinC*UinPae-CosC*VinPa)])
ulalume3@0 1218 GT = np.dot(ATPe,IS1e)
ulalume3@0 1219 GR = np.dot(ARPe,IS1e)
ulalume3@0 1220 HT = np.dot(ATPe,IS2e)
ulalume3@0 1221 HR = np.dot(ARPe,IS2e)
ulalume3@0 1222 elif (TypeC == 6): # diattenuator calibration +-22.5° rotated_diattenuator_X22x5deg.odt
ulalume3@0 1223 # parameters for calibration with aCal
ulalume3@0 1224 AT = ATP1*IinP + sqr05*DiC*(ATP1*QinPe + ATP2e*IinP) + (1-0.5*WiC)*(ATP2e*QinPe + ATP3e*UinPe) + ZiC*(sqr05*SinC*(ATP3e*VinP-ATP4*UinPe) + ATP4*CosC*VinP)
ulalume3@0 1225 BT = sqr05*DiC*(ATP1*UinPe + ATP3e*IinP) + 0.5*WiC*(ATP2e*UinPe + ATP3e*QinPe) - sqr05*ZiC*SinC*(ATP2e*VinP - ATP4*QinPe)
ulalume3@0 1226 AR = ARP1*IinP + sqr05*DiC*(ARP1*QinPe + ARP2e*IinP) + (1-0.5*WiC)*(ARP2e*QinPe + ARP3e*UinPe) + ZiC*(sqr05*SinC*(ARP3e*VinP-ARP4*UinPe) + ARP4*CosC*VinP)
ulalume3@0 1227 BR = sqr05*DiC*(ARP1*UinPe + ARP3e*IinP) + 0.5*WiC*(ARP2e*UinPe + ARP3e*QinPe) - sqr05*ZiC*SinC*(ARP2e*VinP - ARP4*QinPe)
ulalume3@0 1228 # Correction paremeters for normal measurements; they are independent of LDR
ulalume3@0 1229 if (not RotationErrorEpsilonForNormalMeasurements): # calibrator taken out
ulalume3@0 1230 IS1 = np.array([IinPo,QinPo,UinPo,VinPo])
ulalume3@0 1231 IS2 = np.array([IinPa,QinPa,UinPa,VinPa])
ulalume3@0 1232 GT = np.dot(ATP,IS1)
ulalume3@0 1233 GR = np.dot(ARP,IS1)
ulalume3@0 1234 HT = np.dot(ATP,IS2)
ulalume3@0 1235 HR = np.dot(ARP,IS2)
ulalume3@0 1236 else:
ulalume3@0 1237 IS1e = np.array([IinPo+DiC*QinPoe,DiC*IinPo+QinPoe,ZiC*(CosC*UinPoe+SinC*VinPo),-ZiC*(SinC*UinPoe-CosC*VinPo)])
ulalume3@0 1238 IS2e = np.array([IinPa+DiC*QinPae,DiC*IinPa+QinPae,ZiC*(CosC*UinPae+SinC*VinPa),-ZiC*(SinC*UinPae-CosC*VinPa)])
ulalume3@0 1239 GT = np.dot(ATPe,IS1e)
ulalume3@0 1240 GR = np.dot(ARPe,IS1e)
ulalume3@0 1241 HT = np.dot(ATPe,IS2e)
ulalume3@0 1242 HR = np.dot(ARPe,IS2e)
ulalume3@0 1243 else:
ulalume3@0 1244 print("Calibrator not implemented yet")
ulalume3@0 1245 sys.exit()
ulalume3@0 1246
ulalume3@0 1247 elif LocC == 3: # C before receiver optics Eq.57
ulalume3@0 1248
ulalume3@0 1249 #S2ge = np.sin(np.deg2rad(2*RotO - 2*RotC))
ulalume3@0 1250 #C2ge = np.cos(np.deg2rad(2*RotO - 2*RotC))
ulalume3@0 1251 S2e = np.sin(np.deg2rad(2*RotC))
ulalume3@0 1252 C2e = np.cos(np.deg2rad(2*RotC))
ulalume3@0 1253
ulalume3@0 1254 # AS with C before the receiver optics (see document rotated_diattenuator_X22x5deg.odt)
ulalume3@0 1255 AF1 = np.array([1,C2g*DiO,S2g*DiO,0])
ulalume3@0 1256 AF2 = np.array([C2g*DiO,1-S2g**2*WiO,S2g*C2g*WiO,-S2g*ZiO*SinO])
ulalume3@0 1257 AF3 = np.array([S2g*DiO, S2g*C2g*WiO, 1-C2g**2*WiO, C2g*ZiO*SinO])
ulalume3@0 1258 AF4 = np.array([0, S2g*SinO, -C2g*SinO, CosO])
ulalume3@0 1259
ulalume3@0 1260 ATF = (ATP1*AF1+ATP2*AF2+ATP3*AF3+ATP4*AF4)
ulalume3@0 1261 ARF = (ARP1*AF1+ARP2*AF2+ARP3*AF3+ARP4*AF4)
ulalume3@0 1262 ATF1 = ATF[0]
ulalume3@0 1263 ATF2 = ATF[1]
ulalume3@0 1264 ATF3 = ATF[2]
ulalume3@0 1265 ATF4 = ATF[3]
ulalume3@0 1266 ARF1 = ARF[0]
ulalume3@0 1267 ARF2 = ARF[1]
ulalume3@0 1268 ARF3 = ARF[2]
ulalume3@0 1269 ARF4 = ARF[3]
ulalume3@0 1270
ulalume3@0 1271 # rotated AinF by epsilon
ulalume3@0 1272 ATF2e = C2e*ATF[1] + S2e*ATF[2]
ulalume3@0 1273 ATF3e = C2e*ATF[2] - S2e*ATF[1]
ulalume3@0 1274 ARF2e = C2e*ARF[1] + S2e*ARF[2]
ulalume3@0 1275 ARF3e = C2e*ARF[2] - S2e*ARF[1]
ulalume3@0 1276
ulalume3@0 1277 ATFe = np.array([ATF1,ATF2e,ATF3e,ATF4])
ulalume3@0 1278 ARFe = np.array([ARF1,ARF2e,ARF3e,ARF4])
ulalume3@0 1279
ulalume3@0 1280 QinEe = C2e*QinE + S2e*UinE
ulalume3@0 1281 UinEe = C2e*UinE - S2e*QinE
ulalume3@0 1282
ulalume3@0 1283 # Stokes Input Vector before receiver optics Eq. E.19 (after atmosphere F)
ulalume3@0 1284 IinF = IinE
ulalume3@0 1285 QinF = aCal*QinE
ulalume3@0 1286 UinF = -aCal*UinE
ulalume3@0 1287 VinF = (1.-2.*aCal)*VinE
ulalume3@0 1288
ulalume3@0 1289 IinFo = IinE
ulalume3@0 1290 QinFo = 0.
ulalume3@0 1291 UinFo = 0.
ulalume3@0 1292 VinFo = VinE
ulalume3@0 1293
ulalume3@0 1294 IinFa = 0.
ulalume3@0 1295 QinFa = QinE
ulalume3@0 1296 UinFa = -UinE
ulalume3@0 1297 VinFa = -2.*VinE
ulalume3@0 1298
ulalume3@0 1299 # Stokes Input Vector before receiver optics rotated by epsilon Eq. C.3
ulalume3@0 1300 QinFe = C2e*QinF + S2e*UinF
ulalume3@0 1301 UinFe = C2e*UinF - S2e*QinF
ulalume3@0 1302 QinFoe = C2e*QinFo + S2e*UinFo
ulalume3@0 1303 UinFoe = C2e*UinFo - S2e*QinFo
ulalume3@0 1304 QinFae = C2e*QinFa + S2e*UinFa
ulalume3@0 1305 UinFae = C2e*UinFa - S2e*QinFa
ulalume3@0 1306
ulalume3@0 1307 # Calibration signals and Calibration correction K from measurements with LDRCal / aCal
ulalume3@0 1308 if (TypeC == 2) or (TypeC == 1): # rotator calibration Eq. C.4
ulalume3@0 1309 AT = ATF1*IinF + ATF4*h*VinF
ulalume3@0 1310 BT = ATF3e*QinF - ATF2e*h*UinF
ulalume3@0 1311 AR = ARF1*IinF + ARF4*h*VinF
ulalume3@0 1312 BR = ARF3e*QinF - ARF2e*h*UinF
ulalume3@0 1313
ulalume3@0 1314 # Correction paremeters for normal measurements; they are independent of LDR
ulalume3@0 1315 if (not RotationErrorEpsilonForNormalMeasurements):
ulalume3@0 1316 GT = ATF1*IinE + ATF4*VinE
ulalume3@0 1317 GR = ARF1*IinE + ARF4*VinE
ulalume3@0 1318 HT = ATF2*QinE - ATF3*UinE - ATF4*2*VinE
ulalume3@0 1319 HR = ARF2*QinE - ARF3*UinE - ARF4*2*VinE
ulalume3@0 1320 else:
ulalume3@0 1321 GT = ATF1*IinE + ATF4*h*VinE
ulalume3@0 1322 GR = ARF1*IinE + ARF4*h*VinE
ulalume3@0 1323 HT = ATF2e*QinE - ATF3e*h*UinE - ATF4*h*2*VinE
ulalume3@0 1324 HR = ARF2e*QinE - ARF3e*h*UinE - ARF4*h*2*VinE
ulalume3@0 1325
ulalume3@0 1326 elif (TypeC == 3) or (TypeC == 4): # linear polariser calibration Eq. C.5
ulalume3@0 1327 # p = +45°, m = -45°
ulalume3@0 1328 IF1e = np.array([IinF, ZiC*CosC*QinFe, UinFe, ZiC*CosC*VinF])
ulalume3@0 1329 IF2e = np.array([DiC*UinFe, -ZiC*SinC*VinF, DiC*IinF, ZiC*SinC*QinFe])
ulalume3@0 1330
ulalume3@0 1331 AT = np.dot(ATFe,IF1e)
ulalume3@0 1332 AR = np.dot(ARFe,IF1e)
ulalume3@0 1333 BT = np.dot(ATFe,IF2e)
ulalume3@0 1334 BR = np.dot(ARFe,IF2e)
ulalume3@0 1335
ulalume3@0 1336 # Correction paremeters for normal measurements; they are independent of LDR --- the same as for TypeC = 6
ulalume3@0 1337 if (not RotationErrorEpsilonForNormalMeasurements): # calibrator taken out
ulalume3@0 1338 IS1 = np.array([IinE,0,0,VinE])
ulalume3@0 1339 IS2 = np.array([0,QinE,-UinE,-2*VinE])
ulalume3@0 1340
ulalume3@0 1341 GT = np.dot(ATF,IS1)
ulalume3@0 1342 GR = np.dot(ARF,IS1)
ulalume3@0 1343 HT = np.dot(ATF,IS2)
ulalume3@0 1344 HR = np.dot(ARF,IS2)
ulalume3@0 1345 else:
ulalume3@0 1346 IS1e = np.array([IinFo+DiC*QinFoe,DiC*IinFo+QinFoe,ZiC*(CosC*UinFoe+SinC*VinFo),-ZiC*(SinC*UinFoe-CosC*VinFo)])
ulalume3@0 1347 IS2e = np.array([IinFa+DiC*QinFae,DiC*IinFa+QinFae,ZiC*(CosC*UinFae+SinC*VinFa),-ZiC*(SinC*UinFae-CosC*VinFa)])
ulalume3@0 1348 GT = np.dot(ATFe,IS1e)
ulalume3@0 1349 GR = np.dot(ARFe,IS1e)
ulalume3@0 1350 HT = np.dot(ATFe,IS2e)
ulalume3@0 1351 HR = np.dot(ARFe,IS2e)
ulalume3@0 1352
ulalume3@0 1353 elif (TypeC == 6): # diattenuator calibration +-22.5° rotated_diattenuator_X22x5deg.odt
ulalume3@0 1354 # p = +22.5°, m = -22.5°
ulalume3@0 1355 IF1e = np.array([IinF+sqr05*DiC*QinFe, sqr05*DiC*IinF+(1-0.5*WiC)*QinFe, (1-0.5*WiC)*UinFe+sqr05*ZiC*SinC*VinF, -sqr05*ZiC*SinC*UinFe+ZiC*CosC*VinF])
ulalume3@0 1356 IF2e = np.array([sqr05*DiC*UinFe, 0.5*WiC*UinFe-sqr05*ZiC*SinC*VinF, sqr05*DiC*IinF+0.5*WiC*QinFe, sqr05*ZiC*SinC*QinFe])
ulalume3@0 1357
ulalume3@0 1358 AT = np.dot(ATFe,IF1e)
ulalume3@0 1359 AR = np.dot(ARFe,IF1e)
ulalume3@0 1360 BT = np.dot(ATFe,IF2e)
ulalume3@0 1361 BR = np.dot(ARFe,IF2e)
ulalume3@0 1362
ulalume3@0 1363 # Correction paremeters for normal measurements; they are independent of LDR
ulalume3@0 1364 if (not RotationErrorEpsilonForNormalMeasurements): # calibrator taken out
ulalume3@0 1365 #IS1 = np.array([IinE,0,0,VinE])
ulalume3@0 1366 #IS2 = np.array([0,QinE,-UinE,-2*VinE])
ulalume3@0 1367 IS1 = np.array([IinFo,0,0,VinFo])
ulalume3@0 1368 IS2 = np.array([0,QinFa,UinFa,VinFa])
ulalume3@0 1369 GT = np.dot(ATF,IS1)
ulalume3@0 1370 GR = np.dot(ARF,IS1)
ulalume3@0 1371 HT = np.dot(ATF,IS2)
ulalume3@0 1372 HR = np.dot(ARF,IS2)
ulalume3@0 1373 else:
ulalume3@0 1374 #IS1e = np.array([IinE,DiC*IinE,ZiC*SinC*VinE,ZiC*CosC*VinE])
ulalume3@0 1375 #IS2e = np.array([DiC*QinEe,QinEe,-ZiC*(CosC*UinEe+2*SinC*VinE),ZiC*(SinC*UinEe-2*CosC*VinE)])
ulalume3@0 1376 IS1e = np.array([IinFo+DiC*QinFoe,DiC*IinFo+QinFoe,ZiC*(CosC*UinFoe+SinC*VinFo),-ZiC*(SinC*UinFoe-CosC*VinFo)])
ulalume3@0 1377 IS2e = np.array([IinFa+DiC*QinFae,DiC*IinFa+QinFae,ZiC*(CosC*UinFae+SinC*VinFa),-ZiC*(SinC*UinFae-CosC*VinFa)])
ulalume3@0 1378 GT = np.dot(ATFe,IS1e)
ulalume3@0 1379 GR = np.dot(ARFe,IS1e)
ulalume3@0 1380 HT = np.dot(ATFe,IS2e)
ulalume3@0 1381 HR = np.dot(ARFe,IS2e)
ulalume3@0 1382
ulalume3@0 1383
ulalume3@0 1384 else:
ulalume3@0 1385 print('Calibrator not implemented yet')
ulalume3@0 1386 sys.exit()
ulalume3@0 1387
ulalume3@0 1388 elif LocC == 2: # C behind emitter optics Eq.57
ulalume3@0 1389 #print("Calibrator location not implemented yet")
ulalume3@0 1390 S2e = np.sin(np.deg2rad(2*RotC))
ulalume3@0 1391 C2e = np.cos(np.deg2rad(2*RotC))
ulalume3@0 1392
ulalume3@0 1393 # AS with C before the receiver optics (see document rotated_diattenuator_X22x5deg.odt)
ulalume3@0 1394 AF1 = np.array([1,C2g*DiO,S2g*DiO,0])
ulalume3@0 1395 AF2 = np.array([C2g*DiO,1-S2g**2*WiO,S2g*C2g*WiO,-S2g*ZiO*SinO])
ulalume3@0 1396 AF3 = np.array([S2g*DiO, S2g*C2g*WiO, 1-C2g**2*WiO, C2g*ZiO*SinO])
ulalume3@0 1397 AF4 = np.array([0, S2g*SinO, -C2g*SinO, CosO])
ulalume3@0 1398
ulalume3@0 1399 ATF = (ATP1*AF1+ATP2*AF2+ATP3*AF3+ATP4*AF4)
ulalume3@0 1400 ARF = (ARP1*AF1+ARP2*AF2+ARP3*AF3+ARP4*AF4)
ulalume3@0 1401 ATF1 = ATF[0]
ulalume3@0 1402 ATF2 = ATF[1]
ulalume3@0 1403 ATF3 = ATF[2]
ulalume3@0 1404 ATF4 = ATF[3]
ulalume3@0 1405 ARF1 = ARF[0]
ulalume3@0 1406 ARF2 = ARF[1]
ulalume3@0 1407 ARF3 = ARF[2]
ulalume3@0 1408 ARF4 = ARF[3]
ulalume3@0 1409
ulalume3@0 1410 # AS with C behind the emitter --------------------------------------------
ulalume3@0 1411 # terms without aCal
ulalume3@0 1412 ATE1o, ARE1o = ATF1, ARF1
ulalume3@0 1413 ATE2o, ARE2o = 0., 0.
ulalume3@0 1414 ATE3o, ARE3o = 0., 0.
ulalume3@0 1415 ATE4o, ARE4o = ATF4, ARF4
ulalume3@0 1416 # terms with aCal
ulalume3@0 1417 ATE1a, ARE1a = 0. , 0.
ulalume3@0 1418 ATE2a, ARE2a = ATF2, ARF2
ulalume3@0 1419 ATE3a, ARE3a = -ATF3, -ARF3
ulalume3@0 1420 ATE4a, ARE4a = -2*ATF4, -2*ARF4
ulalume3@0 1421 # rotated AinEa by epsilon
ulalume3@0 1422 ATE2ae = C2e*ATF2 + S2e*ATF3
ulalume3@0 1423 ATE3ae = -S2e*ATF2 - C2e*ATF3
ulalume3@0 1424 ARE2ae = C2e*ARF2 + S2e*ARF3
ulalume3@0 1425 ARE3ae = -S2e*ARF2 - C2e*ARF3
ulalume3@0 1426
ulalume3@0 1427 ATE1 = ATE1o
ulalume3@0 1428 ATE2e = aCal*ATE2ae
ulalume3@0 1429 ATE3e = aCal*ATE3ae
ulalume3@0 1430 ATE4 = (1-2*aCal)*ATF4
ulalume3@0 1431 ARE1 = ARE1o
ulalume3@0 1432 ARE2e = aCal*ARE2ae
ulalume3@0 1433 ARE3e = aCal*ARE3ae
ulalume3@0 1434 ARE4 = (1-2*aCal)*ARF4
ulalume3@0 1435
ulalume3@0 1436 # rotated IinE
ulalume3@0 1437 QinEe = C2e*QinE + S2e*UinE
ulalume3@0 1438 UinEe = C2e*UinE - S2e*QinE
ulalume3@0 1439
ulalume3@0 1440 # --- Calibration signals and Calibration correction K from measurements with LDRCal / aCal
ulalume3@0 1441 if (TypeC == 2) or (TypeC == 1): # +++++++++ rotator calibration Eq. C.4
ulalume3@0 1442 AT = ATE1o*IinE + (ATE4o+aCal*ATE4a)*h*VinE
ulalume3@0 1443 BT = aCal * (ATE3ae*QinEe - ATE2ae*h*UinEe)
ulalume3@0 1444 AR = ARE1o*IinE + (ARE4o+aCal*ARE4a)*h*VinE
ulalume3@0 1445 BR = aCal * (ARE3ae*QinEe - ARE2ae*h*UinEe)
ulalume3@0 1446
ulalume3@0 1447 # Correction paremeters for normal measurements; they are independent of LDR
ulalume3@0 1448 if (not RotationErrorEpsilonForNormalMeasurements):
ulalume3@0 1449 # Stokes Input Vector before receiver optics Eq. E.19 (after atmosphere F)
ulalume3@0 1450 GT = ATE1o*IinE + ATE4o*h*VinE
ulalume3@0 1451 GR = ARE1o*IinE + ARE4o*h*VinE
ulalume3@0 1452 HT = ATE2a*QinE + ATE3a*h*UinEe + ATE4a*h*VinE
ulalume3@0 1453 HR = ARE2a*QinE + ARE3a*h*UinEe + ARE4a*h*VinE
ulalume3@0 1454 else:
ulalume3@0 1455 GT = ATE1o*IinE + ATE4o*h*VinE
ulalume3@0 1456 GR = ARE1o*IinE + ARE4o*h*VinE
ulalume3@0 1457 HT = ATE2ae*QinE + ATE3ae*h*UinEe + ATE4a*h*VinE
ulalume3@0 1458 HR = ARE2ae*QinE + ARE3ae*h*UinEe + ARE4a*h*VinE
ulalume3@0 1459
ulalume3@0 1460 elif (TypeC == 3) or (TypeC == 4): # +++++++++ linear polariser calibration Eq. C.5
ulalume3@0 1461 # p = +45°, m = -45°
ulalume3@0 1462 AT = ATE1*IinE + ZiC*CosC*(ATE2e*QinEe + ATE4*VinE) + ATE3e*UinEe
ulalume3@0 1463 BT = DiC*(ATE1*UinEe + ATE3e*IinE) + ZiC*SinC*(ATE4*QinEe - ATE2e*VinE)
ulalume3@0 1464 AR = ARE1*IinE + ZiC*CosC*(ARE2e*QinEe + ARE4*VinE) + ARE3e*UinEe
ulalume3@0 1465 BR = DiC*(ARE1*UinEe + ARE3e*IinE) + ZiC*SinC*(ARE4*QinEe - ARE2e*VinE)
ulalume3@0 1466
ulalume3@0 1467 # Correction paremeters for normal measurements; they are independent of LDR
ulalume3@0 1468 if (not RotationErrorEpsilonForNormalMeasurements):
ulalume3@0 1469 # Stokes Input Vector before receiver optics Eq. E.19 (after atmosphere F)
ulalume3@0 1470 GT = ATE1o*IinE + ATE4o*VinE
ulalume3@0 1471 GR = ARE1o*IinE + ARE4o*VinE
ulalume3@0 1472 HT = ATE2a*QinE + ATE3a*UinE + ATE4a*VinE
ulalume3@0 1473 HR = ARE2a*QinE + ARE3a*UinE + ARE4a*VinE
ulalume3@0 1474 else:
ulalume3@0 1475 D = IinE + DiC*QinEe
ulalume3@0 1476 A = DiC*IinE + QinEe
ulalume3@0 1477 B = ZiC*(CosC*UinEe + SinC*VinE)
ulalume3@0 1478 C = -ZiC*(SinC*UinEe - CosC*VinE)
ulalume3@0 1479 GT = ATE1o*D + ATE4o*C
ulalume3@0 1480 GR = ARE1o*D + ARE4o*C
ulalume3@0 1481 HT = ATE2a*A + ATE3a*B + ATE4a*C
ulalume3@0 1482 HR = ARE2a*A + ARE3a*B + ARE4a*C
ulalume3@0 1483
ulalume3@0 1484 elif (TypeC == 6): # real HWP calibration +-22.5° rotated_diattenuator_X22x5deg.odt
ulalume3@0 1485 # p = +22.5°, m = -22.5°
ulalume3@0 1486 IE1e = np.array([IinE+sqr05*DiC*QinEe, sqr05*DiC*IinE+(1-0.5*WiC)*QinEe, (1-0.5*WiC)*UinEe+sqr05*ZiC*SinC*VinE, -sqr05*ZiC*SinC*UinEe+ZiC*CosC*VinE])
ulalume3@0 1487 IE2e = np.array([sqr05*DiC*UinEe, 0.5*WiC*UinEe-sqr05*ZiC*SinC*VinE, sqr05*DiC*IinE+0.5*WiC*QinEe, sqr05*ZiC*SinC*QinEe])
ulalume3@0 1488 ATEe = np.array([ATE1,ATE2e,ATE3e,ATE4])
ulalume3@0 1489 AREe = np.array([ARE1,ARE2e,ARE3e,ARE4])
ulalume3@0 1490 AT = np.dot(ATEe,IE1e)
ulalume3@0 1491 AR = np.dot(AREe,IE1e)
ulalume3@0 1492 BT = np.dot(ATEe,IE2e)
ulalume3@0 1493 BR = np.dot(AREe,IE2e)
ulalume3@0 1494
ulalume3@0 1495 # Correction paremeters for normal measurements; they are independent of LDR
ulalume3@0 1496 if (not RotationErrorEpsilonForNormalMeasurements): # calibrator taken out
ulalume3@0 1497 GT = ATE1o*IinE + ATE4o*VinE
ulalume3@0 1498 GR = ARE1o*IinE + ARE4o*VinE
ulalume3@0 1499 HT = ATE2a*QinE + ATE3a*UinE + ATE4a*VinE
ulalume3@0 1500 HR = ARE2a*QinE + ARE3a*UinE + ARE4a*VinE
ulalume3@0 1501 else:
ulalume3@0 1502 D = IinE + DiC*QinEe
ulalume3@0 1503 A = DiC*IinE + QinEe
ulalume3@0 1504 B = ZiC*(CosC*UinEe + SinC*VinE)
ulalume3@0 1505 C = -ZiC*(SinC*UinEe - CosC*VinE)
ulalume3@0 1506 GT = ATE1o*D + ATE4o*C
ulalume3@0 1507 GR = ARE1o*D + ARE4o*C
ulalume3@0 1508 HT = ATE2a*A + ATE3a*B + ATE4a*C
ulalume3@0 1509 HR = ARE2a*A + ARE3a*B + ARE4a*C
ulalume3@0 1510
ulalume3@0 1511 else:
ulalume3@0 1512 print('Calibrator not implemented yet')
ulalume3@0 1513 sys.exit()
ulalume3@0 1514
ulalume3@0 1515 # Calibration signals with aCal => Determination of the correction K of the real calibration factor
ulalume3@0 1516 IoutTp = TaT*TiT*TiO*TiE*(AT + BT)
ulalume3@0 1517 IoutTm = TaT*TiT*TiO*TiE*(AT - BT)
ulalume3@0 1518 IoutRp = TaR*TiR*TiO*TiE*(AR + BR)
ulalume3@0 1519 IoutRm = TaR*TiR*TiO*TiE*(AR - BR)
ulalume3@0 1520 # --- Results and Corrections; electronic etaR and etaT are assumed to be 1
ulalume3@0 1521 #Eta = TiR/TiT # Eta = Eta*/K Eq. 84
ulalume3@0 1522 Etapx = IoutRp/IoutTp
ulalume3@0 1523 Etamx = IoutRm/IoutTm
ulalume3@0 1524 Etax = (Etapx*Etamx)**0.5
ulalume3@0 1525 K = Etax / Eta0
ulalume3@0 1526 #print("{0:6.3f},{1:6.3f},{2:6.3f},{3:6.3f},{4:6.3f},{5:6.3f},{6:6.3f},{7:6.3f},{8:6.3f},{9:6.3f},{10:6.3f}".format(AT, BT, AR, BR, DiC, ZiC, RetO, TP, TS, Kp, Km))
ulalume3@0 1527 #print("{0:6.3f},{1:6.3f},{2:6.3f},{3:6.3f}".format(DiC, ZiC, Kp, Km))
ulalume3@0 1528
ulalume3@0 1529 # For comparison with Volkers Libreoffice Müller Matrix spreadsheet
ulalume3@0 1530 #Eta_test_p = (IoutRp/IoutTp)
ulalume3@0 1531 #Eta_test_m = (IoutRm/IoutTm)
ulalume3@0 1532 #Eta_test = (Eta_test_p*Eta_test_m)**0.5
ulalume3@0 1533
ulalume3@0 1534 # *************************************************************************
ulalume3@0 1535 iLDR = -1
ulalume3@0 1536 for LDRTrue in LDRrange:
ulalume3@0 1537 iLDR = iLDR + 1
ulalume3@0 1538 atrue = (1-LDRTrue)/(1+LDRTrue)
ulalume3@0 1539 # ----- Forward simulated signals and LDRsim with atrue; from input file
ulalume3@0 1540 It = TaT*TiT*TiO*TiE*(GT+atrue*HT) # TaT*TiT*TiC*TiO*IinL*(GT+atrue*HT)
ulalume3@0 1541 Ir = TaR*TiR*TiO*TiE*(GR+atrue*HR) # TaR*TiR*TiC*TiO*IinL*(GR+atrue*HR)
ulalume3@0 1542
ulalume3@0 1543 # LDRsim = 1/Eta*Ir/It # simulated LDR* with Y from input file
ulalume3@0 1544 LDRsim = Ir/It # simulated uncorrected LDR with Y from input file
ulalume3@0 1545 '''
ulalume3@0 1546 if Y == 1.:
ulalume3@0 1547 LDRsimx = LDRsim
ulalume3@0 1548 LDRsimx2 = LDRsim2
ulalume3@0 1549 else:
ulalume3@0 1550 LDRsimx = 1./LDRsim
ulalume3@0 1551 LDRsimx2 = 1./LDRsim2
ulalume3@0 1552 '''
ulalume3@0 1553 # ----- Backward correction
ulalume3@0 1554 # Corrected LDRCorr from forward simulated LDRsim (atrue) with assumed true G0,H0,K0
ulalume3@0 1555 LDRCorr = (LDRsim*K0/Etax*(GT0+HT0)-(GR0+HR0))/((GR0-HR0)-LDRsim*K0/Etax*(GT0-HT0))
ulalume3@0 1556
ulalume3@0 1557 # -- F11corr from It and Ir and calibration EtaX
ulalume3@0 1558 Text1 = "F11corr from It and Ir with calibration EtaX: x-axis: F11corr(LDRtrue) / F11corr(LDRtrue = 0.004) - 1"
ulalume3@0 1559 F11corr = 1/(TiO*TiE)*((HR0*Etax/K0*It/TTa-HT0*Ir/TRa)/(HR0*GT0-HT0*GR0)) # IL = 1 Eq.(64)
ulalume3@0 1560
ulalume3@0 1561 #Text1 = "F11corr from It and Ir without corrections but with calibration EtaX: x-axis: F11corr(LDRtrue) devided by F11corr(LDRtrue = 0.004)"
ulalume3@0 1562 #F11corr = 0.5/(TiO*TiE)*(Etax*It/TTa+Ir/TRa) # IL = 1 Eq.(64)
ulalume3@0 1563
ulalume3@0 1564 # -- It from It only with atrue without corrections - for BERTHA (and PollyXTs)
ulalume3@0 1565 #Text1 = " x-axis: IT(LDRtrue) / IT(LDRtrue = 0.004) - 1"
ulalume3@0 1566 #F11corr = It/(TaT*TiT*TiO*TiE) #/(TaT*TiT*TiO*TiE*(GT0+atrue*HT0))
ulalume3@0 1567 # !!! see below line 1673ff
ulalume3@0 1568
ulalume3@0 1569 aF11corr[iLDR,iN] = F11corr
ulalume3@0 1570 aA[iLDR,iN] = LDRCorr
ulalume3@0 1571
ulalume3@0 1572 aX[0,iN] = GR
ulalume3@0 1573 aX[1,iN] = GT
ulalume3@0 1574 aX[2,iN] = HR
ulalume3@0 1575 aX[3,iN] = HT
ulalume3@0 1576 aX[4,iN] = K
ulalume3@0 1577
ulalume3@0 1578 aLDRCal[iN] = iLDRCal
ulalume3@0 1579 aERaT[iN] = iERaT
ulalume3@0 1580 aERaR[iN] = iERaR
ulalume3@0 1581 aRotaT[iN] = iRotaT
ulalume3@0 1582 aRotaR[iN] = iRotaR
ulalume3@0 1583 aRetT[iN] = iRetT
ulalume3@0 1584 aRetR[iN] = iRetR
ulalume3@0 1585
ulalume3@0 1586 aRotL[iN] = iRotL
ulalume3@0 1587 aRotE[iN] = iRotE
ulalume3@0 1588 aRetE[iN] = iRetE
ulalume3@0 1589 aRotO[iN] = iRotO
ulalume3@0 1590 aRetO[iN] = iRetO
ulalume3@0 1591 aRotC[iN] = iRotC
ulalume3@0 1592 aRetC[iN] = iRetC
ulalume3@0 1593 aDiO[iN] = iDiO
ulalume3@0 1594 aDiE[iN] = iDiE
ulalume3@0 1595 aDiC[iN] = iDiC
ulalume3@0 1596 aTP[iN] = iTP
ulalume3@0 1597 aTS[iN] = iTS
ulalume3@0 1598 aRP[iN] = iRP
ulalume3@0 1599 aRS[iN] = iRS
ulalume3@0 1600
ulalume3@0 1601 # --- END loop
ulalume3@0 1602 btime = clock()
ulalume3@0 1603 print("\r done in ", "{0:5.0f}".format(btime-atime), "sec") #, end="\r")
ulalume3@0 1604
ulalume3@0 1605 # --- Plot -----------------------------------------------------------------
ulalume3@0 1606 #sns.set_style("whitegrid")
ulalume3@0 1607 #sns.set_palette("bright", 6)
ulalume3@0 1608
ulalume3@0 1609 '''
ulalume3@0 1610 fig2 = plt.figure()
ulalume3@0 1611 plt.plot(aA[2,:],'b.')
ulalume3@0 1612 plt.plot(aA[3,:],'r.')
ulalume3@0 1613 plt.plot(aA[4,:],'g.')
ulalume3@0 1614 #plt.plot(aA[6,:],'c.')
ulalume3@0 1615 plt.show
ulalume3@0 1616 '''
ulalume3@0 1617 # Plot LDR
ulalume3@0 1618 def PlotSubHist(aVar, aX, X0, daX, iaX, naX):
ulalume3@0 1619 fig, ax = plt.subplots(nrows=1, ncols=5, sharex=True, sharey=True, figsize=(25, 2))
ulalume3@0 1620 iLDR = -1
ulalume3@0 1621 for LDRTrue in LDRrange:
ulalume3@0 1622 iLDR = iLDR + 1
ulalume3@0 1623
ulalume3@0 1624 LDRmin[iLDR] = np.min(aA[iLDR,:])
ulalume3@0 1625 LDRmax[iLDR] = np.max(aA[iLDR,:])
ulalume3@0 1626 Rmin = LDRmin[iLDR] * 0.995 # np.min(aA[iLDR,:]) * 0.995
ulalume3@0 1627 Rmax = LDRmax[iLDR] * 1.005 # np.max(aA[iLDR,:]) * 1.005
ulalume3@0 1628
ulalume3@0 1629 #plt.subplot(5,2,iLDR+1)
ulalume3@0 1630 plt.subplot(1,5,iLDR+1)
ulalume3@0 1631 (n, bins, patches) = plt.hist(aA[iLDR,:],
ulalume3@0 1632 bins=100, log=False,
ulalume3@0 1633 range=[Rmin, Rmax],
ulalume3@0 1634 alpha=0.5, normed=False, color = '0.5', histtype='stepfilled')
ulalume3@0 1635
ulalume3@0 1636 for iaX in range(-naX,naX+1):
ulalume3@0 1637 plt.hist(aA[iLDR,aX == iaX],
ulalume3@0 1638 range=[Rmin, Rmax],
ulalume3@0 1639 bins=100, log=False, alpha=0.3, normed=False, histtype='stepfilled', label = str(round(X0 + iaX*daX/naX,5)))
ulalume3@0 1640
ulalume3@0 1641 if (iLDR == 2): plt.legend()
ulalume3@0 1642
ulalume3@0 1643 plt.tick_params(axis='both', labelsize=9)
ulalume3@0 1644 plt.plot([LDRTrue, LDRTrue], [0, np.max(n)], 'r-', lw=2)
ulalume3@0 1645
ulalume3@0 1646 #plt.title(LID + ' ' + aVar, fontsize=18)
ulalume3@0 1647 #plt.ylabel('frequency', fontsize=10)
ulalume3@0 1648 #plt.xlabel('LDRcorr', fontsize=10)
ulalume3@0 1649 #fig.tight_layout()
ulalume3@0 1650 fig.suptitle(LID + ' ' + str(Type[TypeC]) + ' ' + str(Loc[LocC]) + ' - ' + aVar, fontsize=14, y=1.05)
ulalume3@0 1651 #plt.show()
ulalume3@0 1652 #fig.savefig(LID + '_' + aVar + '.png', dpi=150, bbox_inches='tight', pad_inches=0)
ulalume3@0 1653 #plt.close
ulalume3@0 1654 return
ulalume3@0 1655
ulalume3@0 1656 if (nRotL > 0): PlotSubHist("RotL", aRotL, RotL0, dRotL, iRotL, nRotL)
ulalume3@0 1657 if (nRetE > 0): PlotSubHist("RetE", aRetE, RetE0, dRetE, iRetE, nRetE)
ulalume3@0 1658 if (nRotE > 0): PlotSubHist("RotE", aRotE, RotE0, dRotE, iRotE, nRotE)
ulalume3@0 1659 if (nDiE > 0): PlotSubHist("DiE", aDiE, DiE0, dDiE, iDiE, nDiE)
ulalume3@0 1660 if (nRetO > 0): PlotSubHist("RetO", aRetO, RetO0, dRetO, iRetO, nRetO)
ulalume3@0 1661 if (nRotO > 0): PlotSubHist("RotO", aRotO, RotO0, dRotO, iRotO, nRotO)
ulalume3@0 1662 if (nDiO > 0): PlotSubHist("DiO", aDiO, DiO0, dDiO, iDiO, nDiO)
ulalume3@0 1663 if (nDiC > 0): PlotSubHist("DiC", aDiC, DiC0, dDiC, iDiC, nDiC)
ulalume3@0 1664 if (nRotC > 0): PlotSubHist("RotC", aRotC, RotC0, dRotC, iRotC, nRotC)
ulalume3@0 1665 if (nRetC > 0): PlotSubHist("RetC", aRetC, RetC0, dRetC, iRetC, nRetC)
ulalume3@0 1666 if (nTP > 0): PlotSubHist("TP", aTP, TP0, dTP, iTP, nTP)
ulalume3@0 1667 if (nTS > 0): PlotSubHist("TS", aTS, TS0, dTS, iTS, nTS)
ulalume3@0 1668 if (nRP > 0): PlotSubHist("RP", aRP, RP0, dRP, iRP, nRP)
ulalume3@0 1669 if (nRS > 0): PlotSubHist("RS", aRS, RS0, dRS, iRS, nRS)
ulalume3@0 1670 if (nRetT > 0): PlotSubHist("RetT", aRetT, RetT0, dRetT, iRetT, nRetT)
ulalume3@0 1671 if (nRetR > 0): PlotSubHist("RetR", aRetR, RetR0, dRetR, iRetR, nRetR)
ulalume3@0 1672 if (nERaT > 0): PlotSubHist("ERaT", aERaT, ERaT0, dERaT, iERaT, nERaT)
ulalume3@0 1673 if (nERaR > 0): PlotSubHist("ERaR", aERaR, ERaR0, dERaR, iERaR, nERaR)
ulalume3@0 1674 if (nRotaT > 0): PlotSubHist("RotaT", aRotaT, RotaT0, dRotaT, iRotaT, nRotaT)
ulalume3@0 1675 if (nRotaR > 0): PlotSubHist("RotaR", aRotaR, RotaR0, dRotaR, iRotaR, nRotaR)
ulalume3@0 1676 if (nLDRCal > 0): PlotSubHist("LDRCal", aLDRCal, LDRCal0, dLDRCal, iLDRCal, nLDRCal)
ulalume3@0 1677
ulalume3@0 1678 plt.show()
ulalume3@0 1679 plt.close
ulalume3@0 1680
ulalume3@0 1681 print()
ulalume3@0 1682 #print("IT(LDRtrue) devided by IT(LDRtrue = 0.004)")
ulalume3@0 1683 print(Text1)
ulalume3@0 1684 print()
ulalume3@0 1685
ulalume3@0 1686 iLDR = 5
ulalume3@0 1687 for LDRTrue in LDRrange:
ulalume3@0 1688 iLDR = iLDR - 1
ulalume3@0 1689 aF11corr[iLDR,:] = aF11corr[iLDR,:] / aF11corr[0,:] - 1.0
ulalume3@0 1690
ulalume3@0 1691 # Plot F11
ulalume3@0 1692 def PlotSubHistF11(aVar, aX, X0, daX, iaX, naX):
ulalume3@0 1693 fig, ax = plt.subplots(nrows=1, ncols=5, sharex=True, sharey=True, figsize=(25, 2))
ulalume3@0 1694 iLDR = -1
ulalume3@0 1695 for LDRTrue in LDRrange:
ulalume3@0 1696 iLDR = iLDR + 1
ulalume3@0 1697
ulalume3@0 1698 '''
ulalume3@0 1699 F11min[iLDR] = np.min(aF11corr[iLDR,:])
ulalume3@0 1700 F11max[iLDR] = np.max(aF11corr[iLDR,:])
ulalume3@0 1701 Rmin = F11min[iLDR] * 0.995 # np.min(aA[iLDR,:]) * 0.995
ulalume3@0 1702 Rmax = F11max[iLDR] * 1.005 # np.max(aA[iLDR,:]) * 1.005
ulalume3@0 1703 '''
ulalume3@0 1704 #Rmin = 0.8
ulalume3@0 1705 #Rmax = 1.2
ulalume3@0 1706
ulalume3@0 1707 #plt.subplot(5,2,iLDR+1)
ulalume3@0 1708 plt.subplot(1,5,iLDR+1)
ulalume3@0 1709 (n, bins, patches) = plt.hist(aF11corr[iLDR,:],
ulalume3@0 1710 bins=100, log=False,
ulalume3@0 1711 alpha=0.5, normed=False, color = '0.5', histtype='stepfilled')
ulalume3@0 1712
ulalume3@0 1713 for iaX in range(-naX,naX+1):
ulalume3@0 1714 plt.hist(aF11corr[iLDR,aX == iaX],
ulalume3@0 1715 bins=100, log=False, alpha=0.3, normed=False, histtype='stepfilled', label = str(round(X0 + iaX*daX/naX,5)))
ulalume3@0 1716
ulalume3@0 1717 if (iLDR == 2): plt.legend()
ulalume3@0 1718
ulalume3@0 1719 plt.tick_params(axis='both', labelsize=9)
ulalume3@0 1720 #plt.plot([LDRTrue, LDRTrue], [0, np.max(n)], 'r-', lw=2)
ulalume3@0 1721
ulalume3@0 1722 #plt.title(LID + ' ' + aVar, fontsize=18)
ulalume3@0 1723 #plt.ylabel('frequency', fontsize=10)
ulalume3@0 1724 #plt.xlabel('LDRcorr', fontsize=10)
ulalume3@0 1725 #fig.tight_layout()
ulalume3@0 1726 fig.suptitle(LID + ' ' + str(Type[TypeC]) + ' ' + str(Loc[LocC]) + ' - ' + aVar, fontsize=14, y=1.05)
ulalume3@0 1727 #plt.show()
ulalume3@0 1728 #fig.savefig(LID + '_' + aVar + '.png', dpi=150, bbox_inches='tight', pad_inches=0)
ulalume3@0 1729 #plt.close
ulalume3@0 1730 return
ulalume3@0 1731
ulalume3@0 1732 if (nRotL > 0): PlotSubHistF11("RotL", aRotL, RotL0, dRotL, iRotL, nRotL)
ulalume3@0 1733 if (nRetE > 0): PlotSubHistF11("RetE", aRetE, RetE0, dRetE, iRetE, nRetE)
ulalume3@0 1734 if (nRotE > 0): PlotSubHistF11("RotE", aRotE, RotE0, dRotE, iRotE, nRotE)
ulalume3@0 1735 if (nDiE > 0): PlotSubHistF11("DiE", aDiE, DiE0, dDiE, iDiE, nDiE)
ulalume3@0 1736 if (nRetO > 0): PlotSubHistF11("RetO", aRetO, RetO0, dRetO, iRetO, nRetO)
ulalume3@0 1737 if (nRotO > 0): PlotSubHistF11("RotO", aRotO, RotO0, dRotO, iRotO, nRotO)
ulalume3@0 1738 if (nDiO > 0): PlotSubHistF11("DiO", aDiO, DiO0, dDiO, iDiO, nDiO)
ulalume3@0 1739 if (nDiC > 0): PlotSubHistF11("DiC", aDiC, DiC0, dDiC, iDiC, nDiC)
ulalume3@0 1740 if (nRotC > 0): PlotSubHistF11("RotC", aRotC, RotC0, dRotC, iRotC, nRotC)
ulalume3@0 1741 if (nRetC > 0): PlotSubHistF11("RetC", aRetC, RetC0, dRetC, iRetC, nRetC)
ulalume3@0 1742 if (nTP > 0): PlotSubHistF11("TP", aTP, TP0, dTP, iTP, nTP)
ulalume3@0 1743 if (nTS > 0): PlotSubHistF11("TS", aTS, TS0, dTS, iTS, nTS)
ulalume3@0 1744 if (nRP > 0): PlotSubHistF11("RP", aRP, RP0, dRP, iRP, nRP)
ulalume3@0 1745 if (nRS > 0): PlotSubHistF11("RS", aRS, RS0, dRS, iRS, nRS)
ulalume3@0 1746 if (nRetT > 0): PlotSubHistF11("RetT", aRetT, RetT0, dRetT, iRetT, nRetT)
ulalume3@0 1747 if (nRetR > 0): PlotSubHistF11("RetR", aRetR, RetR0, dRetR, iRetR, nRetR)
ulalume3@0 1748 if (nERaT > 0): PlotSubHistF11("ERaT", aERaT, ERaT0, dERaT, iERaT, nERaT)
ulalume3@0 1749 if (nERaR > 0): PlotSubHistF11("ERaR", aERaR, ERaR0, dERaR, iERaR, nERaR)
ulalume3@0 1750 if (nRotaT > 0): PlotSubHistF11("RotaT", aRotaT, RotaT0, dRotaT, iRotaT, nRotaT)
ulalume3@0 1751 if (nRotaR > 0): PlotSubHistF11("RotaR", aRotaR, RotaR0, dRotaR, iRotaR, nRotaR)
ulalume3@0 1752 if (nLDRCal > 0): PlotSubHistF11("LDRCal", aLDRCal, LDRCal0, dLDRCal, iLDRCal, nLDRCal)
ulalume3@0 1753
ulalume3@0 1754 plt.show()
ulalume3@0 1755 plt.close
ulalume3@0 1756 '''
ulalume3@0 1757 # only histogram
ulalume3@0 1758 #print("******************* " + aVar + " *******************")
ulalume3@0 1759 fig, ax = plt.subplots(nrows=5, ncols=2, sharex=True, sharey=True, figsize=(10, 10))
ulalume3@0 1760 iLDR = -1
ulalume3@0 1761 for LDRTrue in LDRrange:
ulalume3@0 1762 iLDR = iLDR + 1
ulalume3@0 1763 LDRmin[iLDR] = np.min(aA[iLDR,:])
ulalume3@0 1764 LDRmax[iLDR] = np.max(aA[iLDR,:])
ulalume3@0 1765 Rmin = np.min(aA[iLDR,:]) * 0.999
ulalume3@0 1766 Rmax = np.max(aA[iLDR,:]) * 1.001
ulalume3@0 1767 plt.subplot(5,2,iLDR+1)
ulalume3@0 1768 (n, bins, patches) = plt.hist(aA[iLDR,:],
ulalume3@0 1769 range=[Rmin, Rmax],
ulalume3@0 1770 bins=200, log=False, alpha=0.2, normed=False, color = '0.5', histtype='stepfilled')
ulalume3@0 1771 plt.tick_params(axis='both', labelsize=9)
ulalume3@0 1772 plt.plot([LDRTrue, LDRTrue], [0, np.max(n)], 'r-', lw=2)
ulalume3@0 1773 plt.show()
ulalume3@0 1774 plt.close
ulalume3@0 1775 '''
ulalume3@0 1776
ulalume3@0 1777 # --- Plot LDRmin, LDRmax
ulalume3@0 1778 fig2 = plt.figure()
ulalume3@0 1779 plt.plot(LDRrange,LDRmax-LDRrange, linewidth=2.0, color='b')
ulalume3@0 1780 plt.plot(LDRrange,LDRmin-LDRrange, linewidth=2.0, color='g')
ulalume3@0 1781
ulalume3@0 1782 plt.xlabel('LDRtrue', fontsize=18)
ulalume3@0 1783 plt.ylabel('LDRTrue-LDRmin, LDRTrue-LDRmax', fontsize=14)
ulalume3@0 1784 plt.title(LID + ' ' + str(Type[TypeC]) + ' ' + str(Loc[LocC]), fontsize=18)
ulalume3@0 1785 #plt.ylimit(-0.07, 0.07)
ulalume3@0 1786 plt.show()
ulalume3@0 1787 plt.close
ulalume3@0 1788
ulalume3@0 1789 # --- Save LDRmin, LDRmax to file
ulalume3@0 1790 # http://stackoverflow.com/questions/4675728/redirect-stdout-to-a-file-in-python
ulalume3@0 1791 with open('LDR_min_max_ver7_' + LID + '.dat', 'w') as f:
ulalume3@0 1792 with redirect_stdout(f):
ulalume3@0 1793 print(LID)
ulalume3@0 1794 print("LDRtrue, LDRmin, LDRmax")
ulalume3@0 1795 for i in range(len(LDRrange)):
ulalume3@0 1796 print("{0:7.4f},{1:7.4f},{2:7.4f}".format(LDRrange[i], LDRmin[i], LDRmax[i]))
ulalume3@0 1797
ulalume3@0 1798 '''
ulalume3@0 1799 # --- Plot K over LDRCal
ulalume3@0 1800 fig3 = plt.figure()
ulalume3@0 1801 plt.plot(LDRCal0+aLDRCal*dLDRCal/nLDRCal,aX[4,:], linewidth=2.0, color='b')
ulalume3@0 1802
ulalume3@0 1803 plt.xlabel('LDRCal', fontsize=18)
ulalume3@0 1804 plt.ylabel('K', fontsize=14)
ulalume3@0 1805 plt.title(LID, fontsize=18)
ulalume3@0 1806 plt.show()
ulalume3@0 1807 plt.close
ulalume3@0 1808 '''
ulalume3@0 1809
ulalume3@0 1810 # Additional plot routines ======>
ulalume3@0 1811 '''
ulalume3@0 1812 #******************************************************************************
ulalume3@0 1813 # 1. Plot LDRcorrected - LDR(measured Icross/Iparallel)
ulalume3@0 1814 LDRa = np.arange(1.,100.)*0.005
ulalume3@0 1815 LDRCorra = np.arange(1.,100.)
ulalume3@0 1816 if Y == - 1.: LDRa = 1./LDRa
ulalume3@0 1817 LDRCorra = (1./Eta*LDRa*(GT+HT)-(GR+HR))/((GR-HR)-1./Eta*LDRa*(GT-HT))
ulalume3@0 1818 if Y == - 1.: LDRa = 1./LDRa
ulalume3@0 1819 #
ulalume3@0 1820 #fig = plt.figure()
ulalume3@0 1821 plt.plot(LDRa,LDRCorra-LDRa)
ulalume3@0 1822 plt.plot([0.,0.5],[0.,0.5])
ulalume3@0 1823 plt.suptitle('LDRcorrected - LDR(measured Icross/Iparallel)', fontsize=16)
ulalume3@0 1824 plt.xlabel('LDR', fontsize=18)
ulalume3@0 1825 plt.ylabel('LDRCorr - LDR', fontsize=16)
ulalume3@0 1826 #plt.savefig('test.png')
ulalume3@0 1827 #
ulalume3@0 1828 '''
ulalume3@0 1829 '''
ulalume3@0 1830 #******************************************************************************
ulalume3@0 1831 # 2. Plot LDRsim (simulated measurements without corrections = Icross/Iparallel) over LDRtrue
ulalume3@0 1832 LDRa = np.arange(1.,100.)*0.005
ulalume3@0 1833 LDRsima = np.arange(1.,100.)
ulalume3@0 1834
ulalume3@0 1835 atruea = (1.-LDRa)/(1+LDRa)
ulalume3@0 1836 Ita = TiT*TiO*IinL*(GT+atruea*HT)
ulalume3@0 1837 Ira = TiR*TiO*IinL*(GR+atruea*HR)
ulalume3@0 1838 LDRsima = Ira/Ita # simulated uncorrected LDR with Y from input file
ulalume3@0 1839 if Y == -1.: LDRsima = 1./LDRsima
ulalume3@0 1840 #
ulalume3@0 1841 #fig = plt.figure()
ulalume3@0 1842 plt.plot(LDRa,LDRsima)
ulalume3@0 1843 plt.plot([0.,0.5],[0.,0.5])
ulalume3@0 1844 plt.suptitle('LDRsim (simulated measurements without corrections = Icross/Iparallel) over LDRtrue', fontsize=10)
ulalume3@0 1845 plt.xlabel('LDRtrue', fontsize=18)
ulalume3@0 1846 plt.ylabel('LDRsim', fontsize=16)
ulalume3@0 1847 #plt.savefig('test.png')
ulalume3@0 1848 #
ulalume3@0 1849 '''

mercurial