algorithm bug

main
esea_info 3 years ago
parent 5386996c45
commit 5daad6ff71
  1. 7
      .gitignore
  2. 312
      calfile/Basis aq_B057.dat
  3. 312
      calfile/Reflectivity_B057.dat
  4. 7
      config.yml
  5. 2297
      data/20210305/CALIBRAT.DAT
  6. 2646
      data/CALIBRAT.DAT
  7. 128
      oscar.py
  8. 48
      uiconfig/ui_algorithm.py
  9. 21
      yiwinframe.py

7
.gitignore vendored

@ -0,0 +1,7 @@
/__pycache__/
/dist/
/build/
/*/__pycache__
/data/output/
*.log

@ -0,0 +1,312 @@
[Spectrum]
Version = 1
IDData = OSCAR_B057_2021-10-27_18-19-42_Waterbase_722
IDDevice = OSCAR_B057
IDDataType = SPECTRUM
IDDataTypeSub1 = CALIBRATED
IDDataTypeSub2 = BASIS
IDDataTypeSub3 =
DateTime = 2021-10-27 18:19:42
PositionLatitude = 0
PositionLongitude = 0
Comment = Basis aq_B057
CommentSub1 =
CommentSub2 =
CommentSub3 =
IDMethodType =
MethodName =
Mission = 1 ; 12.4864 ; ;
MissionSub = 0
RecordType = 0
[Attributes]
Averaging = 10
CalFactor = 0
Deviation = 12.4864
FlashCount = 1
IDBasisSpec =
IDDataBack =
IDDataCal =
IntegrationTime = 512
Maximum = 13.6111
P31 = 0
P31e = 0
PathLength = 10
PathLengthCustomOn = 0
RAWDynamic = 65535
Salinity = 0
SpectrumType = Waterbase
Temperature = 22.6
Unit1 = $01 $01 Wavelength nm
Unit2 = $03 $05 Intensity counts
Unit3 = $f0 $05 Error counts
Unit4 = $f1 $00 Status
lampLEDs = 255
lampReference[0] = 0
lampReference[1] = 0
p999 = 0
tempLampModule = 28.2781
tempMainCPU = 32.3844
tempRefDiode = 0
tempSpectrometer = 31.1875
[END] of [Attributes]
[DATA]
0 8 0 0
305.458 0.0235729 0 0
308.829 0.0258807 0 0
312.201 0.0294883 0 0
315.573 0.0332754 0 0
318.946 0.0368528 0 0
322.319 0.04041 0 0
325.693 0.0462642 0 0
329.068 0.0507155 0 0
332.444 0.055753 0 0
335.82 0.0606716 0 0
339.197 0.0673889 0 0
342.574 0.0735427 0 0
345.952 0.0805726 0 0
349.331 0.0892087 0 0
352.71 0.101946 0 0
356.09 0.124363 0 0
359.47 0.19028 0 0
362.851 0.481172 0 0
366.233 1.61263 0 0
369.614 4.38994 0 0
372.997 7.58869 0 0
376.38 8.39007 0 0
379.763 6.40237 0 0
383.147 3.96186 0 0
386.532 2.57689 0 0
389.916 2.32963 0 0
393.302 3.10931 0 0
396.687 4.89567 0 0
400.074 7.68979 0 0
403.46 10.9366 0 0
406.847 13.2694 0 0
410.235 13.6111 0 0
413.622 12.1997 0 0
417.01 9.97307 0 0
420.399 7.69784 0 0
423.788 5.84763 0 0
427.177 4.64566 0 0
430.566 4.10735 0 0
433.956 4.18864 0 0
437.346 4.94749 0 0
440.737 6.47152 0 0
444.127 8.51629 0 0
447.518 10.2627 0 0
450.909 10.8273 0 0
454.301 10.0626 0 0
457.692 8.6015 0 0
461.084 7.1128 0 0
464.476 5.81184 0 0
467.868 4.69912 0 0
471.261 3.79535 0 0
474.654 3.10424 0 0
478.046 2.58624 0 0
481.439 2.20351 0 0
484.832 1.93217 0 0
488.226 1.76454 0 0
491.619 1.69272 0 0
495.013 1.71108 0 0
498.406 1.80813 0 0
501.8 1.97254 0 0
505.193 2.18686 0 0
508.587 2.43889 0 0
511.981 2.71825 0 0
515.375 3.01988 0 0
518.769 3.33946 0 0
522.163 3.66964 0 0
525.557 3.99942 0 0
528.951 4.32306 0 0
532.344 4.64249 0 0
535.738 4.94651 0 0
539.132 5.22672 0 0
542.526 5.47785 0 0
545.92 5.6838 0 0
549.313 5.84096 0 0
552.707 5.95492 0 0
556.101 6.02508 0 0
559.494 6.05466 0 0
562.887 6.04191 0 0
566.28 5.99166 0 0
569.673 5.90574 0 0
573.066 5.78152 0 0
576.459 5.60274 0 0
579.851 5.3717 0 0
583.244 5.08381 0 0
586.636 4.75883 0 0
590.028 4.43218 0 0
593.419 4.10981 0 0
596.811 3.78596 0 0
600.202 3.48223 0 0
603.593 3.22144 0 0
606.984 3.00453 0 0
610.374 2.83081 0 0
613.764 2.68109 0 0
617.154 2.54144 0 0
620.544 2.41463 0 0
623.933 2.29668 0 0
627.322 2.18342 0 0
630.71 2.07068 0 0
634.099 1.95174 0 0
637.486 1.82464 0 0
640.874 1.68807 0 0
644.261 1.54591 0 0
647.648 1.4024 0 0
651.034 1.26168 0 0
654.42 1.12081 0 0
657.805 0.988181 0 0
661.19 0.879976 0 0
664.575 0.793755 0 0
667.959 0.723342 0 0
671.342 0.661492 0 0
674.726 0.606241 0 0
678.108 0.553647 0 0
681.49 0.504017 0 0
684.872 0.456715 0 0
688.253 0.411757 0 0
691.633 0.368644 0 0
695.013 0.327421 0 0
698.393 0.289869 0 0
701.771 0.255323 0 0
705.149 0.223835 0 0
708.527 0.193949 0 0
711.904 0.166534 0 0
715.28 0.142313 0 0
718.656 0.120154 0 0
722.031 0.0995851 0 0
725.406 0.0826066 0 0
728.779 0.0675694 0 0
732.152 0.0536433 0 0
735.525 0.0441175 0 0
738.896 0.0378898 0 0
742.267 0.0336096 0 0
745.638 0.0294109 0 0
749.007 0.0275907 0 0
752.376 0.0249468 0 0
755.744 0.0224244 0 0
759.111 0.0204832 0 0
762.478 0.019215 0 0
765.843 0.0171043 0 0
769.208 0.0154865 0 0
772.572 0.01413 0 0
775.935 0.0139086 0 0
779.298 0.0115462 0 0
782.659 0.0111161 0 0
786.02 0.0104855 0 0
789.38 0.0100116 0 0
792.738 0.00868838 0 0
796.097 0.00860912 0 0
799.454 0.0076391 0 0
802.81 0.00702899 0 0
806.165 0.00635478 0 0
809.519 0.00631045 0 0
812.873 0.00491819 0 0
816.225 0.00496419 0 0
819.577 0.00458108 0 0
822.927 0.00359648 0 0
826.276 0.00249498 0 0
829.625 0.00206451 0 0
832.972 0.00241153 0 0
836.319 0.00190884 0 0
839.664 0.00116645 0 0
843.008 0.000788486 0 0
846.352 0.00126225 0 0
849.694 0.000698472 0 0
853.035 0.000788052 0 0
856.375 0.000576336 0 0
859.714 0.00107976 0 0
863.052 6.75897e-05 0 0
866.388 0.000160362 0 0
869.724 0.000521695 0 0
873.058 -0.000233819 0 0
876.391 0.000329745 0 0
879.723 0.000729946 0 0
883.054 0.000430542 0 0
886.384 5.22949e-05 0 0
889.712 3.50377e-05 0 0
893.039 0.000663218 0 0
896.365 0.000164812 0 0
899.69 -0.000248686 0 0
903.013 0.000198088 0 0
906.336 7.39134e-05 0 0
909.656 -1.60612e-05 0 0
912.976 4.46558e-05 0 0
916.294 9.0726e-05 0 0
919.611 4.55665e-05 0 0
922.927 6.95051e-06 0 0
926.241 -5.49556e-05 0 0
929.554 -0.000118515 0 0
932.866 4.99956e-05 0 0
936.176 4.4646e-05 0 0
939.485 -0.000172356 0 0
942.793 -0.000260726 0 0
946.099 -0.000242362 0 0
949.404 0.000162978 0 0
952.707 -0.00061517 0 0
956.009 -0.000147276 0 0
959.309 -8.76372e-05 0 0
962.608 -0.000229671 0 0
965.906 -0.00100792 0 0
969.202 0.000330054 0 0
972.496 0.000370684 0 0
975.789 -2.13762e-05 0 0
979.081 -0.000779746 0 0
982.371 0.000441775 0 0
985.659 -0.00011134 0 0
988.946 -0.000525979 0 0
992.231 -0.000121042 0 0
995.515 -1.97136e-05 0 0
998.797 0.000224478 0 0
1002.08 -0.000863507 0 0
1005.36 -0.0003046 0 0
1008.63 0.00165833 0 0
1011.91 0.000371848 0 0
1015.18 -0.00062928 0 0
1018.46 0.00205528 0 0
1021.73 0.00431697 0 0
1025 -0.00665683 0 0
1028.26 0.0033482 0 0
1031.53 0.00464093 0 0
1034.79 -0.00648228 0 0
1038.06 -0.00546118 0 0
1041.32 -0.003737 0 0
1044.58 -0.0104238 0 0
1047.83 0.00294009 0 0
1051.09 -0.000245236 0 0
1054.34 -0.00136794 0 0
1057.59 -0.00208346 0 0
1060.84 -0.00193366 0 0
1064.09 -0.00398091 0 0
1067.34 -0.0037972 0 0
1070.58 0.000169779 0 0
1073.83 -0.00232306 0 0
1077.07 -0.00468359 0 0
1080.31 -0.00579226 0 0
1083.54 0.000659453 0 0
1086.78 -0.00163854 0 0
1090.01 -0.00561112 0 0
1093.24 -0.000590463 0 0
1096.47 -0.00118384 0 0
1099.7 -0.00240756 0 0
1102.92 -0.0114305 0 0
1106.15 -0.00172552 0 0
1109.37 -0.0146519 0 0
1112.59 -0.0135967 0 0
1115.81 -0.0116597 0 0
1119.02 0.00568576 0 0
1122.24 0.0173172 0 0
1125.45 0.00287367 0 0
1128.66 -0.0113086 0 0
1131.87 -0.00182147 0 0
1135.07 0.00447147 0 0
1138.28 5.91032e-05 0 0
1141.48 -0.00235593 0 0
1144.68 0.000373866 0 0
1147.87 -0.000547288 0 0
1151.07 -0.00250311 0 0
1154.26 -0.000716403 0 0
[END] of [DATA]
[END] of Spectrum

@ -0,0 +1,312 @@
[Spectrum]
Version = 1
IDData = ALAB_2021-10-28_12-39-48_555_061
IDDevice = OSCAR_B057
IDDataType = SPECTRUM
IDDataTypeSub1 = Reflectivity
IDDataTypeSub2 =
IDDataTypeSub3 =
DateTime = 2021-10-28 12:39:48
PositionLatitude = 0
PositionLongitude = 0
Comment = Reflectivity B057
CommentSub1 = Referenz Lambda850_100mmK
CommentSub2 = WL-Bereich 360 - 750 nm
CommentSub3 =
IDMethodType = Oscar Control
MethodName = OSCAR_B057
Mission = 1 ; 8.94849 ; ;
MissionSub = 0
RecordType = 1
[Attributes]
Averaging = 10
CalFactor = 0
Deviation = 8.94849
FlashCount = 1
IDBasisSpec =
IDDataBack =
IDDataCal =
IntegrationTime = 2048
Maximum = 3.16707
P31 = 0
P31e = 0
PathLength = 100
PathLengthCustomOn = 0
RAWDynamic = 65535
Salinity = 0
SpectrumType = Nigrosin
Temperature = 22.5
Unit1 = $01 $01 Wavelength nm
Unit2 = $0d $08 Reflectivity 1
Unit3 = $0d $08 Reflectivity 1
Unit4 = $f1 $00 Status
lampLEDs = 255
lampReference[0] = 0
lampReference[1] = 0
p999 = 0
tempLampModule = 27.7969
tempMainCPU = 31.5312
tempRefDiode = 0
tempSpectrometer = 30.3125
[END] of [Attributes]
[DATA]
0 10 0 0
305.458 -NAN 0 0
308.829 -NAN 0 0
312.201 -NAN 0 0
315.573 -NAN 0 0
318.946 -NAN 0 0
322.319 -NAN 0 0
325.693 -NAN 0 0
329.068 -NAN 0 0
332.444 -NAN 0 0
335.82 -NAN 0 0
339.197 -NAN 0 0
342.574 -NAN 0 0
345.952 -NAN 0 0
349.331 -NAN 0 0
352.71 -NAN 0 0
356.09 -NAN 0 0
359.47 -NAN 0 0
362.851 0.97631290798748 0 0
366.233 0.977035303934902 0 0
369.614 0.977352488665722 0 0
372.997 0.977495268997149 0 0
376.38 0.977598757383961 0 0
379.763 0.977621432935033 0 0
383.147 0.977509842057 0 0
386.532 0.97763741909712 0 0
389.916 0.977739059048204 0 0
393.302 0.977832679373828 0 0
396.687 0.977870091288099 0 0
400.074 0.977861257131528 0 0
403.46 0.977889242532888 0 0
406.847 0.977790088917731 0 0
410.235 0.977664250242469 0 0
413.622 0.977532390142121 0 0
417.01 0.977472416782342 0 0
420.399 0.977383572362554 0 0
423.788 0.977371220151441 0 0
427.177 0.977324984759689 0 0
430.566 0.977307455037814 0 0
433.956 0.977272461057533 0 0
437.346 0.977181040829754 0 0
440.737 0.977172279323615 0 0
444.127 0.977092109231784 0 0
447.518 0.976961432164169 0 0
450.909 0.976800865383897 0 0
454.301 0.976598714575425 0 0
457.692 0.976402831738254 0 0
461.084 0.976235276826295 0 0
464.476 0.976077509416135 0 0
467.868 0.975935424712903 0 0
471.261 0.975842747767366 0 0
474.654 0.975700003864027 0 0
478.046 0.975597364985662 0 0
481.439 0.97546604458239 0 0
484.832 0.975328690504326 0 0
488.226 0.97518938414775 0 0
491.619 0.975111985181815 0 0
495.013 0.975011695249239 0 0
498.406 0.974912328658174 0 0
501.8 0.974781863848554 0 0
505.193 0.974716774541975 0 0
508.587 0.97461069796349 0 0
511.981 0.974498950953264 0 0
515.375 0.974414443770169 0 0
518.769 0.974235626242656 0 0
522.163 0.974069651907046 0 0
525.557 0.973892983716703 0 0
528.951 0.973726188029201 0 0
532.344 0.973509054172393 0 0
535.738 0.973331464142004 0 0
539.132 0.973147110329348 0 0
542.526 0.972949951006716 0 0
545.92 0.972776445770494 0 0
549.313 0.972726061921191 0 0
552.707 0.972593305099752 0 0
556.101 0.972438934282586 0 0
559.494 0.972200599067765 0 0
562.887 0.972046689764082 0 0
566.28 0.971886962750765 0 0
569.673 0.971699731263939 0 0
573.066 0.971514739662917 0 0
576.459 0.971346799880918 0 0
579.851 0.971226204651133 0 0
583.244 0.971134574970254 0 0
586.636 0.971197637777534 0 0
590.028 0.971228245177734 0 0
593.419 0.971360112264274 0 0
596.811 0.971419217753195 0 0
600.202 0.971349297500719 0 0
603.593 0.971306154977392 0 0
606.984 0.97108440963044 0 0
610.374 0.970818138524895 0 0
613.764 0.970557029697395 0 0
617.154 0.970398401274203 0 0
620.544 0.970187567371871 0 0
623.933 0.969924465196964 0 0
627.322 0.969805205692619 0 0
630.71 0.969612343388037 0 0
634.099 0.969266284847535 0 0
637.486 0.969044080344918 0 0
640.874 0.968862569512551 0 0
644.261 0.968697273968919 0 0
647.648 0.968475380296487 0 0
651.034 0.968402898351648 0 0
654.42 0.968301432256174 0 0
657.805 0.96811557181239 0 0
661.19 0.967831998414956 0 0
664.575 0.967346983731961 0 0
667.959 0.967198783980504 0 0
671.342 0.967049292913876 0 0
674.726 0.966790190039097 0 0
678.108 0.96657792647428 0 0
681.49 0.966415059037831 0 0
684.872 0.966521406337671 0 0
688.253 0.966615368578119 0 0
691.633 0.966415794955571 0 0
695.013 0.966698466412562 0 0
698.393 0.966860492044959 0 0
701.771 0.966854371047198 0 0
705.149 0.967807405484363 0 0
708.527 0.968620677043477 0 0
711.904 0.968605798008826 0 0
715.28 0.969374189021107 0 0
718.656 0.96951909385625 0 0
722.031 0.972719165491867 0 0
725.406 0.977043301054775 0 0
728.779 0.980861686090619 0 0
732.152 0.98743212715864 0 0
735.525 0.993518823214052 0 0
738.896 0.99542247784127 0 0
742.267 0.996812023538068 0 0
745.638 1.00277127079848 0 0
749.007 1.0016184480888 0 0
752.376 -NAN 0 0
755.744 -NAN 0 0
759.111 -NAN 0 0
762.478 -NAN 0 0
765.843 -NAN 0 0
769.208 -NAN 0 0
772.572 -NAN 0 0
775.935 -NAN 0 0
779.298 -NAN 0 0
782.659 -NAN 0 0
786.02 -NAN 0 0
789.38 -NAN 0 0
792.738 -NAN 0 0
796.097 -NAN 0 0
799.454 -NAN 0 0
802.81 -NAN 0 0
806.165 -NAN 0 0
809.519 -NAN 0 0
812.873 -NAN 0 0
816.225 -NAN 0 0
819.577 -NAN 0 0
822.927 -NAN 0 0
826.276 -NAN 0 0
829.625 -NAN 0 0
832.972 -NAN 0 0
836.319 -NAN 0 0
839.664 -NAN 0 0
843.008 -NAN 0 0
846.352 -NAN 0 0
849.694 -NAN 0 0
853.035 -NAN 0 0
856.375 -NAN 0 0
859.714 -NAN 0 0
863.052 -NAN 0 0
866.388 -NAN 0 0
869.724 -NAN 0 0
873.058 -NAN 0 0
876.391 -NAN 0 0
879.723 -NAN 0 0
883.054 -NAN 0 0
886.384 -NAN 0 0
889.712 -NAN 0 0
893.039 -NAN 0 0
896.365 -NAN 0 0
899.69 -NAN 0 0
903.013 -NAN 0 0
906.336 -NAN 0 0
909.656 -NAN 0 0
912.976 -NAN 0 0
916.294 -NAN 0 0
919.611 -NAN 0 0
922.927 -NAN 0 0
926.241 -NAN 0 0
929.554 -NAN 0 0
932.866 -NAN 0 0
936.176 -NAN 0 0
939.485 -NAN 0 0
942.793 -NAN 0 0
946.099 -NAN 0 0
949.404 -NAN 0 0
952.707 -NAN 0 0
956.009 -NAN 0 0
959.309 -NAN 0 0
962.608 -NAN 0 0
965.906 -NAN 0 0
969.202 -NAN 0 0
972.496 -NAN 0 0
975.789 -NAN 0 0
979.081 -NAN 0 0
982.371 -NAN 0 0
985.659 -NAN 0 0
988.946 -NAN 0 0
992.231 -NAN 0 0
995.515 -NAN 0 0
998.797 -NAN 0 0
1002.08 -NAN 0 0
1005.36 -NAN 0 0
1008.63 -NAN 0 0
1011.91 -NAN 0 0
1015.18 -NAN 0 0
1018.46 -NAN 0 0
1021.73 -NAN 0 0
1025 -NAN 0 0
1028.26 -NAN 0 0
1031.53 -NAN 0 0
1034.79 -NAN 0 0
1038.06 -NAN 0 0
1041.32 -NAN 0 0
1044.58 -NAN 0 0
1047.83 -NAN 0 0
1051.09 -NAN 0 0
1054.34 -NAN 0 0
1057.59 -NAN 0 0
1060.84 -NAN 0 0
1064.09 -NAN 0 0
1067.34 -NAN 0 0
1070.58 -NAN 0 0
1073.83 -NAN 0 0
1077.07 -NAN 0 0
1080.31 -NAN 0 0
1083.54 -NAN 0 0
1086.78 -NAN 0 0
1090.01 -NAN 0 0
1093.24 -NAN 0 0
1096.47 -NAN 0 0
1099.7 -NAN 0 0
1102.92 -NAN 0 0
1106.15 -NAN 0 0
1109.37 -NAN 0 0
1112.59 -NAN 0 0
1115.81 -NAN 0 0
1119.02 -NAN 0 0
1122.24 -NAN 0 0
1125.45 -NAN 0 0
1128.66 -NAN 0 0
1131.87 -NAN 0 0
1135.07 -NAN 0 0
1138.28 -NAN 0 0
1141.48 -NAN 0 0
1144.68 -NAN 0 0
1147.87 -NAN 0 0
1151.07 -NAN 0 0
1154.26 -NAN 0 0
[END] of [DATA]
[END] of Spectrum

@ -1,7 +1,5 @@
algorithm:
'A720': 0
'PureWater': 0
'PureWater2': 0
PureWater: 1
comsetting:
baudrate: 9600
bytesize: 8
@ -9,8 +7,7 @@ comsetting:
port: COM1
stopbit: 1
device:
UIPath: 150
UISN: B055
UISN: B057
logsetting:
LogInterval: 1
RefreshInterval: 0

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -28,7 +28,7 @@ class Oscar(object):
self.raw_wavelength = []
self.raw_wavelength_np = np.array([])
self.purewater_wavelength = []
self.purewater_attenuation = []
self.purewater_absorption = []
self.output_wavelength = []
self.basis = []
self.reflectivity = []
@ -136,6 +136,7 @@ class Oscar(object):
log.info(f" -> datalen : {len(res_data)} ",__name__, "deal_one_measure_time_data")
basis = self.basis[self.begin:self.end]
refl = self.reflectivity[self.begin:self.end]
for i in range(len(res_time)):
data = self.convert_str_2_float_list( res_data[i][0][self.begin:self.end] )
@ -184,39 +185,39 @@ class Oscar(object):
self.purewater_after_interp = np.interp(
np.array(self.output_wavelength)
, np.array(self.purewater_wavelength)
, np.array(self.purewater_attenuation)
, np.array(self.purewater_absorption)
)
pass
def correction_turbidity(self, data:np.ndarray ):
'''浊度校正, 吸光度
0 : 默认11项平均
1 : 720
2 : 不浊度校正
'''
log.debug( "correction_turbidity .....",__name__, 'correction_turbidity' )
if self.cfg['algorithm']['A720'] == 0:
count = data.shape[0]
tmp = 0.0
for i in range(count-11,count,1):
tmp = tmp + data[i]
tmp = tmp/11
return data - tmp
pass
if self.cfg['algorithm']['A720'] == 1:
count = data.shape[0]
tmp = data[count] - (self.output_wavelength[count]-720) * (data[count] -data[count-1]) \
/ (self.output_wavelength[count]-self.output_wavelength[count-1])
print(f"tmp .... {tmp}")
return data-tmp
pass
if self.cfg['algorithm']['A720'] == 2:
return data
return data
pass
# def correction_turbidity(self, data:np.ndarray ):
# '''浊度校正, 吸光度
# 0 : 默认11项平均
# 1 : 720
# 2 : 不浊度校正
# '''
# log.debug( "correction_turbidity .....",__name__, 'correction_turbidity' )
# if self.cfg['algorithm']['A720'] == 0:
# count = data.shape[0]
# tmp = 0.0
# for i in range(count-11,count,1):
# tmp = tmp + data[i]
# tmp = tmp/11
# return data - tmp
# pass
# if self.cfg['algorithm']['A720'] == 1:
# count = data.shape[0]
# tmp = data[count] - (self.output_wavelength[count]-720) * (data[count] -data[count-1]) \
# / (self.output_wavelength[count]-self.output_wavelength[count-1])
# print(f"tmp .... {tmp}")
# return data-tmp
# pass
# if self.cfg['algorithm']['A720'] == 2:
# return data
# return data
# pass
def correction_pure_water(self, data:np.ndarray ):
'''浊度校正
'''纯水校正
0 : 不变
1 : 减去纯水
'''
@ -252,7 +253,7 @@ class Oscar(object):
_, res_data = ReadCal.read_columns_sets_by_mark(
cal_fpath, FILE_MARK, 0, 1)
self.purewater_wavelength = self.convert_str_2_float_list( res_data[0][0])
self.purewater_attenuation = self.convert_str_2_float_list(res_data[0][1])
self.purewater_absorption = self.convert_str_2_float_list(res_data[0][1])
def set_serial(self, )-> None:
self.uart.set_serial_para(
@ -395,45 +396,54 @@ class Oscar(object):
pass
def get_absorption_coeff( self, data, refl, basis_aq, abs_coff_pw ):
def get_absorption_coeff( self, data, basis_aq, refl, abs_coff_pw ):
"""
@description : d 一组数据
"""
r = OSCAR_R
r0 = OSCAR_R0
abs_coeff_with_pw =[]
# log.info( f" do_leastsq -> {len(data)} " )
if len(data) == len( refl) or len(data) == len( basis_aq) or len(data) == len( abs_coff_pw) :
for fa,fb,rou,ab in zip(data, basis_aq,refl, abs_coff_pw ):
Tab = float(fa)/float(fb)
#print( "Tab %s" %Tab)
EXP_ab_r0 = np.exp(-1*float(ab)*r0)
#print ( "Exp_ab_r0 %s" %EXP_ab_r0)
Ps_ab_r = ( 1 - ( 2*float(ab)*r + 1) * np.exp (-2*float(ab)*r) ) /( 2*float(ab)*float(ab)*r*r )
#print ( "Ps_ab_r %s" %Ps_ab_r)
# EXP_aa_r0 = exp(-1*aa*r0)
# Ps_aa_r = ( 1 - ( 2*aa*r + 1) * exp (-2*aa*r) ) /( 2*aa*aa*r*r )
def f(x):
return Tab*EXP_ab_r0*Ps_ab_r - \
np.exp(-1*x*r0)*( 1 - ( 2*x*r + 1) * np.exp (-2*x*r) ) /( 2*x*x*r*r ) - \
float(rou)* Tab *EXP_ab_r0*Ps_ab_r*( 1 - ( 2*x*r + 1) * np.exp (-2*x*r) ) /( 2*x*x*r*r ) + \
float(rou)* np.exp(-1*x*r0)*Ps_ab_r *( 1 - ( 2*x*r + 1) * np.exp (-2*x*r) ) /( 2*x*x*r*r )
result_with_pw = leastsq(f, 1)[0][0]
# print( result_with_pw )
# 添加到数组
abs_coeff_with_pw.append( result_with_pw )
abs_coeff_with_pw.append( self.my_do_leastsq( fa,fb,rou,ab ) )
return abs_coeff_with_pw
def my_do_leastsq( self,fa,fb,rou,ab ):
'''
验证数据如下
aa = [0.374777, 0.97631290798748 , 0.481172 , 0.00642894, 7.903851278710607]
bb= [1.23091 , 0.977035303934902 , 1.61263, 0.00622602 , 3.0728245039943833]
'''
r = OSCAR_R
r0 = OSCAR_R0
Tab = float(fa)/float(fb)
#print( "Tab %s" %Tab)
EXP_ab_r0 = np.exp(-1*float(ab)*r0)
#print ( "Exp_ab_r0 %s" %EXP_ab_r0)
Ps_ab_r = ( 1 - ( 2*float(ab)*r + 1) * np.exp (-2*float(ab)*r) ) /( 2*float(ab)*float(ab)*r*r )
#print ( "Ps_ab_r %s" %Ps_ab_r)
# EXP_aa_r0 = exp(-1*aa*r0)
# Ps_aa_r = ( 1 - ( 2*aa*r + 1) * exp (-2*aa*r) ) /( 2*aa*aa*r*r )
def f(x):
return Tab*EXP_ab_r0*Ps_ab_r - \
np.exp(-1*x*r0)*( 1 - ( 2*x*r + 1) * np.exp (-2*x*r) ) /( 2*x*x*r*r ) - \
float(rou)* Tab *EXP_ab_r0*Ps_ab_r*( 1 - ( 2*x*r + 1) * np.exp (-2*x*r) ) /( 2*x*x*r*r ) + \
float(rou)* np.exp(-1*x*r0)*Ps_ab_r *( 1 - ( 2*x*r + 1) * np.exp (-2*x*r) ) /( 2*x*x*r*r )
result_with_pw = leastsq(f, 1)[0][0]
return result_with_pw
if __name__ == '__main__':
data = np.array([3,4,5,6])
print(data.shape[0])
print(data[3])
print(data-1)
# data = np.array([3,4,5,6])
# print(data.shape[0])
# print(data[3])
# print(data-1)
# aa = [0.36774 , 0.444266 , 0.978428499401649 , 0.006471900000000001, 0.09034255552368634 ,0.08387065552368633]
# bb = [1.30934 , 1.61241 , 0.978965953688747 , 0.006268619999999998 , 0.09721998800225573 , 0.09095136800225573]
aa = [0.374777, 0.97631290798748 , 0.481172 , 0.00642894, 7.903851278710607]
bb= [1.23091 , 0.977035303934902 , 1.61263, 0.00622602 , 3.0728245039943833]

@ -26,21 +26,21 @@ class UI_Algorithm(wx.Dialog):
self.sb = wx.StaticBox(self.panel, label='算法配置')
self.sbs = wx.StaticBoxSizer(self.sb, orient=wx.VERTICAL)
self.hbox1 = wx.BoxSizer(wx.HORIZONTAL)
self.staticText1 = wx.StaticText(self.panel, label='浊度校正 ',size=(60, -1), style=wx.ALIGN_CENTRE_VERTICAL )
self.textCtrl1 = wx.TextCtrl(self.panel, value="",size=(250,25) )
tmp = self.get_str_from_config( "algorithm", "A720" )
if tmp is not None:
self.textCtrl1.SetValue(tmp)
self.hbox1.Add(self.staticText1, flag=wx.TOP|wx.LEFT, border=5)
self.hbox1.Add(self.textCtrl1, flag=wx.TOP|wx.LEFT, border=5)
self.sbs.Add(self.hbox1, flag=wx.TOP|wx.LEFT, border= 5)
# self.hbox1 = wx.BoxSizer(wx.HORIZONTAL)
# self.staticText1 = wx.StaticText(self.panel, label='浊度校正 ',size=(60, -1), style=wx.ALIGN_CENTRE_VERTICAL )
# self.textCtrl1 = wx.TextCtrl(self.panel, value="",size=(250,25) )
# tmp = self.get_str_from_config( "algorithm", "A720" )
# if tmp is not None:
# self.textCtrl1.SetValue(tmp)
# self.hbox1.Add(self.staticText1, flag=wx.TOP|wx.LEFT, border=5)
# self.hbox1.Add(self.textCtrl1, flag=wx.TOP|wx.LEFT, border=5)
# self.sbs.Add(self.hbox1, flag=wx.TOP|wx.LEFT, border= 5)
self.hbox2 = wx.BoxSizer(wx.HORIZONTAL)
self.staticText2 = wx.StaticText(self.panel, label='包含纯水: ' ,size=(60, -1))
# self.staticText2_1 = wx.StaticText(self.panel, label='分钟 ' ,size=(60, -1))
self.textCtrl2 = wx.TextCtrl(self.panel, value="",size=(250,25))
tmp = self.get_str_from_config( "algorithm", "2" )
tmp = self.get_str_from_config( "algorithm", "PureWater" )
if tmp is not None:
self.textCtrl2.SetValue(tmp)
self.hbox2.Add(self.staticText2, flag=wx.TOP|wx.LEFT, border=5)
@ -48,17 +48,17 @@ class UI_Algorithm(wx.Dialog):
# self.hbox2.Add(self.staticText2_1, flag=wx.TOP|wx.LEFT, border=5)
self.sbs.Add(self.hbox2, flag=wx.TOP|wx.LEFT, border=5)
self.hbox3 = wx.BoxSizer(wx.HORIZONTAL)
self.staticText3 = wx.StaticText(self.panel, label='纯水: ' ,size=(60, -1))
# self.staticText2_1 = wx.StaticText(self.panel, label='分钟 ' ,size=(60, -1))
self.textCtrl3 = wx.TextCtrl(self.panel, value="",size=(250,25))
tmp = self.get_str_from_config( "algorithm", "3" )
if tmp is not None:
self.textCtrl3.SetValue(tmp)
self.hbox3.Add(self.staticText3, flag=wx.TOP|wx.LEFT, border=5)
self.hbox3.Add(self.textCtrl3,flag=wx.TOP|wx.LEFT, border=5)
# self.hbox2.Add(self.staticText2_1, flag=wx.TOP|wx.LEFT, border=5)
self.sbs.Add(self.hbox3, flag=wx.TOP|wx.LEFT, border=5)
# self.hbox3 = wx.BoxSizer(wx.HORIZONTAL)
# self.staticText3 = wx.StaticText(self.panel, label='纯水: ' ,size=(60, -1))
# # self.staticText2_1 = wx.StaticText(self.panel, label='分钟 ' ,size=(60, -1))
# self.textCtrl3 = wx.TextCtrl(self.panel, value="",size=(250,25))
# tmp = self.get_str_from_config( "algorithm", "3" )
# if tmp is not None:
# self.textCtrl3.SetValue(tmp)
# self.hbox3.Add(self.staticText3, flag=wx.TOP|wx.LEFT, border=5)
# self.hbox3.Add(self.textCtrl3,flag=wx.TOP|wx.LEFT, border=5)
# # self.hbox2.Add(self.staticText2_1, flag=wx.TOP|wx.LEFT, border=5)
# self.sbs.Add(self.hbox3, flag=wx.TOP|wx.LEFT, border=5)
self.panel.SetSizer(self.sbs)
@ -101,9 +101,9 @@ class UI_Algorithm(wx.Dialog):
def OnSave(self, e):
success = True
# 赋值字典,写入文件
self.set_config_by_section_key_val( 'algorithm',"1",self.textCtrl1.GetValue( ) )
self.set_config_by_section_key_val( 'algorithm',"2",self.textCtrl2.GetValue( ) )
self.set_config_by_section_key_val( 'algorithm',"3",self.textCtrl2.GetValue( ) )
# self.set_config_by_section_key_val( 'algorithm',"1",self.textCtrl1.GetValue( ) )
self.set_config_by_section_key_val( 'algorithm',"PureWater",self.textCtrl2.GetValue( ) )
# self.set_config_by_section_key_val( 'algorithm',"3",self.textCtrl2.GetValue( ) )
self.config.write_yaml(self.config_yml)
del self.config
if success:

@ -16,6 +16,7 @@ from uiconfig.ui_filepath_setting import UI_Filepath_Setting
from uiconfig.ui_pathsn_setting import UI_PathSN_Setting
from uiconfig.ui_plot_setting import UI_Plot_Setting
from uiconfig.ui_log_setting import UI_Log_Setting
from uiconfig.ui_algorithm import UI_Algorithm
from uiconfig.uiabout import About
from uiconfig.uihelp import Help
@ -63,6 +64,8 @@ ID_PLOT_RULE = 17
ID_HELP = 21
ID_ABOUT = 22
ID_ALGORITHM = 30
class YiwinFrame( wx.Frame ):
'''将buf类传进来'''
def __init__(self, title, parent, size=(900, 750)):
@ -166,6 +169,8 @@ class YiwinFrame( wx.Frame ):
settingMenu.Append(ID_PLOT_SETTING, u'&绘图设置', ' ')
settingMenu.AppendSeparator()
settingMenu.Append(ID_LOG_SETTING, u'&采集设置', ' ')
settingMenu.AppendSeparator()
settingMenu.Append(ID_ALGORITHM, u'&算法配置', ' ')
self.menubar.Append(settingMenu, u'&系统设置')
plotMenu = wx.Menu()
@ -205,6 +210,7 @@ class YiwinFrame( wx.Frame ):
self.Bind(wx.EVT_MENU, self.OnFilePathSetting, id = ID_FILE_PATH)
self.Bind(wx.EVT_MENU, self.OnPlotSetting, id = ID_PLOT_SETTING)
self.Bind(wx.EVT_MENU, self.OnLogSetting, id = ID_LOG_SETTING)
self.Bind(wx.EVT_MENU, self.OnAlgorithm, id = ID_ALGORITHM)
self.Bind(wx.EVT_MENU, self.OnPlotOne, id = ID_PLOT_ONE)
self.Bind(wx.EVT_MENU, self.OnPlotSeven, id = ID_PLOT_SEVEN)
@ -421,7 +427,7 @@ class YiwinFrame( wx.Frame ):
time_ = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
wl = np.array(self.oscar.purewater_wavelength)
att = np.array(self.oscar.purewater_attenuation)
att = np.array(self.oscar.purewater_absorption)
self.plotpanel.plot_one(time_, wl, att)
pass
@ -556,6 +562,19 @@ class YiwinFrame( wx.Frame ):
self.__read_config()
pass
def OnAlgorithm(self,e):
with UI_Algorithm(
self,
-1 ) as Dialog_Sensor_Setting:
Dialog_Sensor_Setting.CenterOnParent()
resultLog = Dialog_Sensor_Setting.ShowModal()
if resultLog == wx.ID_OK:
log.info( " Algorithm config dialog confirm, call back " )
self.__read_config()
pass
def OnHelpConfig(self, e):
with Help(
self,

Loading…
Cancel
Save