;+ ; Convert the temperature in the telemetry file (or fits headers) from ADUs to decrees ; ; :Params: ; cryo : in, required, type=int ; cryo cycle at LMAT, either 1, 2, or 3 ; tmc : in, required, type=int ; flag, either 1 or 2, due to a change of set point/calibration; in the .csv file name ; module : in, required, type=string ; NIRCAM module, either 'A" or 'B' ; channel : in, required, type=string ; NIRCAM channel, either 'SW' or 'LW' ; Itmc : in, required, type=float ; telemetry value in input to be converted ; fpa_temp : out, required, type=float ; temperature in output ;- pro temp_convert, cryo, tmc, module, channel, Itmc, fpa_temp Vref = 0.01 ScalFac = 1.53e-04 fa_tmc1_sw = [ 5.37E+01, -4.44E+01, 1.03E+01, -1.62E+00, 1.88E-01, -1.27E-02, -0.000511, 0.00E+00, 0.00E+00, 2.732769204, 3.965444954] fa_tmc1_lw = [ 5.42E+01, -44.649865, 9.669200, -1.317193, 0.125655, -0.001803, -0.001624, 0.00E+00, 0.00E+00, 2.812958836, 3.822134036] fa_tmc2_sw = [ 5.37E+01, -4.44E+01, 1.03E+01, -1.62E+00, 1.89E-01, -1.30E-02, 0.00E+00, 0.00E+00, 0.00E+00, 2.695267065, 3.903767789] fa_tmc2_lw = [54.394900, -44.761453, 9.687855, -1.315860, 0.123408, -0.001315, -0.000942, -0.000507, 0.000607, 2.816966829, 3.824636721] fb_tmc1_sw = [ 5.34E+01, -4.43E+01, 1.05E+01, -1.73E+00, 2.19E-01, -2.00E-02, 0.001338, 0.00E+00, 0.00E+00, 3.060816014, 4.568445635] fb_tmc1_lw = [ 5.34E+01, -4.43E+01, 1.06E+01, -1.75E+00, 2.23E-01, -1.98E-02, 0.00E+00, 0.00E+00, 0.00E+00, 3.031019001, 4.523140792] fb_tmc2_sw = [ 5.34E+01, -4.43E+01, 1.05E+01, -1.71E+00, 2.10E-01, -1.76E-02, 1.09E-03, 0.00E+00, 0.00E+00, 2.975591580, 4.415748619] fb_tmc2_lw = [53.400645, -4.43E+01, 1.05E+01, -1.73E+00, 2.17E-01, -1.85E-02, 0.00E+00, 0.00E+00, 0.00E+00, 2.992098801, 4.445425972] if (cryo lt 3) then begin Itmc /= ScalFac if (Itmc lt 0) then Itmc += 65536 case tmc of 1: begin if ((module eq 'A') and (channel eq 'SW')) then Itmc += -96 if ((module eq 'A') and (channel eq 'LW')) then Itmc += 5 if ((module eq 'B') and (channel eq 'SW')) then Itmc += -4 if ((module eq 'B') and (channel eq 'LW')) then Itmc += 79 end 2: begin if ((module eq 'A') and (channel eq 'SW')) then Itmc += -106 if ((module eq 'A') and (channel eq 'LW')) then Itmc += -35 if ((module eq 'B') and (channel eq 'SW')) then Itmc += -25 if ((module eq 'B') and (channel eq 'LW')) then Itmc += 67 end endcase if (Itmc gt 32767) then begin Itmc = (Itmc - 65536.) * ScalFac endif else begin Itmc *= ScalFac endelse endif case tmc of 1 : begin if ((module eq 'A') and (channel eq 'SW')) then c = fa_tmc1_sw if ((module eq 'A') and (channel eq 'LW')) then c = fa_tmc1_lw if ((module eq 'B') and (channel eq 'SW')) then c = fb_tmc1_sw if ((module eq 'B') and (channel eq 'LW')) then c = fb_tmc1_lw end 2: begin if ((module eq 'A') and (channel eq 'SW')) then c = fa_tmc2_sw if ((module eq 'A') and (channel eq 'LW')) then c = fa_tmc2_lw if ((module eq 'B') and (channel eq 'SW')) then c = fb_tmc2_sw if ((module eq 'B') and (channel eq 'LW')) then c = fb_tmc2_lw end endcase Rohm = 3.0E+05 * Vref / Itmc logR = alog10(Rohm) k = ((logR - c(9)) - (c(10) - logR)) / (c(10) - c(9)) acosk = acos(k) fpa_temp = 0. for i = 0,8 do fpa_temp += c(i) * cos(i*acosk) fpa_temp = strtrim(string(fpa_temp), 2) end