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