add calibration measurements
This commit is contained in:
parent
520f5bcfd4
commit
662d5654d8
|
@ -0,0 +1,48 @@
|
||||||
|
ECgemessen,time,tempReservoir,ECadcCalib,ECadc,ECadcAdjusted,sm
|
||||||
|
0,275.24,25,6017.98,752.11,751.97,7307.69
|
||||||
|
50,316.39,25.11,6017.75,1244.1,1243.92,7247.13
|
||||||
|
70,359.55,25.23,6017.86,2030.25,2029.92,7199.56
|
||||||
|
110,398.7,25.31,6017.86,2734.5,2734.06,7147.19
|
||||||
|
190,442.85,25.41,6017.73,3537.29,3536.79,7071.94
|
||||||
|
260,472.94,25.45,6017.82,4354.48,4353.8,6974.44
|
||||||
|
350,542.17,25.57,6017.87,5304.49,5303.62,6830.88
|
||||||
|
440,581.33,25.63,6017.81,6423.09,6422.09,6596.06
|
||||||
|
590,635.55,25.7,6017.9,7389.73,7388.48,6330.69
|
||||||
|
800,678.7,25.75,6018.04,8382.96,8381.35,5964.13
|
||||||
|
940,723.86,25.81,6018,8897.81,8896.16,5740.44
|
||||||
|
1110,784.03,25.87,6018.07,9448.96,9447.09,5492
|
||||||
|
1320,814.12,25.87,6018,9972.98,9971.12,5226.63
|
||||||
|
1510,875.35,25.87,6018.23,10499.23,10496.88,4988.75
|
||||||
|
1740,905.43,25.88,6018.4,10904.04,10901.28,4803.19
|
||||||
|
1810,941.58,25.94,6018.4,10997.25,10994.46,4746.94
|
||||||
|
1980,969.66,25.94,6018.56,11190.55,11187.42,4618.25
|
||||||
|
2150,1013.82,25.94,6018.63,11386.87,11383.56,4516.69
|
||||||
|
2330,1038.9,25.94,6018.65,11685.33,11681.89,4443.88
|
||||||
|
2500,1065.99,25.94,6018.57,11865.25,11861.92,4345.88
|
||||||
|
2600,1093.07,25.94,6018.35,11981.96,11979.04,4315.44
|
||||||
|
2740,1116.15,25.94,6018.28,12036.36,12033.56,4289.44
|
||||||
|
3100,1141.23,25.94,6018.34,12413.91,12410.89,4210.13
|
||||||
|
3340,1171.31,25.94,6018.26,12563.63,12560.76,4160.5
|
||||||
|
3740,1197.4,25.89,6018.22,12785.22,12782.37,4085.38
|
||||||
|
4040,1226.48,25.88,6018.15,12867.1,12864.39,4141.81
|
||||||
|
4480,1255.57,25.87,6018.25,13088.04,13085.06,4146.38
|
||||||
|
4710,1279.65,25.87,6018.22,13138.02,13135.1,4158.44
|
||||||
|
5350,1309.73,25.81,6018.35,13325.45,13322.2,4117.06
|
||||||
|
5950,1358.95,25.76,6018.34,13420.62,13417.36,4085.31
|
||||||
|
6520,1389.04,25.75,6018.32,13519.69,13516.45,4084.06
|
||||||
|
7070,1413.12,25.69,6018.3,13545.42,13542.22,4065.81
|
||||||
|
7620,1443.2,25.69,6018.34,13656.96,13653.65,4023.19
|
||||||
|
8620,1482.35,25.61,6018.33,13724.86,13721.56,3986.75
|
||||||
|
9560,1530.57,25.5,6018.16,13929.07,13926.12,4002.94
|
||||||
|
10430,1673.05,25.44,6018.18,13843.42,13840.42,4042.5
|
||||||
|
11240,1703.13,25.4,6018.26,13907.46,13904.27,4022.75
|
||||||
|
11980,1742.28,25.32,6018.32,13938.42,13935.08,4007.31
|
||||||
|
12220,1772.37,25.31,6018.21,13939.71,13936.62,3992.13
|
||||||
|
12570,1809.52,25.26,6018.27,13941.7,13938.47,3989.38
|
||||||
|
12940,1839.6,25.25,6018.29,13953.32,13950.05,3968.38
|
||||||
|
13090,1878.76,25.25,6018.34,13874.39,13871.03,3964.63
|
||||||
|
13660,1909.9,25.19,6018.27,13941.99,13938.76,3941.31
|
||||||
|
14560,1939.98,25.12,6018.39,14020.18,14016.67,3907.94
|
||||||
|
16280,1970.13,24.93,6018.52,14106.17,14102.33,3923.69
|
||||||
|
17490,1995.21,24.78,6018.82,14159.11,14154.54,3908
|
||||||
|
18220,2025.29,24.69,6018.91,14187.77,14182.99,3897
|
|
Binary file not shown.
|
@ -0,0 +1,46 @@
|
||||||
|
ecMeasured,time,tempReservoir,ECadcCalib,ECadc,ECadcAdjusted,sm
|
||||||
|
0,275.24,25,6017.98,752.11,751.97,7307.69
|
||||||
|
50,316.39,25.11,6017.75,1244.1,1243.92,7247.13
|
||||||
|
70,359.55,25.23,6017.86,2030.25,2029.92,7199.56
|
||||||
|
110,398.7,25.31,6017.86,2734.5,2734.06,7147.19
|
||||||
|
190,442.85,25.41,6017.73,3537.29,3536.79,7071.94
|
||||||
|
260,472.94,25.45,6017.82,4354.48,4353.8,6974.44
|
||||||
|
350,542.17,25.57,6017.87,5304.49,5303.62,6830.88
|
||||||
|
440,581.33,25.63,6017.81,6423.09,6422.09,6596.06
|
||||||
|
590,635.55,25.7,6017.9,7389.73,7388.48,6330.69
|
||||||
|
800,678.7,25.75,6018.04,8382.96,8381.35,5964.13
|
||||||
|
940,723.86,25.81,6018,8897.81,8896.16,5740.44
|
||||||
|
1110,784.03,25.87,6018.07,9448.96,9447.09,5492
|
||||||
|
1320,814.12,25.87,6018,9972.98,9971.12,5226.63
|
||||||
|
1510,875.35,25.87,6018.23,10499.23,10496.88,4988.75
|
||||||
|
1740,905.43,25.88,6018.4,10904.04,10901.28,4803.19
|
||||||
|
1810,941.58,25.94,6018.4,10997.25,10994.46,4746.94
|
||||||
|
1980,969.66,25.94,6018.56,11190.55,11187.42,4618.25
|
||||||
|
2150,1013.82,25.94,6018.63,11386.87,11383.56,4516.69
|
||||||
|
2330,1038.9,25.94,6018.65,11685.33,11681.89,4443.88
|
||||||
|
2500,1065.99,25.94,6018.57,11865.25,11861.92,4345.88
|
||||||
|
2600,1093.07,25.94,6018.35,11981.96,11979.04,4315.44
|
||||||
|
2740,1116.15,25.94,6018.28,12036.36,12033.56,4289.44
|
||||||
|
3100,1141.23,25.94,6018.34,12413.91,12410.89,4210.13
|
||||||
|
3340,1171.31,25.94,6018.26,12563.63,12560.76,4160.5
|
||||||
|
3740,1197.4,25.89,6018.22,12785.22,12782.37,4085.38
|
||||||
|
4040,1226.48,25.88,6018.15,12867.1,12864.39,4141.81
|
||||||
|
4480,1255.57,25.87,6018.25,13088.04,13085.06,4146.38
|
||||||
|
4710,1279.65,25.87,6018.22,13138.02,13135.1,4158.44
|
||||||
|
5350,1309.73,25.81,6018.35,13325.45,13322.2,4117.06
|
||||||
|
5950,1358.95,25.76,6018.34,13420.62,13417.36,4085.31
|
||||||
|
6520,1389.04,25.75,6018.32,13519.69,13516.45,4084.06
|
||||||
|
7070,1413.12,25.69,6018.3,13545.42,13542.22,4065.81
|
||||||
|
7620,1443.2,25.69,6018.34,13656.96,13653.65,4023.19
|
||||||
|
8620,1482.35,25.61,6018.33,13724.86,13721.56,3986.75
|
||||||
|
10430,1673.05,25.44,6018.18,13843.42,13840.42,4042.5
|
||||||
|
11240,1703.13,25.4,6018.26,13907.46,13904.27,4022.75
|
||||||
|
11980,1742.28,25.32,6018.32,13938.42,13935.08,4007.31
|
||||||
|
12220,1772.37,25.31,6018.21,13939.71,13936.62,3992.13
|
||||||
|
12570,1809.52,25.26,6018.27,13941.7,13938.47,3989.38
|
||||||
|
12940,1839.6,25.25,6018.29,13953.32,13950.05,3968.38
|
||||||
|
13660,1909.9,25.19,6018.27,13941.99,13938.76,3941.31
|
||||||
|
14560,1939.98,25.12,6018.39,14020.18,14016.67,3907.94
|
||||||
|
16280,1970.13,24.93,6018.52,14106.17,14102.33,3923.69
|
||||||
|
17490,1995.21,24.78,6018.82,14159.11,14154.54,3908
|
||||||
|
18220,2025.29,24.69,6018.91,14187.77,14182.99,3897
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
275.24,25.00,6017.98,752.11,751.97,7307.69
|
||||||
|
316.39,25.11,6017.75,1244.10,1243.92,7247.13
|
||||||
|
359.55,25.23,6017.86,2030.25,2029.92,7199.56
|
||||||
|
398.70,25.31,6017.86,2734.50,2734.06,7147.19
|
||||||
|
442.85,25.41,6017.73,3537.29,3536.79,7071.94
|
||||||
|
472.94,25.45,6017.82,4354.48,4353.80,6974.44
|
||||||
|
542.17,25.57,6017.87,5304.49,5303.62,6830.88
|
||||||
|
581.33,25.63,6017.81,6423.09,6422.09,6596.06
|
||||||
|
635.55,25.70,6017.90,7389.73,7388.48,6330.69
|
||||||
|
678.70,25.75,6018.04,8382.96,8381.35,5964.13
|
||||||
|
723.86,25.81,6018.00,8897.81,8896.16,5740.44
|
||||||
|
784.03,25.87,6018.07,9448.96,9447.09,5492.00
|
||||||
|
814.12,25.87,6018.00,9972.98,9971.12,5226.63
|
||||||
|
875.35,25.87,6018.23,10499.23,10496.88,4988.75
|
||||||
|
905.43,25.88,6018.40,10904.04,10901.28,4803.19
|
||||||
|
941.58,25.94,6018.40,10997.25,10994.46,4746.94
|
||||||
|
969.66,25.94,6018.56,11190.55,11187.42,4618.25
|
||||||
|
1013.82,25.94,6018.63,11386.87,11383.56,4516.69
|
||||||
|
1038.90,25.94,6018.65,11685.33,11681.89,4443.88
|
||||||
|
1065.99,25.94,6018.57,11865.25,11861.92,4345.88
|
||||||
|
1093.07,25.94,6018.35,11981.96,11979.04,4315.44
|
||||||
|
1116.15,25.94,6018.28,12036.36,12033.56,4289.44
|
||||||
|
1141.23,25.94,6018.34,12413.91,12410.89,4210.13
|
||||||
|
1171.31,25.94,6018.26,12563.63,12560.76,4160.50
|
||||||
|
1197.40,25.89,6018.22,12785.22,12782.37,4085.38
|
||||||
|
1226.48,25.88,6018.15,12867.10,12864.39,4141.81
|
||||||
|
1255.57,25.87,6018.25,13088.04,13085.06,4146.38
|
||||||
|
1279.65,25.87,6018.22,13138.02,13135.10,4158.44
|
||||||
|
1309.73,25.81,6018.35,13325.45,13322.20,4117.06
|
||||||
|
1358.95,25.76,6018.34,13420.62,13417.36,4085.31
|
||||||
|
1389.04,25.75,6018.32,13519.69,13516.45,4084.06
|
||||||
|
1413.12,25.69,6018.30,13545.42,13542.22,4065.81
|
||||||
|
1443.20,25.69,6018.34,13656.96,13653.65,4023.19
|
||||||
|
1482.35,25.61,6018.33,13724.86,13721.56,3986.75
|
||||||
|
1521.50,25.51,6018.16,13836.41,13833.47,3974.31
|
||||||
|
1530.57,25.50,6018.16,13929.07,13926.12,4002.94
|
||||||
|
1673.05,25.44,6018.18,13843.42,13840.42,4042.50
|
||||||
|
1703.13,25.40,6018.26,13907.46,13904.27,4022.75
|
||||||
|
1742.28,25.32,6018.32,13938.42,13935.08,4007.31
|
||||||
|
1772.37,25.31,6018.21,13939.71,13936.62,3992.13
|
||||||
|
1809.52,25.26,6018.27,13941.70,13938.47,3989.38
|
||||||
|
1839.60,25.25,6018.29,13953.32,13950.05,3968.38
|
||||||
|
1878.76,25.25,6018.34,13874.39,13871.03,3964.63
|
||||||
|
1909.90,25.19,6018.27,13941.99,13938.76,3941.31
|
||||||
|
1939.98,25.12,6018.39,14020.18,14016.67,3907.94
|
||||||
|
1970.13,24.93,6018.52,14106.17,14102.33,3923.69
|
||||||
|
1995.21,24.78,6018.82,14159.11,14154.54,3908.00
|
||||||
|
2025.29,24.69,6018.91,14187.77,14182.99,3897.00
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
time,tempReservoir,ECadcCalib,ECadc,ECadcAdjusted,sm
|
||||||
|
39.27,7.93,0.00,12928.21,0.00,4386.81
|
||||||
|
69.36,8.22,0.00,12938.00,0.00,4384.50
|
||||||
|
99.44,8.52,0.00,12953.12,0.00,4379.63
|
||||||
|
129.53,8.81,0.00,12973.91,0.00,4373.06
|
||||||
|
159.62,9.07,0.00,12988.02,0.00,4356.50
|
||||||
|
189.70,9.34,0.00,13009.92,0.00,4349.94
|
||||||
|
219.79,9.60,6020.01,13024.38,13017.61,4341.31
|
||||||
|
249.88,9.85,6019.94,13031.18,13024.56,4335.56
|
||||||
|
279.96,10.07,6019.95,13040.61,13033.96,4343.38
|
||||||
|
310.05,10.31,6019.63,13049.85,13043.89,4333.25
|
||||||
|
340.13,10.53,6019.55,13031.47,13025.69,4341.63
|
||||||
|
370.22,10.73,6019.45,13034.77,13029.19,4348.63
|
||||||
|
400.31,10.94,6019.37,13036.65,13031.26,4352.88
|
||||||
|
430.39,11.14,6019.32,13046.40,13041.11,4347.88
|
||||||
|
460.48,11.32,6019.14,13068.50,13063.60,4333.19
|
||||||
|
490.56,11.52,6019.33,13068.20,13062.88,4344.81
|
||||||
|
520.65,11.70,6019.31,13070.17,13064.90,4342.13
|
||||||
|
550.74,11.86,6019.35,13083.50,13078.13,4318.44
|
||||||
|
580.82,12.04,6019.53,13090.34,13084.59,4313.81
|
||||||
|
610.91,12.21,6019.65,13109.86,13103.82,4290.75
|
||||||
|
640.99,12.36,6019.84,13117.46,13111.01,4289.56
|
||||||
|
671.08,12.53,6019.84,13114.20,13107.74,4287.75
|
||||||
|
701.17,12.68,6019.87,13108.12,13101.61,4297.50
|
||||||
|
731.25,12.84,6019.89,13110.45,13103.90,4296.50
|
||||||
|
761.34,12.98,6019.95,13108.24,13101.55,4300.13
|
||||||
|
791.42,13.12,6020.08,13107.10,13100.13,4291.31
|
||||||
|
821.51,13.27,6020.11,13112.17,13105.13,4291.94
|
||||||
|
851.60,13.54,6019.90,13137.00,13130.41,4280.56
|
||||||
|
881.68,14.04,6019.86,13178.26,13171.73,4238.19
|
||||||
|
911.77,14.48,6019.92,13190.11,13183.44,4233.13
|
||||||
|
941.85,14.90,6019.86,13175.19,13168.66,4257.25
|
||||||
|
971.94,15.27,6019.61,13194.13,13188.15,4251.19
|
||||||
|
1002.03,15.61,6019.69,13205.95,13199.79,4245.19
|
||||||
|
1032.11,15.99,6019.64,13210.87,13204.81,4250.19
|
||||||
|
1062.20,17.11,6019.70,13281.73,13275.50,4234.06
|
||||||
|
1092.28,18.58,6019.70,13349.77,13343.52,4223.38
|
||||||
|
1122.37,19.82,6019.57,13409.64,13403.63,4215.75
|
||||||
|
1152.46,20.87,6019.75,13451.96,13445.56,4202.25
|
||||||
|
1182.54,21.80,6019.73,13494.50,13488.10,4195.00
|
||||||
|
1212.63,22.62,6019.61,13537.11,13530.97,4185.19
|
||||||
|
1242.71,23.32,6019.64,13562.43,13556.20,4172.31
|
||||||
|
1272.80,23.95,6019.76,13592.77,13586.27,4157.00
|
||||||
|
1302.89,24.54,6019.79,13604.54,13597.98,4171.88
|
||||||
|
1332.97,25.10,6019.75,13625.00,13618.51,4166.69
|
||||||
|
1363.06,25.61,6019.69,13646.54,13640.16,4148.81
|
||||||
|
1393.14,26.04,6019.68,13657.82,13651.47,4166.50
|
||||||
|
1423.23,26.43,6019.67,13689.71,13683.37,4130.25
|
||||||
|
1453.32,26.75,6019.63,13702.87,13696.63,4095.00
|
||||||
|
1483.40,27.05,6019.64,13675.46,13669.20,4119.00
|
||||||
|
1513.49,27.62,6019.53,13712.39,13706.35,4109.06
|
||||||
|
1543.57,28.28,6019.43,13961.50,13955.58,3871.44
|
||||||
|
1573.66,28.89,6019.38,13974.99,13969.20,3876.13
|
||||||
|
1603.75,29.42,6019.37,13982.94,13977.16,3862.38
|
||||||
|
1633.83,29.88,6019.26,13992.91,13987.39,3821.69
|
||||||
|
1663.92,30.29,6019.25,13995.25,13989.74,3797.63
|
||||||
|
1694.00,30.63,6019.18,13146.87,13141.84,4383.75
|
||||||
|
1724.09,30.92,6019.37,13912.02,13906.27,3879.06
|
||||||
|
1754.18,31.19,6019.37,13904.85,13899.09,3859.56
|
||||||
|
1784.26,31.42,6019.46,13893.30,13887.36,3856.63
|
||||||
|
1814.35,31.62,6019.48,13876.41,13870.41,3874.13
|
||||||
|
1844.43,31.93,6019.54,13876.48,13870.34,3877.19
|
||||||
|
1874.52,32.45,6019.54,13878.46,13872.34,3857.50
|
||||||
|
1904.61,32.90,6019.57,13869.21,13863.01,3846.31
|
||||||
|
1934.69,33.27,6019.42,13861.22,13855.37,3878.63
|
||||||
|
1964.78,33.61,6019.38,13852.55,13846.80,3882.00
|
||||||
|
1994.86,33.89,6019.40,13837.23,13831.43,3867.75
|
||||||
|
2024.95,34.13,6019.32,13823.03,13817.41,3867.94
|
||||||
|
2055.04,34.33,6019.29,13805.09,13799.57,3870.75
|
||||||
|
2085.12,34.49,6019.24,13788.38,13782.98,3878.44
|
||||||
|
2115.21,34.65,6019.21,13768.86,13763.54,3862.00
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
Messwertkalibrierung DIY EC Messgerät:
|
||||||
|
|
||||||
|
300mL dest. Wasser in 500mL Becherglas auf Magnetrührer
|
||||||
|
Wasser temperiert auf 25°C und durchgehend temperatur gehalten
|
||||||
|
Temperatursensor und DIY EC-Probe in Flüssigkeit gehalten
|
||||||
|
EC Sensor in Flüssigkeit zur Referenzmessung
|
||||||
|
Magnetrührer auf langsamer Stufe (keine Strudelbildung)
|
||||||
|
Messwert per Tastendruck erfasst (time,tempReservoir,ECadcCalib,ECadc,ECadcAdjusted,sm)
|
||||||
|
zeit
|
||||||
|
temperatur d. flüssigkeit
|
||||||
|
referenz adc wert (geschalteter fester widerstand statt probe)
|
||||||
|
Roher ADC Messwert
|
||||||
|
angepasster ADC Messwert (linear gemappt nach abweichung vom referenz adc wert, referenz adc wert vorher ermittelt und eingegeben in code)
|
||||||
|
Soil Moisture ADC Messwert (der mit dem RG174 Kabel)
|
||||||
|
|
||||||
|
manuell abgelesen: EC wert
|
||||||
|
|
||||||
|
Erster Messwert nur dest. Wasser.
|
||||||
|
Weitere Messwerte jew. nach hinzufügen erst wenigen tropfen NaCl Lösung. Später mehr bis zu 6mL pro Messung.
|
||||||
|
|
||||||
|
Bläschen an Elektroden durch pusten entfernt wenn sie sich gebildet haben
|
||||||
|
|
||||||
|
Werte in 20230505_NaCl.csv bzw auswertung in ..ods
|
||||||
|
|
||||||
|
Polynom 10. Grades erstellt mit python approximate.py
|
||||||
|
polynom in c++ code übernommen und punktuelle ergebnisse aus adc zu ec funktion ausgegeben und geplottet zur kontrolle, ob rechnung funktioniert.
|
||||||
|
|
||||||
|
|
||||||
|
Temperaturabhängigkeit:
|
||||||
|
NaCl Lösung auf etwa 1500uS/cm angemischt
|
||||||
|
Im Eiswasserbad gekühlt
|
||||||
|
Auf Magnetrührer platziert mit Temperatur und Diy EC-Probe
|
||||||
|
Kontinuierlich (alle 30s) messwerte aufgezeichnet
|
||||||
|
Bläschenbildung an den Elektroden ab etwa 34°C
|
||||||
|
Werte in 20230505_NaCl_temperature.csv
|
||||||
|
|
||||||
|
t=99s: start bei 10.9°C (EC messgerät) (8.5°C laut DS18B20) EC=1364uS/cm (EC messgerät)
|
||||||
|
t=219s: erster korrekter calib wert. EC Messgerät: 1416uS/cm @11.4C
|
||||||
|
t=851s: 1443uS @15.6°C
|
||||||
|
t=1423s: 1553uS @25,3°C
|
||||||
|
t=1513s: blaeschen entfernt von ec probe
|
||||||
|
|
||||||
|
ab 30°C viele bläschen
|
|
@ -0,0 +1,101 @@
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
from scipy.optimize import curve_fit
|
||||||
|
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
# importing module
|
||||||
|
from pandas import *
|
||||||
|
|
||||||
|
# reading CSV file
|
||||||
|
data = read_csv("20230505_NaCl_optimized.csv")
|
||||||
|
|
||||||
|
# converting column data to list
|
||||||
|
#solutionAdded = data['solutionAdded'].tolist() #in ml
|
||||||
|
tempReservoir = data['tempReservoir'].tolist() #in C
|
||||||
|
adc = data['ECadcAdjusted'].tolist() #adc reading
|
||||||
|
|
||||||
|
solutionConcentration=5924.8 #mg/L NaCl
|
||||||
|
startWaterAmount=0.3 #L
|
||||||
|
|
||||||
|
ppmToECfactor=1/0.46
|
||||||
|
|
||||||
|
#concentration = [x*solutionConcentration/(startWaterAmount+x) for x in solutionAdded]
|
||||||
|
#ECcalculated = [x*ppmToECfactor for x in concentration] #uS/cm
|
||||||
|
|
||||||
|
ECmeasured = data['ecMeasured'].tolist() #in C
|
||||||
|
|
||||||
|
#print(concentration)
|
||||||
|
#print(ECcalculated)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
x = adc
|
||||||
|
|
||||||
|
#y = ECcalculated
|
||||||
|
y = ECmeasured
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'''
|
||||||
|
def model(x, a, b, c, d, e):
|
||||||
|
y = a * x**4 + b *x**3 + c*x**2 + d*x + e
|
||||||
|
return y
|
||||||
|
|
||||||
|
|
||||||
|
popt, pcov = curve_fit(model, x, y)
|
||||||
|
|
||||||
|
#y1 = a * numpy.exp(b * x)
|
||||||
|
|
||||||
|
#print("popt="+str(popt))
|
||||||
|
for p in popt:
|
||||||
|
print(p)
|
||||||
|
'''
|
||||||
|
|
||||||
|
plt.plot(x, y, 'ok')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
xstart = np.min(adc)
|
||||||
|
xstop = np.max(adc)
|
||||||
|
increment = 10
|
||||||
|
xmodel = np.arange(xstart,xstop,increment)
|
||||||
|
|
||||||
|
|
||||||
|
#ymodel = model(xmodel, *popt)
|
||||||
|
#plt.plot(xmodel,ymodel, 'r')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for model_order in [9,10,11]:
|
||||||
|
print("model order="+str(model_order))
|
||||||
|
# Finding the Model
|
||||||
|
p = np.polyfit(x, y, model_order)
|
||||||
|
#print(p)
|
||||||
|
polystring=""
|
||||||
|
for i in np.arange(model_order+1):
|
||||||
|
_c=str(p[i])
|
||||||
|
if p[i]>=0:
|
||||||
|
_c="+"+_c #add leading +
|
||||||
|
polystring+=_c+"*x^"+str(model_order-i)+" "
|
||||||
|
print(polystring)
|
||||||
|
print("Excel:")
|
||||||
|
for i in np.arange(model_order+1):
|
||||||
|
print(str(p[i]))
|
||||||
|
print("Array:")
|
||||||
|
arraystring="{"
|
||||||
|
for i in np.arange(model_order+1):
|
||||||
|
arraystring+=str(p[model_order-i])
|
||||||
|
arraystring+=","
|
||||||
|
arraystring=arraystring[:-1]+"}"
|
||||||
|
print(arraystring)
|
||||||
|
# Plot the Model
|
||||||
|
ymodel = np.polyval(p, xmodel)
|
||||||
|
plt.plot(xmodel,ymodel,label="order="+str(model_order))
|
||||||
|
print()
|
||||||
|
|
||||||
|
plt.legend()
|
||||||
|
plt.grid()
|
||||||
|
plt.show()
|
||||||
|
|
Loading…
Reference in New Issue