Skip to content
Snippets Groups Projects
Commit 72adaa7b authored by Marko Mecina's avatar Marko Mecina
Browse files

add calibration for IWF EGSE CCD temp and ADC_I_HEATER

parent 168cf2a7
Branches
No related tags found
No related merge requests found
...@@ -3,6 +3,7 @@ IWF EGSE communication library ...@@ -3,6 +3,7 @@ IWF EGSE communication library
Ref: SMILE-IWF-PL-IF-048 Ref: SMILE-IWF-PL-IF-048
""" """
import numpy as np
PORT = 8089 PORT = 8089
...@@ -45,6 +46,13 @@ RESPONSE_ID = { ...@@ -45,6 +46,13 @@ RESPONSE_ID = {
} }
# load calibration curve for CCD temperature to PWM set point
try:
_pwm_t_cal = np.loadtxt('ccd_pwm_t_cal.dat', unpack=True)
except FileNotFoundError:
_pwm_t_cal = None
class Command: class Command:
# GENERAL # GENERAL
...@@ -325,3 +333,52 @@ def response_proc_func(rawdata): ...@@ -325,3 +333,52 @@ def response_proc_func(rawdata):
pkts.remove(b'') pkts.remove(b'')
proc_pkts = [(RESPONSE_ID.get(pkt[0:1], 'UKNOWN'), pkt.decode('ascii', errors='replace')) for pkt in pkts] proc_pkts = [(RESPONSE_ID.get(pkt[0:1], 'UKNOWN'), pkt.decode('ascii', errors='replace')) for pkt in pkts]
return proc_pkts return proc_pkts
def ccd_pwm_from_temp(t, cal_file=None):
"""
Calculate the pwm value for EGSE command set_pwm from temperature *t*, according to pwm_t_cal
:param t:
:param cal_file:
:return:
"""
if cal_file is not None:
cal = np.loadtxt(cal_file, unpack=True)
pwm = np.round(np.interp(t, *cal, left=-1, right=-1))
else:
if _pwm_t_cal is not None:
pwm = np.round(np.interp(t, *_pwm_t_cal, left=-1, right=-1))
else:
print('No calibration curve defined')
return
if isinstance(pwm, np.ndarray):
return np.array(pwm, dtype=int)
else:
return int(pwm)
def adu_to_ana_adcihtr(adu):
"""
Calculate the 'analogue' value IWF_EGSE_I_HEATER needed for set_psu_analogue_value that corresponds to the equivalent digital HK ADU value
:param adu:
:return:
"""
# this has linear behaviour
adu_min = 3950
adu_max = 12650
ana_min = 0
ana_max = 3276
if adu < adu_min:
return adu_min
elif adu > adu_max:
return adu_max
else:
return ((adu - adu_min) / (adu_max - adu_min)) * (ana_max - ana_min)
# calibration curve for CCD temperature to PWM set point (IWF EGSE)
-140.000 2300
-139.993 2299
-139.972 2298
-139.950 2297
-139.926 2296
-139.897 2295
-139.882 2294
-139.853 2293
-139.824 2292
-139.812 2291
-139.794 2290
-139.767 2289
-139.759 2288
-139.741 2287
-139.715 2286
-139.688 2285
-139.660 2284
-139.639 2283
-139.616 2282
-139.597 2281
-139.571 2280
-139.551 2279
-139.532 2278
-139.507 2277
-139.489 2276
-139.461 2275
-139.433 2274
-139.412 2273
-139.387 2272
-139.358 2271
-139.340 2270
-139.319 2269
-139.303 2268
-139.287 2267
-139.247 2266
-139.225 2265
-139.204 2264
-139.180 2263
-139.152 2262
-139.135 2261
-139.118 2260
-139.094 2259
-139.069 2258
-139.044 2257
-139.017 2256
-138.995 2255
-138.976 2254
-138.946 2253
-138.918 2252
-138.888 2251
-138.865 2250
-138.845 2249
-138.826 2248
-138.807 2247
-138.792 2246
-138.765 2245
-138.739 2244
-138.723 2243
-138.697 2242
-138.681 2241
-138.657 2240
-138.636 2239
-138.609 2238
-138.596 2237
-138.561 2236
-138.529 2235
-138.505 2234
-138.477 2233
-138.460 2232
-138.436 2231
-138.414 2230
-138.387 2229
-138.365 2228
-138.345 2227
-138.320 2226
-138.300 2225
-138.278 2224
-138.256 2223
-138.226 2222
-138.197 2221
-138.177 2220
-138.150 2219
-138.116 2218
-138.088 2217
-138.058 2216
-138.024 2215
-137.991 2214
-137.962 2213
-137.925 2212
-137.903 2211
-137.882 2210
-137.860 2209
-137.834 2208
-137.802 2207
-137.776 2206
-137.739 2205
-137.714 2204
-137.686 2203
-137.657 2202
-137.643 2201
-137.616 2200
-137.584 2199
-137.547 2198
-137.527 2197
-137.513 2196
-137.484 2195
-137.449 2194
-137.424 2193
-137.396 2192
-137.363 2191
-137.346 2190
-137.328 2189
-137.301 2188
-137.272 2187
-137.250 2186
-137.219 2185
-137.191 2184
-137.172 2183
-137.151 2182
-137.131 2181
-137.109 2180
-137.088 2179
-137.065 2178
-137.039 2177
-137.008 2176
-136.979 2175
-136.952 2174
-136.934 2173
-136.904 2172
-136.861 2171
-136.832 2170
-136.810 2169
-136.781 2168
-136.750 2167
-136.739 2166
-136.712 2165
-136.679 2164
-136.652 2163
-136.631 2162
-136.604 2161
-136.578 2160
-136.554 2159
-136.525 2158
-136.492 2157
-136.460 2156
-136.435 2155
-136.400 2154
-136.375 2153
-136.349 2152
-136.317 2151
-136.289 2150
-136.259 2149
-136.223 2148
-136.197 2147
-136.173 2146
-136.149 2145
-136.114 2144
-136.089 2143
-136.069 2142
-136.043 2141
-136.009 2140
-135.987 2139
-135.957 2138
-135.929 2137
-135.900 2136
-135.871 2135
-135.842 2134
-135.812 2133
-135.784 2132
-135.748 2131
-135.711 2130
-135.680 2129
-135.646 2128
-135.614 2127
-135.588 2126
-135.563 2125
-135.540 2124
-135.511 2123
-135.479 2122
-135.451 2121
-135.417 2120
-135.401 2119
-135.369 2118
-135.337 2117
-135.295 2116
-135.263 2115
-135.225 2114
-135.198 2113
-135.165 2112
-135.132 2111
-135.098 2110
-135.067 2109
-135.039 2108
-135.000 2107
-134.960 2106
-134.939 2105
-134.923 2104
-134.891 2103
-134.859 2102
-134.827 2101
-134.793 2100
-134.750 2099
-134.714 2098
-134.673 2097
-134.634 2096
-134.603 2095
-134.568 2094
-134.536 2093
-134.500 2092
-134.482 2091
-134.455 2090
-134.434 2089
-134.384 2088
-134.356 2087
-134.317 2086
-134.292 2085
-134.266 2084
-134.236 2083
-134.212 2082
-134.191 2081
-134.147 2080
-134.103 2079
-134.069 2078
-134.047 2077
-134.016 2076
-133.981 2075
-133.963 2074
-133.935 2073
-133.900 2072
-133.873 2071
-133.834 2070
-133.800 2069
-133.763 2068
-133.730 2067
-133.682 2066
-133.648 2065
-133.609 2064
-133.583 2063
-133.545 2062
-133.521 2061
-133.466 2060
-133.431 2059
-133.386 2058
-133.359 2057
-133.323 2056
-133.296 2055
-133.263 2054
-133.229 2053
-133.188 2052
-133.147 2051
-133.109 2050
-133.062 2049
-133.023 2048
-132.994 2047
-132.959 2046
-132.943 2045
-132.908 2044
-132.871 2043
-132.837 2042
-132.800 2041
-132.755 2040
-132.715 2039
-132.682 2038
-132.649 2037
-132.607 2036
-132.580 2035
-132.534 2034
-132.503 2033
-132.449 2032
-132.412 2031
-132.371 2030
-132.334 2029
-132.296 2028
-132.262 2027
-132.227 2026
-132.190 2025
-132.152 2024
-132.119 2023
-132.091 2022
-132.048 2021
-132.009 2020
-131.970 2019
-131.936 2018
-131.902 2017
-131.864 2016
-131.835 2015
-131.798 2014
-131.759 2013
-131.719 2012
-131.681 2011
-131.641 2010
-131.615 2009
-131.574 2008
-131.549 2007
-131.513 2006
-131.475 2005
-131.431 2004
-131.392 2003
-131.350 2002
-131.301 2001
-131.261 2000
-131.223 1999
-131.180 1998
-131.138 1997
-131.108 1996
-131.059 1995
-131.017 1994
-130.970 1993
-130.926 1992
-130.887 1991
-130.850 1990
-130.807 1989
-130.767 1988
-130.716 1987
-130.667 1986
-130.632 1985
-130.582 1984
-130.541 1983
-130.496 1982
-130.456 1981
-130.418 1980
-130.384 1979
-130.336 1978
-130.286 1977
-130.251 1976
-130.209 1975
-130.179 1974
-130.134 1973
-130.103 1972
-130.054 1971
-129.997 1970
-129.951 1969
-129.913 1968
-129.869 1967
-129.823 1966
-129.780 1965
-129.732 1964
-129.692 1963
-129.660 1962
-129.620 1961
-129.577 1960
-129.525 1959
-129.481 1958
-129.433 1957
-129.385 1956
-129.337 1955
-129.287 1954
-129.249 1953
-129.210 1952
-129.163 1951
-129.117 1950
-129.063 1949
-129.019 1948
-128.959 1947
-128.908 1946
-128.876 1945
-128.827 1944
-128.777 1943
-128.734 1942
-128.675 1941
-128.612 1940
-128.566 1939
-128.508 1938
-128.453 1937
-128.408 1936
-128.362 1935
-128.319 1934
-128.264 1933
-128.215 1932
-128.160 1931
-128.118 1930
-128.063 1929
-128.009 1928
-127.950 1927
-127.900 1926
-127.853 1925
-127.807 1924
-127.751 1923
-127.702 1922
-127.656 1921
-127.609 1920
-127.561 1919
-127.507 1918
-127.449 1917
-127.410 1916
-127.365 1915
-127.314 1914
-127.274 1913
-127.219 1912
-127.166 1911
-127.113 1910
-127.060 1909
-127.010 1908
-126.954 1907
-126.900 1906
-126.840 1905
-126.793 1904
-126.737 1903
-126.688 1902
-126.637 1901
-126.576 1900
-126.515 1899
-126.457 1898
-126.401 1897
-126.349 1896
-126.288 1895
-126.221 1894
-126.168 1893
-126.106 1892
-126.041 1891
-125.987 1890
-125.930 1889
-125.867 1888
-125.820 1887
-125.767 1886
-125.702 1885
-125.641 1884
-125.580 1883
-125.523 1882
-125.469 1881
-125.409 1880
-125.341 1879
-125.285 1878
-125.216 1877
-125.150 1876
-125.093 1875
-125.041 1874
-124.981 1873
-124.913 1872
-124.848 1871
-124.782 1870
-124.735 1869
-124.671 1868
-124.611 1867
-124.556 1866
-124.492 1865
-124.424 1864
-124.359 1863
-124.291 1862
-124.218 1861
-124.156 1860
-124.098 1859
-124.028 1858
-123.956 1857
-123.883 1856
-123.812 1855
-123.750 1854
-123.682 1853
-123.622 1852
-123.552 1851
-123.480 1850
-123.396 1849
-123.339 1848
-123.271 1847
-123.198 1846
-123.128 1845
-123.050 1844
-122.989 1843
-122.916 1842
-122.847 1841
-122.776 1840
-122.708 1839
-122.635 1838
-122.554 1837
-122.481 1836
-122.406 1835
-122.331 1834
-122.268 1833
-122.197 1832
-122.123 1831
-122.044 1830
-121.978 1829
-121.891 1828
-121.813 1827
-121.732 1826
-121.658 1825
-121.586 1824
-121.499 1823
-121.428 1822
-121.354 1821
-121.276 1820
-121.203 1819
-121.117 1818
-121.041 1817
-120.959 1816
-120.874 1815
-120.785 1814
-120.707 1813
-120.628 1812
-120.547 1811
-120.460 1810
-120.374 1809
-120.279 1808
-120.194 1807
-120.114 1806
-120.038 1805
-119.945 1804
-119.876 1803
-119.784 1802
-119.702 1801
-119.615 1800
-119.528 1799
-119.438 1798
-119.353 1797
-119.257 1796
-119.167 1795
-119.068 1794
-118.978 1793
-118.885 1792
-118.797 1791
-118.706 1790
-118.616 1789
-118.528 1788
-118.437 1787
-118.343 1786
-118.250 1785
-118.147 1784
-118.057 1783
-117.963 1782
-117.860 1781
-117.759 1780
-117.654 1779
-117.552 1778
-117.453 1777
-117.357 1776
-117.262 1775
-117.160 1774
-117.059 1773
-116.947 1772
-116.844 1771
-116.744 1770
-116.644 1769
-116.535 1768
-116.422 1767
-116.319 1766
-116.217 1765
-116.105 1764
-115.987 1763
-115.875 1762
-115.768 1761
-115.661 1760
-115.556 1759
-115.444 1758
-115.334 1757
-115.226 1756
-115.116 1755
-115.000 1754
-114.876 1753
-114.753 1752
-114.635 1751
-114.502 1750
-114.383 1749
-114.261 1748
-114.139 1747
-114.019 1746
-113.891 1745
-113.764 1744
-113.639 1743
-113.517 1742
-113.376 1741
-113.238 1740
-113.111 1739
-112.972 1738
-112.840 1737
-112.705 1736
-112.571 1735
-112.435 1734
-112.301 1733
-112.166 1732
-112.030 1731
-111.883 1730
-111.741 1729
-111.604 1728
-111.477 1727
-111.324 1726
-111.186 1725
-111.040 1724
-110.889 1723
-110.740 1722
-110.595 1721
-110.450 1720
-110.299 1719
-110.151 1718
-110.001 1717
-109.857 1716
-109.700 1715
-109.552 1714
-109.407 1713
-109.255 1712
-109.096 1711
-108.938 1710
-108.776 1709
-108.612 1708
-108.446 1707
-108.280 1706
-108.121 1705
-107.956 1704
-107.788 1703
-107.626 1702
-107.466 1701
-107.303 1700
-107.134 1699
-106.969 1698
-106.797 1697
-106.609 1696
-106.431 1695
-106.258 1694
-106.079 1693
-105.902 1692
-105.716 1691
-105.541 1690
-105.351 1689
-105.158 1688
-104.971 1687
-104.782 1686
-104.589 1685
-104.401 1684
-104.209 1683
-104.007 1682
-103.814 1681
-103.618 1680
-103.414 1679
-103.211 1678
-103.006 1677
-102.806 1676
-102.595 1675
-102.395 1674
-102.188 1673
-101.977 1672
-101.777 1671
-101.570 1670
-101.355 1669
-101.137 1668
-100.917 1667
-100.703 1666
-100.487 1665
-100.266 1664
-100.051 1663
-99.821 1662
-99.600 1661
-99.384 1660
-99.164 1659
-98.944 1658
-98.724 1657
-98.494 1656
-98.263 1655
-98.044 1654
-97.813 1653
-97.582 1652
-97.350 1651
-97.119 1650
-96.885 1649
-96.661 1648
-96.435 1647
-96.200 1646
-95.959 1645
-95.722 1644
-95.491 1643
-95.256 1642
-95.022 1641
-94.786 1640
-94.546 1639
-94.311 1638
-94.069 1637
-93.826 1636
-93.576 1635
-93.327 1634
-93.073 1633
-92.825 1632
-92.582 1631
-92.340 1630
-92.096 1629
-91.865 1628
-91.610 1627
-91.360 1626
-91.101 1625
-90.841 1624
-90.580 1623
-90.318 1622
-90.066 1621
-89.813 1620
-89.562 1619
-89.307 1618
-89.054 1617
-88.795 1616
-88.525 1615
-88.277 1614
-88.027 1613
-87.780 1612
-87.529 1611
-87.277 1610
-87.023 1609
-86.776 1608
-86.525 1607
-86.276 1606
-86.017 1605
-85.766 1604
-85.502 1603
-85.252 1602
-85.007 1601
-84.763 1600
-84.516 1599
-84.265 1598
-84.023 1597
-83.772 1596
-83.523 1595
-83.272 1594
-83.013 1593
-82.763 1592
-82.506 1591
-82.268 1590
-82.019 1589
-81.762 1588
-81.508 1587
-81.255 1586
-81.000 1585
-80.763 1584
-80.512 1583
-80.252 1582
-79.996 1581
-79.757 1580
-79.510 1579
-79.254 1578
-79.014 1577
-78.760 1576
-78.516 1575
-78.273 1574
-78.033 1573
-77.795 1572
-77.558 1571
-77.319 1570
-77.074 1569
-76.842 1568
-76.602 1567
-76.369 1566
-76.127 1565
-75.887 1564
-75.651 1563
-75.408 1562
-75.183 1561
-74.954 1560
-74.713 1559
-74.490 1558
-74.270 1557
-74.038 1556
-73.807 1555
-73.574 1554
-73.349 1553
-73.115 1552
-72.886 1551
-72.658 1550
-72.429 1549
-72.201 1548
-71.968 1547
-71.729 1546
-71.503 1545
-71.278 1544
-71.039 1543
-70.828 1542
-70.606 1541
-70.389 1540
-70.160 1539
-69.936 1538
-69.728 1537
-69.504 1536
-69.292 1535
-69.066 1534
-68.844 1533
-68.624 1532
-68.426 1531
-68.210 1530
-67.990 1529
-67.783 1528
-67.574 1527
-67.355 1526
-67.148 1525
-66.929 1524
-66.717 1523
-66.508 1522
-66.307 1521
-66.098 1520
-65.899 1519
-65.707 1518
-65.489 1517
-65.278 1516
-65.058 1515
-64.871 1514
-64.674 1513
-64.476 1512
-64.279 1511
-64.079 1510
-63.887 1509
-63.684 1508
-63.495 1507
-63.279 1506
-63.074 1505
-62.895 1504
-62.704 1503
-62.512 1502
-62.338 1501
-62.140 1500
-61.959 1499
-61.778 1498
-61.591 1497
-61.404 1496
-61.219 1495
-61.046 1494
-60.873 1493
-60.679 1492
-60.499 1491
-60.334 1490
-60.159 1489
-59.980 1488
-59.803 1487
-59.623 1486
-59.446 1485
-59.275 1484
-59.103 1483
-58.929 1482
-58.763 1481
-58.598 1480
-58.418 1479
-58.248 1478
-58.081 1477
-57.908 1476
-57.752 1475
-57.590 1474
-57.419 1473
-57.250 1472
-57.091 1471
-56.927 1470
-56.755 1469
-56.578 1468
-56.435 1467
-56.283 1466
-56.129 1465
-55.968 1464
-55.819 1463
-55.665 1462
-55.500 1461
-55.342 1460
-55.179 1459
-55.024 1458
-54.866 1457
-54.713 1456
-54.562 1455
-54.423 1454
-54.272 1453
-54.109 1452
-53.959 1451
-53.799 1450
-53.638 1449
-53.495 1448
-53.341 1447
-53.190 1446
-53.044 1445
-52.891 1444
-52.751 1443
-52.606 1442
-52.461 1441
-52.319 1440
-52.175 1439
-52.022 1438
-51.870 1437
-51.738 1436
-51.606 1435
-51.474 1434
-51.340 1433
-51.205 1432
-51.068 1431
-50.937 1430
-50.795 1429
-50.665 1428
-50.539 1427
-50.406 1426
-50.286 1425
-50.162 1424
-50.032 1423
-49.920 1422
-49.786 1421
-49.666 1420
-49.560 1419
-49.443 1418
-49.322 1417
-49.201 1416
-49.080 1415
-48.966 1414
-48.852 1413
-48.744 1412
-48.630 1411
-48.504 1410
-48.390 1409
-48.278 1408
-48.165 1407
-48.057 1406
-47.944 1405
-47.837 1404
-47.721 1403
-47.622 1402
-47.512 1401
-47.400 1400
-47.298 1399
-47.193 1398
-47.085 1397
-46.985 1396
-46.887 1395
-46.779 1394
-46.671 1393
-46.563 1392
-46.462 1391
-46.354 1390
-46.247 1389
-46.147 1388
-46.050 1387
-45.948 1386
-45.861 1385
-45.765 1384
-45.665 1383
-45.574 1382
-45.478 1381
-45.385 1380
-45.288 1379
-45.198 1378
-45.097 1377
-45.008 1376
-44.920 1375
-44.835 1374
-44.741 1373
-44.651 1372
-44.568 1371
-44.470 1370
-44.375 1369
-44.301 1368
-44.214 1367
-44.129 1366
-44.054 1365
-43.971 1364
-43.878 1363
-43.796 1362
-43.722 1361
-43.636 1360
-43.549 1359
-43.469 1358
-43.382 1357
-43.316 1356
-43.243 1355
-43.156 1354
-43.077 1353
-43.000 1352
-42.928 1351
-42.854 1350
-42.775 1349
-42.699 1348
-42.623 1347
-42.561 1346
-42.494 1345
-42.427 1344
-42.354 1343
-42.302 1342
-42.239 1341
-42.165 1340
-42.088 1339
-42.037 1338
-41.963 1337
-41.900 1336
-41.831 1335
-41.773 1334
-41.714 1333
-41.662 1332
-41.589 1331
-41.521 1330
-41.486 1329
-41.433 1328
-41.378 1327
-41.323 1326
-41.273 1325
-41.219 1324
-41.172 1323
-41.124 1322
-41.065 1321
-41.012 1320
-40.959 1319
-40.893 1318
-40.841 1317
-40.787 1316
-40.741 1315
-40.689 1314
-40.625 1313
-40.583 1312
-40.533 1311
-40.487 1310
-40.443 1309
-40.396 1308
-40.348 1307
-40.303 1306
-40.254 1305
-40.197 1304
-40.148 1303
-40.097 1302
-40.052 1301
-40.000 1300
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment