Wed, 07 Jul 2021 16:00:34 +0200
Merge
Volker@40 | 1 | # This Python script will be executed from within the main lidar_correction_ghk.py |
Volker@40 | 2 | # Probably it will be better in the future to let the main script rather read a conguration file, |
Volker@40 | 3 | # which might improve the portability of the code within an executable. |
Volker@40 | 4 | # Due to problems I had with some two letter variables, most variables are now with at least |
Volker@40 | 5 | # three letters mixed small and capital. |
Volker@40 | 6 | # To be used with lidar_correction_ghk.py ver. 0.9.5 and larger |
Volker@40 | 7 | |
Volker@40 | 8 | # Do you want to calculate the errors? If not, just the GHK-parameters are determined. |
Volker@40 | 9 | Error_Calc = True |
Volker@40 | 10 | |
Volker@40 | 11 | # Header to identify the lidar system |
Volker@40 | 12 | EID = "li" # Earlinet station ID |
Volker@40 | 13 | LID = "PollyXT Lacros Limassol" # Additional lidar ID (short descriptive text) |
Volker@40 | 14 | print(" Lidar system :", EID, ", ", LID) |
Volker@40 | 15 | |
Volker@40 | 16 | # +++ IL Laser and +-Uncertainty |
Volker@40 | 17 | Qin, dQin, nQin = 1.0, 0.0, 0 # second Stokes vector parameter; default 1 => linear polarization 0.999 => LDR = 0.0005 |
Volker@40 | 18 | Vin, dVin, nVin = 0.0, 0.0, 0 # fourth Stokes vector parameter; default 0 => corresponds to LDR 0.0005 with DOP 1 |
Volker@40 | 19 | RotL, dRotL, nRotL = 90.0, 1.0, 1 #alpha; rotation of laser polarization in degrees; alle wellenlängen im PollyXT Lacros sind vertical zum opt. Tisch polarisiert. |
Volker@40 | 20 | |
Volker@40 | 21 | # +++ ME Emitter optics and +-Uncertainty; default = no emitter optics |
Volker@40 | 22 | DiE, dDiE, nDiE = 0.0, 0.02, 0 # Diattenuation |
Volker@40 | 23 | TiE = 1.0 # Unpolarized transmittance |
Volker@40 | 24 | RetE, dRetE, nRetE = 0., 180., 0 # Retardance in degrees |
Volker@40 | 25 | RotE, dRotE, nRotE = 0., 1.0, 0 # beta: Rotation of the optical element in degrees |
Volker@40 | 26 | |
Volker@40 | 27 | # +++ MO Receiver optics including telescope |
Volker@40 | 28 | DiO, dDiO, nDiO = 0.0, 0.0, 0 # Diattenuation |
Volker@40 | 29 | TiO = 1.0 # Unpolarized transmittance |
Volker@40 | 30 | RetO, dRetO, nRetO = 0., 180., 0 # Retardance in degrees |
Volker@40 | 31 | RotO, dRotO, nRotO = 0., 0.5, 0 # gamma: Rotation of the optical element in degrees |
Volker@40 | 32 | |
Volker@40 | 33 | # +++++ PBS MT Transmitting path defined with TS, TP, PolFilter extinction ratio ERaT, and +-Uncertainty |
Volker@40 | 34 | # --- Polarizing beam splitter transmitting path |
Volker@40 | 35 | TP, dTP, nTP = 0.50, 1.0, 0 # transmittance of the PBS for parallel polarized light |
Volker@40 | 36 | TS, dTS, nTS = 0.50, 1.0, 0 # transmittance of the PBS for cross polarized light |
Volker@40 | 37 | RetT, dRetT, nRetT = 0.0, 180., 0 # Retardance in degrees |
Volker@40 | 38 | # --- Pol.Filter behind transmitted path of PBS |
Volker@40 | 39 | ERaT, dERaT, nERaT = 0.00075, 0.00025, 0 # Extinction ratio |
Volker@40 | 40 | RotaT, dRotaT, nRotaT = 0., 1., 1 # Rotation of the Pol.-filter in degrees; usually close to 0° because TP >> TS, but for PollyXTs it can also be close to 90° |
Volker@40 | 41 | # -- |
Volker@40 | 42 | TiT = 0.5 * (TP + TS) # do not change this |
Volker@40 | 43 | DiT = (TP-TS)/(TP+TS) # do not change this |
Volker@40 | 44 | DaT = (1-ERaT)/(1+ERaT) # do not change this |
Volker@40 | 45 | TaT = 0.5*(1+ERaT) # do not change this |
Volker@40 | 46 | |
Volker@40 | 47 | # +++++ PBS MR Reflecting path defined with RS, RP, and cleaning PolFilter extinction ratio ERaR and +-Uncertainty |
Volker@40 | 48 | # ---- for PBS without absorption the change of RS and RP must depend on the change of TP and TS. Hence the values and uncertainties are not independent. |
Volker@40 | 49 | RS_RP_depend_on_TS_TP = True |
Volker@40 | 50 | # --- Polarizing beam splitter reflecting path |
Volker@40 | 51 | if(RS_RP_depend_on_TS_TP): |
Volker@40 | 52 | RP, dRP, nRP = 1-TP, 0.00, 0 # do not change this |
Volker@40 | 53 | RS, dRS, nRS = 1-TS, 0.00, 0 # do not change this |
Volker@40 | 54 | else: |
Volker@40 | 55 | RP, dRP, nRP = 0.5, 0.01, 0 # change this if RS_RP_depend_on_TS_TP = False; reflectance of the PBS for parallel polarized light |
Volker@40 | 56 | RS, dRS, nRS = 0.5, 0.01, 0 # change this if RS_RP_depend_on_TS_TP = False; reflectance of the PBS for cross polarized light |
Volker@40 | 57 | RetR, dRetR, nRetR = 0.0, 180., 0 # Retardance in degrees |
Volker@40 | 58 | # --- Pol.Filter behind reflected path of PBS |
Volker@40 | 59 | ERaR, dERaR, nERaR = 1.0, 0.0, 0 # Extinction ratio |
Volker@40 | 60 | RotaR, dRotaR, nRotaR = 0., 1., 0 # Rotation of the Pol.-filter in degrees; usually close to 90° because RS >> RP, but for PollyXTs it can also be close to 0° |
Volker@40 | 61 | # -- |
Volker@40 | 62 | TiR = 0.5 * (RP + RS) # do not change this |
Volker@40 | 63 | DiR = (RP-RS)/(RP+RS) # do not change this |
Volker@40 | 64 | DaR = (1-ERaR)/(1+ERaR) # do not change this |
Volker@40 | 65 | TaR = 0.5*(1+ERaR) # do not change this |
Volker@40 | 66 | |
Volker@40 | 67 | # NEW --- Additional ND filter transmission (attenuation) during the calibration |
Volker@40 | 68 | TCalT, dTCalT, nTCalT = 1, 0.01, 0 # transmitting path, default 1, 0, 0 |
Volker@40 | 69 | TCalR, dTCalR, nTCalR = 1, 0.0001, 0 # reflecting path, default 1, 0, 0 |
Volker@40 | 70 | |
Volker@40 | 71 | # +++ Orientation of the PBS with respect to the reference plane (see Improvements_of_lidar_correction_ghk_ver.0.9.8_190124.pdf) |
Volker@40 | 72 | # Y = +1: polarisation in reference plane is finally transmitted, |
Volker@40 | 73 | # Y = -1: polarisation in reference plane is finally reflected. |
Volker@40 | 74 | Y = +1. |
Volker@40 | 75 | |
Volker@40 | 76 | # +++ Calibrator |
Volker@40 | 77 | # --- Calibrator Type used; defined by matrix values below |
Volker@40 | 78 | TypeC = 3 #Type of calibrator: 1 = mechanical rotator; 2 = hwp rotator (fixed retardation); 3 = linear polarizer; 4 = qwp; 5 = circular polarizer; 6 = real HWP calibration +-22.5° |
Volker@40 | 79 | # --- Calibrator Location |
Volker@40 | 80 | LocC = 3 #location of calibrator: 1 = behind laser; 2 = behind emitter; 3 = before receiver; 4 = before PBS |
Volker@40 | 81 | # --- MC Calibrator parameters |
Volker@40 | 82 | if TypeC == 1: #mechanical rotator |
Volker@40 | 83 | DiC, dDiC, nDiC = 0., 0., 0 # Diattenuation |
Volker@40 | 84 | TiC = 1. |
Volker@40 | 85 | RetC, dRetC, nRetC = 0., 0., 0 # Retardance in degrees |
Volker@40 | 86 | RotC, dRotC, nRotC = 0., 1.0, 1 #constant calibrator rotation offset epsilon |
Volker@40 | 87 | # Rotation error without calibrator: if False, then epsilon = 0 for normal measurements |
Volker@40 | 88 | RotationErrorEpsilonForNormalMeasurements = True # is in general True for TypeC == 1 calibrator |
Volker@40 | 89 | elif TypeC == 2: # HWP simulated by rotator without retardance! |
Volker@40 | 90 | DiC, dDiC, nDiC = 0., 0., 0 # Diattenuation; ideal 0.0 |
Volker@40 | 91 | TiC = 1. |
Volker@40 | 92 | RetC, dRetC, nRetC = 180., 0., 0 # Retardance in degrees |
Volker@40 | 93 | #NOTE: use here twice the HWP-rotation-angle |
Volker@40 | 94 | RotC, dRotC, nRotC = 0.0, 0.1, 1 #constant calibrator rotation offset epsilon |
Volker@40 | 95 | RotationErrorEpsilonForNormalMeasurements = True # is in general True for TypeC == 2 calibrator |
Volker@40 | 96 | elif TypeC == 3: # linear polarizer calibrator. Diattenuation DiC = (1-ERC)/(1+ERC); ERC = extinction ratio of calibrator |
Volker@40 | 97 | DiC, dDiC, nDiC = 0.9985, 0.0005, 1 # Diattenuation; ideal 1.0 |
Volker@40 | 98 | TiC = 0.4 # ideal 0.5 |
Volker@40 | 99 | RetC, dRetC, nRetC = 0., 0., 0 # Retardance in degrees |
Volker@40 | 100 | RotC, dRotC, nRotC = 0.0, 0.1, 0 #constant calibrator rotation offset epsilon |
Volker@40 | 101 | RotationErrorEpsilonForNormalMeasurements = False # is in general False for TypeC == 3 calibrator |
Volker@40 | 102 | elif TypeC == 4: # QWP calibrator |
Volker@40 | 103 | DiC, dDiC, nDiC = 0.0, 0., 0 # Diattenuation; ideal 0.0 |
Volker@40 | 104 | TiC = 1.0 # ideal 0.5 |
Volker@40 | 105 | RetC, dRetC, nRetC = 90., 0., 0 # Retardance in degrees |
Volker@40 | 106 | RotC, dRotC, nRotC = 0.0, 0.1, 1 #constant calibrator rotation offset epsilon |
Volker@40 | 107 | RotationErrorEpsilonForNormalMeasurements = False # is False for TypeC == 4 calibrator |
Volker@40 | 108 | elif TypeC == 6: # real half-wave plate rotator calibration at +-22.5° => rotated_diattenuator_X22x5deg.odt |
Volker@40 | 109 | DiC, dDiC, nDiC = 0., 0., 0 # Diattenuation; ideal 0.0 |
Volker@40 | 110 | TiC = 1. |
Volker@40 | 111 | RetC, dRetC, nRetC = 180., 0., 0 # Retardance in degrees |
Volker@40 | 112 | #Note: use real HWP angles here |
Volker@40 | 113 | RotC, dRotC, nRotC = 0.0, 0.1, 1 #constant calibrator rotation offset epsilon |
Volker@40 | 114 | RotationErrorEpsilonForNormalMeasurements = True # is in general True for TypeC == 6 calibrator |
Volker@40 | 115 | else: |
Volker@40 | 116 | print ('calibrator not implemented yet') |
Volker@40 | 117 | sys.exit() |
Volker@40 | 118 | |
Volker@40 | 119 | # --- LDRCal assumed atmospheric linear depolarization ratio during the calibration measurements in calibration range with almost clean air (first guess) |
Volker@40 | 120 | # LDRCal,dLDRCal,nLDRCal= 0.2, 0.15, 1 # spans most of the atmospheric depolarisation variability |
Volker@40 | 121 | LDRCal,dLDRCal,nLDRCal= 0.009, 0.005, 1 # spans the interference filter influence |
Volker@40 | 122 | |
Volker@40 | 123 | # ==================================================== |
Volker@40 | 124 | # NOTE: there is no need to change anything below. |
Volker@40 | 125 | # ==================================================== |
Volker@40 | 126 | # !!! don't change anything in this section !!! |
Volker@40 | 127 | bPlotEtax = False # plot error histogramms for Etax |
Volker@40 | 128 | # NEW *** Only for signal noise errors *** |
Volker@40 | 129 | nNCal = 0 # error nNCal, calibration signals: one-sigma (fixed) in nNCal steps to left and right |
Volker@40 | 130 | nNI = 0 # error nNI, 0° signals: one-sigma (fixed) in nNI steps to left and right; NI signals are calculated from NCalT and NCalR in main programm, but noise is assumed to be independent. |
Volker@40 | 131 | |
Volker@40 | 132 | # --- number of photon counts in the signal summed up in the calibration range during the calibration measurements |
Volker@40 | 133 | NCalT = 40000 # default 1e6, assumed the same in +45° and -45° signals; counts with ND-filter TCalT |
Volker@40 | 134 | NCalR = 40000 # default 1e6, assumed the same in +45° and -45° signals; counts with ND-filter TCalR |
Volker@40 | 135 | NILfac = 1 # (relative duration (laser shots) of standard (0°) measurement to calibration measurements) * (range of std. meas. smoothing / calibration range); example: 100000#/5000# * 100/1000 = 2 |
Volker@40 | 136 | # LDRmeas below will be used to calculate IR and IT of 0° signals. |
Volker@40 | 137 | # calculate signal counts only from parallel 0° signal assuming the same electronic amplification in both channels; overwrites above values |
Volker@40 | 138 | CalcFrom0deg = True |
Volker@40 | 139 | NI = 100000000 #number of photon counts in the parallel 0°-signal 40000 |
Volker@40 | 140 | |
Volker@40 | 141 | if(CalcFrom0deg): |
Volker@40 | 142 | # either eFactT or eFacR is = 1 => rel. amplification |
Volker@40 | 143 | eFacT = 1 # rel. amplification of transmitted channel, approximate values are sufficient; def. = 1 |
Volker@40 | 144 | eFacR = 1 # rel. amplification of reflected channel, approximate values are sufficient; def. = 1 |
Volker@40 | 145 | NILfac = 1 # (relative duration (laser shots) of standard (0°) measurement to calibration measurements) * (range of std. meas. smoothing / calibration range); example: 100000#/5000# * 100/1000 = 2 |
Volker@40 | 146 | |
Volker@40 | 147 | NCalT = NI / NILfac * TCalT * eFacT # photon counts in transmitted signal during calibration |
Volker@40 | 148 | NCalR = NI / NILfac * TCalR * eFacR # photon counts in reflected signal during calibration |
Volker@40 | 149 | # LDRmeas below will be used to calculate IR and IT of 0° signals. |
Volker@40 | 150 | # NEW *** End of signal noise error parameters *** |
Volker@40 | 151 | |
Volker@40 | 152 | # --- LDRtrue for simulation of measurement => LDRsim |
Volker@40 | 153 | LDRtrue = 0.004 |
Volker@40 | 154 | LDRtrue2 = 0.004 |
Volker@40 | 155 | |
Volker@40 | 156 | # --- measured LDRm will be corrected with calculated parameters GHK |
Volker@40 | 157 | LDRmeas = 0.3 |
Volker@40 | 158 | |
Volker@40 | 159 | # --- this is just for correct transfer of the variables to the main file |
Volker@40 | 160 | Qin0, dQin, nQin = Qin, dQin, nQin |
Volker@40 | 161 | Vin0, dVin, nVin = Vin, dVin, nVin |
Volker@40 | 162 | RotL0, dRotL, nRotL = RotL, dRotL, nRotL |
Volker@40 | 163 | # Emitter |
Volker@40 | 164 | DiE0, dDiE, nDiE = DiE, dDiE, nDiE |
Volker@40 | 165 | RetE0, dRetE, nRetE = RetE, dRetE, nRetE |
Volker@40 | 166 | RotE0, dRotE, nRotE = RotE, dRotE, nRotE |
Volker@40 | 167 | # Receiver |
Volker@40 | 168 | DiO0, dDiO, nDiO = DiO, dDiO, nDiO |
Volker@40 | 169 | RetO0, dRetO, nRetO = RetO, dRetO, nRetO |
Volker@40 | 170 | RotO0, dRotO, nRotO = RotO, dRotO, nRotO |
Volker@40 | 171 | # Calibrator |
Volker@40 | 172 | DiC0, dDiC, nDiC = DiC, dDiC, nDiC |
Volker@40 | 173 | RetC0, dRetC, nRetC = RetC, dRetC, nRetC |
Volker@40 | 174 | RotC0, dRotC, nRotC = RotC, dRotC, nRotC |
Volker@40 | 175 | # PBS |
Volker@40 | 176 | TP0, dTP, nTP = TP, dTP, nTP |
Volker@40 | 177 | TS0, dTS, nTS = TS, dTS, nTS |
Volker@40 | 178 | RetT0, dRetT, nRetT = RetT, dRetT, nRetT |
Volker@40 | 179 | |
Volker@40 | 180 | ERaT0, dERaT, nERaT = ERaT, dERaT, nERaT |
Volker@40 | 181 | RotaT0,dRotaT,nRotaT= RotaT,dRotaT,nRotaT |
Volker@40 | 182 | |
Volker@40 | 183 | RP0, dRP, nRP = RP, dRP, nRP |
Volker@40 | 184 | RS0, dRS, nRS = RS, dRS, nRS |
Volker@40 | 185 | RetR0, dRetR, nRetR = RetR, dRetR, nRetR |
Volker@40 | 186 | |
Volker@40 | 187 | ERaR0, dERaR, nERaR = ERaR, dERaR, nERaR |
Volker@40 | 188 | RotaR0,dRotaR,nRotaR= RotaR,dRotaR,nRotaR |
Volker@40 | 189 | |
Volker@40 | 190 | LDRCal0,dLDRCal,nLDRCal=LDRCal,dLDRCal,nLDRCal |