1
0
Fork 0
mirror of https://github.com/gwm17/spspy.git synced 2024-09-21 06:57:26 -04:00

Added focal plane zoffset tool (fpcheck). Included mass file in repo.

This commit is contained in:
Gordon McCann 2022-05-17 09:28:33 -04:00
parent f11c611c18
commit 1a7a139ef4
8 changed files with 3717 additions and 2 deletions

1
.gitignore vendored
View File

@ -4,4 +4,5 @@
__pycache__ __pycache__
*.sublime-project *.sublime-project
*.sublime-workspace *.sublime-workspace
!/etc/mass.txt
!.gitignore !.gitignore

887
11C_fit.eps Normal file
View File

@ -0,0 +1,887 @@
%!PS-Adobe-3.0 EPSF-3.0
%%Title: 11C_fit.eps
%%Creator: Matplotlib v3.5.1, https://matplotlib.org/
%%CreationDate: Wed Mar 2 17:08:47 2022
%%Orientation: portrait
%%BoundingBox: 90 320 522 472
%%HiResBoundingBox: 90.000000 320.400000 522.000000 471.600000
%%EndComments
%%BeginProlog
/mpldict 12 dict def
mpldict begin
/_d { bind def } bind def
/m { moveto } _d
/l { lineto } _d
/r { rlineto } _d
/c { curveto } _d
/cl { closepath } _d
/ce { closepath eofill } _d
/box {
m
1 index 0 r
0 exch r
neg 0 r
cl
} _d
/clipbox {
box
clip
newpath
} _d
/sc { setcachedevice } _d
%!PS-Adobe-3.0 Resource-Font
%%Creator: Converted from TrueType to Type 3 by Matplotlib.
10 dict begin
/FontName /DejaVuSans def
/PaintType 0 def
/FontMatrix [0.00048828125 0 0 0.00048828125 0 0] def
/FontBBox [-2090 -948 3673 2524] def
/FontType 3 def
/Encoding [/space /c /parenleft /parenright /m /zero /one /minus /two /four /six /seven /eight] def
/CharStrings 14 dict dup begin
/.notdef 0 def
/space{651 0 0 0 0 0 sc
ce} _d
/c{1126 0 113 -29 999 1147 sc
999 1077 m
999 905 l
947 934 895 955 842 969 c
790 984 737 991 684 991 c
565 991 472 953 406 877 c
340 802 307 696 307 559 c
307 422 340 316 406 240 c
472 165 565 127 684 127 c
737 127 790 134 842 148 c
895 163 947 184 999 213 c
999 43 l
948 19 894 1 839 -11 c
784 -23 726 -29 664 -29 c
495 -29 361 24 262 130 c
163 236 113 379 113 559 c
113 742 163 885 263 990 c
364 1095 501 1147 676 1147 c
733 1147 788 1141 842 1129 c
896 1118 948 1100 999 1077 c
ce} _d
/parenleft{799 0 176 -270 635 1554 sc
635 1554 m
546 1401 479 1249 436 1099 c
393 949 371 797 371 643 c
371 489 393 336 436 185 c
480 34 546 -117 635 -270 c
475 -270 l
375 -113 300 41 250 192 c
201 343 176 494 176 643 c
176 792 201 941 250 1092 c
299 1243 374 1397 475 1554 c
635 1554 l
ce} _d
/parenright{799 0 164 -270 623 1554 sc
164 1554 m
324 1554 l
424 1397 499 1243 548 1092 c
598 941 623 792 623 643 c
623 494 598 343 548 192 c
499 41 424 -113 324 -270 c
164 -270 l
253 -117 319 34 362 185 c
406 336 428 489 428 643 c
428 797 406 949 362 1099 c
319 1249 253 1401 164 1554 c
ce} _d
/m{1995 0 186 0 1821 1147 sc
1065 905 m
1111 988 1166 1049 1230 1088 c
1294 1127 1369 1147 1456 1147 c
1573 1147 1663 1106 1726 1024 c
1789 943 1821 827 1821 676 c
1821 0 l
1636 0 l
1636 670 l
1636 777 1617 857 1579 909 c
1541 961 1483 987 1405 987 c
1310 987 1234 955 1179 892 c
1124 829 1096 742 1096 633 c
1096 0 l
911 0 l
911 670 l
911 778 892 858 854 909 c
816 961 757 987 678 987 c
584 987 509 955 454 891 c
399 828 371 742 371 633 c
371 0 l
186 0 l
186 1120 l
371 1120 l
371 946 l
413 1015 463 1065 522 1098 c
581 1131 650 1147 731 1147 c
812 1147 881 1126 938 1085 c
995 1044 1038 984 1065 905 c
ce} _d
/zero{1303 0 135 -29 1167 1520 sc
651 1360 m
547 1360 469 1309 416 1206 c
364 1104 338 950 338 745 c
338 540 364 387 416 284 c
469 182 547 131 651 131 c
756 131 834 182 886 284 c
939 387 965 540 965 745 c
965 950 939 1104 886 1206 c
834 1309 756 1360 651 1360 c
651 1520 m
818 1520 946 1454 1034 1321 c
1123 1189 1167 997 1167 745 c
1167 494 1123 302 1034 169 c
946 37 818 -29 651 -29 c
484 -29 356 37 267 169 c
179 302 135 494 135 745 c
135 997 179 1189 267 1321 c
356 1454 484 1520 651 1520 c
ce} _d
/one{1303 0 225 0 1114 1493 sc
254 170 m
584 170 l
584 1309 l
225 1237 l
225 1421 l
582 1493 l
784 1493 l
784 170 l
1114 170 l
1114 0 l
254 0 l
254 170 l
ce} _d
/minus{1716 0 217 557 1499 727 sc
217 727 m
1499 727 l
1499 557 l
217 557 l
217 727 l
ce} _d
/two{1303 0 150 0 1098 1520 sc
393 170 m
1098 170 l
1098 0 l
150 0 l
150 170 l
227 249 331 356 463 489 c
596 623 679 709 713 748 c
778 821 823 882 848 932 c
874 983 887 1032 887 1081 c
887 1160 859 1225 803 1275 c
748 1325 675 1350 586 1350 c
523 1350 456 1339 385 1317 c
315 1295 240 1262 160 1217 c
160 1421 l
241 1454 317 1478 388 1495 c
459 1512 523 1520 582 1520 c
737 1520 860 1481 952 1404 c
1044 1327 1090 1223 1090 1094 c
1090 1033 1078 974 1055 919 c
1032 864 991 800 930 725 c
913 706 860 650 771 557 c
682 465 556 336 393 170 c
ce} _d
/four{1303 0 100 0 1188 1493 sc
774 1317 m
264 520 l
774 520 l
774 1317 l
721 1493 m
975 1493 l
975 520 l
1188 520 l
1188 352 l
975 352 l
975 0 l
774 0 l
774 352 l
100 352 l
100 547 l
721 1493 l
ce} _d
/six{1303 0 143 -29 1174 1520 sc
676 827 m
585 827 513 796 460 734 c
407 672 381 587 381 479 c
381 372 407 287 460 224 c
513 162 585 131 676 131 c
767 131 838 162 891 224 c
944 287 971 372 971 479 c
971 587 944 672 891 734 c
838 796 767 827 676 827 c
1077 1460 m
1077 1276 l
1026 1300 975 1318 923 1331 c
872 1344 821 1350 770 1350 c
637 1350 535 1305 464 1215 c
394 1125 354 989 344 807 c
383 865 433 909 492 940 c
551 971 617 987 688 987 c
838 987 956 941 1043 850 c
1130 759 1174 636 1174 479 c
1174 326 1129 203 1038 110 c
947 17 827 -29 676 -29 c
503 -29 371 37 280 169 c
189 302 143 494 143 745 c
143 981 199 1169 311 1309 c
423 1450 573 1520 762 1520 c
813 1520 864 1515 915 1505 c
967 1495 1021 1480 1077 1460 c
ce} _d
/seven{1303 0 168 0 1128 1493 sc
168 1493 m
1128 1493 l
1128 1407 l
586 0 l
375 0 l
885 1323 l
168 1323 l
168 1493 l
ce} _d
/eight{1303 0 139 -29 1163 1520 sc
651 709 m
555 709 479 683 424 632 c
369 581 342 510 342 420 c
342 330 369 259 424 208 c
479 157 555 131 651 131 c
747 131 823 157 878 208 c
933 260 961 331 961 420 c
961 510 933 581 878 632 c
823 683 748 709 651 709 c
449 795 m
362 816 295 857 246 916 c
198 975 174 1048 174 1133 c
174 1252 216 1347 301 1416 c
386 1485 503 1520 651 1520 c
800 1520 916 1485 1001 1416 c
1086 1347 1128 1252 1128 1133 c
1128 1048 1104 975 1055 916 c
1007 857 940 816 854 795 c
951 772 1027 728 1081 662 c
1136 596 1163 515 1163 420 c
1163 275 1119 164 1030 87 c
942 10 816 -29 651 -29 c
486 -29 360 10 271 87 c
183 164 139 275 139 420 c
139 515 166 596 221 662 c
276 728 352 772 449 795 c
375 1114 m
375 1037 399 976 447 933 c
496 890 564 868 651 868 c
738 868 805 890 854 933 c
903 976 928 1037 928 1114 c
928 1191 903 1252 854 1295 c
805 1338 738 1360 651 1360 c
564 1360 496 1338 447 1295 c
399 1252 375 1191 375 1114 c
ce} _d
end readonly def
/BuildGlyph {
exch begin
CharStrings exch
2 copy known not {pop /.notdef} if
true 3 1 roll get exec
end
} _d
/BuildChar {
1 index /Encoding get exch get
1 index /BuildGlyph get exec
} _d
FontName currentdict end definefont pop
%!PS-Adobe-3.0 Resource-Font
%%Creator: Converted from TrueType to Type 3 by Matplotlib.
10 dict begin
/FontName /DejaVuSans-Oblique def
/PaintType 0 def
/FontMatrix [0.00048828125 0 0 0.00048828125 0 0] def
/FontBBox [-2080 -717 3398 2187] def
/FontType 3 def
/Encoding [/x /rho] def
/CharStrings 3 dict dup begin
/.notdef 0 def
/x{1212 0 -53 0 1229 1120 sc
1229 1120 m
715 571 l
1030 0 l
819 0 l
582 444 l
170 0 l
-53 0 l
498 590 l
205 1120 l
416 1120 l
631 715 l
1006 1120 l
1229 1120 l
ce} _d
/rho{1300 0 33 -426 1278 1147 sc
385 920 m
438 988 521 1052 634 1112 c
678 1135 761 1147 882 1147 c
1018 1147 1118 1093 1182 985 c
1246 877 1261 735 1227 559 c
1192 383 1122 241 1016 133 c
910 25 789 -29 653 -29 c
571 -29 504 -13 451 20 c
398 52 359 101 334 168 c
218 -426 l
33 -426 l
223 549 l
253 703 307 827 385 920 c
1036 559 m
1062 694 1055 801 1014 878 c
973 955 904 993 807 993 c
710 993 626 955 555 878 c
484 801 436 694 410 559 c
383 424 390 317 431 240 c
472 163 541 125 638 125 c
735 125 819 163 890 240 c
961 317 1009 424 1036 559 c
ce} _d
end readonly def
/BuildGlyph {
exch begin
CharStrings exch
2 copy known not {pop /.notdef} if
true 3 1 roll get exec
end
} _d
/BuildChar {
1 index /Encoding get exch get
1 index /BuildGlyph get exec
} _d
FontName currentdict end definefont pop
end
%%EndProlog
mpldict begin
90 320.4 translate
432 151.2 0 0 clipbox
0.500 setlinewidth
0 setlinejoin
0 setlinecap
[] 0 setdash
0.000 setgray
gsave
0 0 m
432 0 l
432 151.2 l
0 151.2 l
cl
gsave
1.000 setgray
fill
grestore
stroke
grestore
gsave
37.71899 33.672115 m
428.99976 33.672115 l
428.99976 148.19976 l
37.71899 148.19976 l
cl
1.000 setgray
fill
grestore
0.800 setlinewidth
1 setlinejoin
gsave
/o {
gsave
newpath
translate
0.8 setlinewidth
1 setlinejoin
0 setlinecap
0 0 m
0 -3.5 l
gsave
0.000 setgray
fill
grestore
stroke
grestore
} bind def
54.8816 33.6721 o
grestore
/DejaVuSans 10.000 selectfont
gsave
41.155048 19.078365 translate
0.000000 rotate
0.000000 0 m /minus glyphshow
8.378906 0 m /two glyphshow
14.741211 0 m /six glyphshow
21.103516 0 m /zero glyphshow
grestore
gsave
/o {
gsave
newpath
translate
0.8 setlinewidth
1 setlinejoin
0 setlinecap
0 0 m
0 -3.5 l
gsave
0.000 setgray
fill
grestore
stroke
grestore
} bind def
113.126 33.6721 o
grestore
gsave
99.399278 19.078365 translate
0.000000 rotate
0.000000 0 m /minus glyphshow
8.378906 0 m /two glyphshow
14.741211 0 m /four glyphshow
21.103516 0 m /zero glyphshow
grestore
gsave
/o {
gsave
newpath
translate
0.8 setlinewidth
1 setlinejoin
0 setlinecap
0 0 m
0 -3.5 l
gsave
0.000 setgray
fill
grestore
stroke
grestore
} bind def
171.37 33.6721 o
grestore
gsave
157.643508 19.078365 translate
0.000000 rotate
0.000000 0 m /minus glyphshow
8.378906 0 m /two glyphshow
14.741211 0 m /two glyphshow
21.103516 0 m /zero glyphshow
grestore
gsave
/o {
gsave
newpath
translate
0.8 setlinewidth
1 setlinejoin
0 setlinecap
0 0 m
0 -3.5 l
gsave
0.000 setgray
fill
grestore
stroke
grestore
} bind def
229.614 33.6721 o
grestore
gsave
215.887739 19.078365 translate
0.000000 rotate
0.000000 0 m /minus glyphshow
8.378906 0 m /two glyphshow
14.741211 0 m /zero glyphshow
21.103516 0 m /zero glyphshow
grestore
gsave
/o {
gsave
newpath
translate
0.8 setlinewidth
1 setlinejoin
0 setlinecap
0 0 m
0 -3.5 l
gsave
0.000 setgray
fill
grestore
stroke
grestore
} bind def
287.859 33.6721 o
grestore
gsave
274.131969 19.078365 translate
0.000000 rotate
0.000000 0 m /minus glyphshow
8.378906 0 m /one glyphshow
14.741211 0 m /eight glyphshow
21.103516 0 m /zero glyphshow
grestore
gsave
/o {
gsave
newpath
translate
0.8 setlinewidth
1 setlinejoin
0 setlinecap
0 0 m
0 -3.5 l
gsave
0.000 setgray
fill
grestore
stroke
grestore
} bind def
346.103 33.6721 o
grestore
gsave
332.376199 19.078365 translate
0.000000 rotate
0.000000 0 m /minus glyphshow
8.378906 0 m /one glyphshow
14.741211 0 m /six glyphshow
21.103516 0 m /zero glyphshow
grestore
gsave
/o {
gsave
newpath
translate
0.8 setlinewidth
1 setlinejoin
0 setlinecap
0 0 m
0 -3.5 l
gsave
0.000 setgray
fill
grestore
stroke
grestore
} bind def
404.347 33.6721 o
grestore
gsave
390.620429 19.078365 translate
0.000000 rotate
0.000000 0 m /minus glyphshow
8.378906 0 m /one glyphshow
14.741211 0 m /four glyphshow
21.103516 0 m /zero glyphshow
grestore
gsave
214.859375 5.078365 translate
0.000000 rotate
/DejaVuSans-Oblique 10.0 selectfont
0.000000 0.406250 moveto
/x glyphshow
/DejaVuSans 10.0 selectfont
5.917969 0.406250 moveto
/space glyphshow
9.096680 0.406250 moveto
/parenleft glyphshow
12.998047 0.406250 moveto
/m glyphshow
22.739258 0.406250 moveto
/m glyphshow
32.480469 0.406250 moveto
/parenright glyphshow
grestore
gsave
/o {
gsave
newpath
translate
0.8 setlinewidth
1 setlinejoin
0 setlinecap
-0 0 m
-3.5 0 l
gsave
0.000 setgray
fill
grestore
stroke
grestore
} bind def
37.719 50.8677 o
grestore
gsave
18.000240 47.070840 translate
0.000000 rotate
0.000000 0 m /seven glyphshow
6.362305 0 m /zero glyphshow
grestore
gsave
/o {
gsave
newpath
translate
0.8 setlinewidth
1 setlinejoin
0 setlinecap
-0 0 m
-3.5 0 l
gsave
0.000 setgray
fill
grestore
stroke
grestore
} bind def
37.719 96.096 o
grestore
gsave
18.000240 92.299152 translate
0.000000 rotate
0.000000 0 m /seven glyphshow
6.362305 0 m /two glyphshow
grestore
gsave
/o {
gsave
newpath
translate
0.8 setlinewidth
1 setlinejoin
0 setlinecap
-0 0 m
-3.5 0 l
gsave
0.000 setgray
fill
grestore
stroke
grestore
} bind def
37.719 141.324 o
grestore
gsave
18.000240 137.527464 translate
0.000000 rotate
0.000000 0 m /seven glyphshow
6.362305 0 m /four glyphshow
grestore
gsave
11.000240 74.435937 translate
90.000000 rotate
/DejaVuSans-Oblique 10.0 selectfont
0.000000 0.406250 moveto
/rho glyphshow
/DejaVuSans 10.0 selectfont
6.347656 0.406250 moveto
/space glyphshow
9.526367 0.406250 moveto
/parenleft glyphshow
13.427734 0.406250 moveto
/c glyphshow
18.925781 0.406250 moveto
/m glyphshow
28.666992 0.406250 moveto
/parenright glyphshow
grestore
1.500 setlinewidth
0.122 0.467 0.706 setrgbcolor
gsave
391.281 114.528 37.719 33.672 clipbox
55.50448 38.936602 m
57.261815 38.936602 l
stroke
grestore
gsave
391.281 114.528 37.719 33.672 clipbox
115.79737 56.684726 m
117.570009 56.684726 l
stroke
grestore
gsave
391.281 114.528 37.719 33.672 clipbox
134.046325 62.41111 m
135.850671 62.41111 l
stroke
grestore
gsave
391.281 114.528 37.719 33.672 clipbox
343.718019 123.926997 m
345.473365 123.926997 l
stroke
grestore
gsave
391.281 114.528 37.719 33.672 clipbox
409.454726 142.767063 m
411.21427 142.767063 l
stroke
grestore
gsave
391.281 114.528 37.719 33.672 clipbox
56.383147 38.877917 m
56.383147 38.995286 l
stroke
grestore
gsave
391.281 114.528 37.719 33.672 clipbox
116.68369 56.631041 m
116.68369 56.738412 l
stroke
grestore
gsave
391.281 114.528 37.719 33.672 clipbox
134.948498 62.35357 m
134.948498 62.46865 l
stroke
grestore
gsave
391.281 114.528 37.719 33.672 clipbox
344.595692 123.880074 m
344.595692 123.97392 l
stroke
grestore
gsave
391.281 114.528 37.719 33.672 clipbox
410.334498 142.720827 m
410.334498 142.813299 l
stroke
grestore
2 setlinecap
1.000 0.498 0.055 setrgbcolor
gsave
391.281 114.528 37.719 33.672 clipbox
56.383147 39.086887 m
410.334498 142.993958 l
410.334498 142.993958 l
stroke
grestore
1.000 setlinewidth
0 setlinecap
0.122 0.467 0.706 setrgbcolor
gsave
391.281 114.528 37.719 33.672 clipbox
/o {
gsave
newpath
translate
1.0 setlinewidth
1 setlinejoin
0 setlinecap
0 -3 m
0.795609 -3 1.55874 -2.683901 2.12132 -2.12132 c
2.683901 -1.55874 3 -0.795609 3 0 c
3 0.795609 2.683901 1.55874 2.12132 2.12132 c
1.55874 2.683901 0.795609 3 0 3 c
-0.795609 3 -1.55874 2.683901 -2.12132 2.12132 c
-2.683901 1.55874 -3 0.795609 -3 0 c
-3 -0.795609 -2.683901 -1.55874 -2.12132 -2.12132 c
-1.55874 -2.683901 -0.795609 -3 0 -3 c
cl
gsave
0.122 0.467 0.706 setrgbcolor
fill
grestore
stroke
grestore
} bind def
56.3831 38.9366 o
116.684 56.6847 o
134.948 62.4111 o
344.596 123.927 o
410.334 142.767 o
grestore
0.800 setlinewidth
0 setlinejoin
2 setlinecap
0.000 setgray
gsave
37.71899 33.672115 m
37.71899 148.19976 l
stroke
grestore
gsave
428.99976 33.672115 m
428.99976 148.19976 l
stroke
grestore
gsave
37.71899 33.672115 m
428.99976 33.672115 l
stroke
grestore
end
showpage

3
bin/fpcheck Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
./fpcheck/FPCheckGUI.py

2500
etc/mass.txt Normal file

File diff suppressed because it is too large Load Diff

179
fpcheck/FPCheckGUI.py Executable file
View File

@ -0,0 +1,179 @@
#!/usr/bin/env python3
from Reaction import Reaction
from qtpy.QtWidgets import QApplication, QWidget, QMainWindow
from qtpy.QtWidgets import QLabel, QMenuBar, QAction
from qtpy.QtWidgets import QHBoxLayout, QVBoxLayout, QGridLayout, QGroupBox
from qtpy.QtWidgets import QPushButton, QButtonGroup, QRadioButton
from qtpy.QtWidgets import QSpinBox, QDoubleSpinBox, QComboBox
from qtpy.QtWidgets import QDialog, QFileDialog, QDialogButtonBox
from qtpy.QtWidgets import QTableWidget, QTableWidgetItem
from qtpy.QtWidgets import QLineEdit, QTabWidget, QFormLayout
from qtpy.QtCore import Signal
import sys
class ReactionDialog(QDialog):
new_reaction = Signal(Reaction)
update_reaction = Signal(float, float, float, str)
def __init__(self, parent=None, rxn=None):
super().__init__(parent)
self.setWindowTitle("Add A Reaction")
QBtn = QDialogButtonBox.Ok | QDialogButtonBox.Cancel
self.buttonBox = QDialogButtonBox(QBtn)
self.buttonBox.accepted.connect(self.accept)
if rxn is not None:
self.buttonBox.accepted.connect(self.SendReactionUpdate)
else:
self.buttonBox.accepted.connect(self.SendReaction)
self.buttonBox.rejected.connect(self.reject)
self.layout = QVBoxLayout()
self.setLayout(self.layout)
self.CreateReactionInputs()
if rxn is not None:
self.SetInitialValues(rxn)
self.layout.addWidget(self.buttonBox)
def SendReaction(self) :
rxn = Reaction(self.ztInput.value(), self.atInput.value(), self.zpInput.value(),self.apInput.value(),self.zeInput.value(),self.aeInput.value(), self.bkeInput.value(), self.thetaInput.value(), self.bfieldInput.value())
self.new_reaction.emit(rxn)
def SendReactionUpdate(self):
self.update_reaction.emit(self.bkeInput.value(), self.thetaInput.value(), self.bfieldInput.value(), self.rxnKey)
def CreateReactionInputs(self) :
self.nucleiGroupBox = QGroupBox("Reaction Nuclei",self)
inputLayout = QFormLayout()
self.ztInput = QSpinBox(self.nucleiGroupBox)
self.ztInput.setRange(1, 110)
self.atInput = QSpinBox(self.nucleiGroupBox)
self.atInput.setRange(1,270)
self.zpInput = QSpinBox(self.nucleiGroupBox)
self.zpInput.setRange(1, 110)
self.apInput = QSpinBox(self.nucleiGroupBox)
self.apInput.setRange(1,270)
self.zeInput = QSpinBox(self.nucleiGroupBox)
self.zeInput.setRange(1, 110)
self.aeInput = QSpinBox(self.nucleiGroupBox)
self.aeInput.setRange(1,270)
inputLayout.addRow("ZT",self.ztInput)
inputLayout.addRow("AT",self.atInput)
inputLayout.addRow("ZP",self.zpInput)
inputLayout.addRow("AP",self.apInput)
inputLayout.addRow("ZE",self.zeInput)
inputLayout.addRow("AE",self.aeInput)
self.parameterGroupBox = QGroupBox("Reaction Parameters", self)
parameterLayout = QFormLayout()
self.bkeInput = QDoubleSpinBox(self.parameterGroupBox)
self.bkeInput.setRange(0.0, 40.0)
self.bkeInput.setDecimals(4)
self.thetaInput = QDoubleSpinBox(self.parameterGroupBox)
self.thetaInput.setRange(0.0, 180.0)
self.thetaInput.setDecimals(4)
self.bfieldInput = QDoubleSpinBox(self.parameterGroupBox)
self.bfieldInput.setRange(0.0, 16.0)
self.bfieldInput.setDecimals(6)
parameterLayout.addRow("Beam KE(Mev)",self.bkeInput)
parameterLayout.addRow("Theta(deg)",self.thetaInput)
parameterLayout.addRow("Bfield(kG)",self.bfieldInput)
self.nucleiGroupBox.setLayout(inputLayout)
self.parameterGroupBox.setLayout(parameterLayout)
self.layout.addWidget(self.nucleiGroupBox)
self.layout.addWidget(self.parameterGroupBox)
def SetInitialValues(self, rxn):
self.ztInput.setValue(rxn.Target.Z)
self.ztInput.setEnabled(False)
self.atInput.setValue(rxn.Target.A)
self.atInput.setEnabled(False)
self.zpInput.setValue(rxn.Projectile.Z)
self.zpInput.setEnabled(False)
self.apInput.setValue(rxn.Projectile.A)
self.apInput.setEnabled(False)
self.zeInput.setValue(rxn.Ejectile.Z)
self.zeInput.setEnabled(False)
self.aeInput.setValue(rxn.Ejectile.A)
self.aeInput.setEnabled(False)
self.bkeInput.setValue(rxn.BKE)
self.thetaInput.setValue(rxn.Theta/rxn.DEG2RAD)
self.bfieldInput.setValue(rxn.Bfield)
class FPCheckGUI(QMainWindow):
def __init__(self, parent=None):
super().__init__(parent)
self.setWindowTitle("FPCheck")
self.reactions = [] #data
self.centralLayout = QVBoxLayout()
self.centralWidget = QWidget(self)
self.setCentralWidget(self.centralWidget)
self.centralWidget.setLayout(self.centralLayout)
self.CreateMenus()
self.CreateTable()
self.show()
def CreateMenus(self):
self.fileMenu = self.menuBar().addMenu("File")
saveAction = QAction("Save", self)
loadAction = QAction("Load", self)
exitAction = QAction("Exit", self)
self.fileMenu.addAction(saveAction)
self.fileMenu.addAction(loadAction)
self.fileMenu.addAction(exitAction)
def CreateTable(self):
self.reactionTable = QTableWidget(self)
self.reactionTable.setColumnCount(8)
self.reactionTable.setHorizontalHeaderLabels(["Target","Projectile","Ejectile","Residual","Beam KE(MeV)","BField(kG)","Angle(deg)","FP ZOffset (cm)"])
self.centralLayout.addWidget(self.reactionTable)
self.reactionTable.resizeColumnsToContents()
self.addButton = QPushButton("Add", self)
self.addButton.clicked.connect(self.HandleAddReaction)
self.centralLayout.addWidget(self.addButton)
def HandleAddReaction(self):
rxnDia = ReactionDialog(self)
rxnDia.new_reaction.connect(self.AddReaction)
rxnDia.exec()
def UpdateTable(self):
self.reactionTable.setRowCount(len(self.reactions))
curRow = 0
for rxn in self.reactions:
self.reactionTable.setItem(curRow, 0, QTableWidgetItem(rxn.Target.Symbol))
self.reactionTable.setItem(curRow, 1, QTableWidgetItem(rxn.Projectile.Symbol))
self.reactionTable.setItem(curRow, 2, QTableWidgetItem(rxn.Ejectile.Symbol))
self.reactionTable.setItem(curRow, 3, QTableWidgetItem(rxn.Residual.Symbol))
self.reactionTable.setItem(curRow, 4, QTableWidgetItem(str(rxn.BKE)))
self.reactionTable.setItem(curRow, 5, QTableWidgetItem(str(rxn.Bfield)))
self.reactionTable.setItem(curRow, 6, QTableWidgetItem(str(rxn.Theta)))
self.reactionTable.setItem(curRow, 7, QTableWidgetItem(str(rxn.GetFocalPlaneZOffset())))
curRow += 1
self.reactionTable.resizeColumnsToContents()
self.reactionTable.resizeRowsToContents()
def AddReaction(self, rxn):
self.reactions.append(rxn)
self.UpdateTable()
def main():
myapp = QApplication(sys.argv)
window = FPCheckGUI()
sys.exit(myapp.exec_())
if __name__ == '__main__':
main()

70
fpcheck/NucData.py Executable file
View File

@ -0,0 +1,70 @@
#!/usr/bin/env python3
import numpy as np
import requests
import lxml.html as xhtml
class MassTable:
def __init__(self):
file = open("./etc/mass.txt","r")
self.mtable = {}
u2mev = 931.4940954
me = 0.000548579909
self.etable = {}
file.readline()
file.readline()
for line in file:
entries = line.split()
n = entries[0]
z = entries[1]
a = entries[2]
element = entries[3]
massBig = float(entries[4])
massSmall = float(entries[5])
key = '('+z+','+a+')'
value = ((massBig+massSmall*1e-6) - float(z)*me)*u2mev
self.mtable[key] = value
self.etable[key] = element
file.close()
def GetMass(self, z, a):
key = '('+str(z)+','+str(a)+')'
if key in self.mtable:
return self.mtable[key]
else:
return 0
def GetSymbol(self, z, a):
key = '('+str(z)+','+str(a)+')'
if key in self.etable:
return str(a)+self.etable[key]
else:
return 'none'
Masses = MassTable()
def GetExcitations(symbol):
levels = np.array(np.empty(0))
text = ''
site = requests.get("https://www.nndc.bnl.gov/nudat2/getdatasetClassic.jsp?nucleus="+symbol+"&unc=nds")
contents = xhtml.fromstring(site.content)
tables = contents.xpath("//table")
rows = tables[2].xpath("./tr")
for row in rows[1:-2]:
entries = row.xpath("./td")
if len(entries) != 0:
entry = entries[0]
data = entry.xpath("./a")
if len(data) == 0:
text = entry.text
else:
text = data[0].text
text = text.replace('?', '')
text = text.replace('\xa0\xa0','')
levels = np.append(levels, float(text)/1000.0)
return levels

67
fpcheck/Reaction.py Normal file
View File

@ -0,0 +1,67 @@
#!/usr/bin/env python3
from NucData import Masses
import numpy as np
class Nucleus:
def __init__(self, z, a):
self.Z = z
self.A = a
self.Symbol = Masses.GetSymbol(self.Z, self.A)
self.GSMass = Masses.GetMass(self.Z, self.A)
def Minus(self, rhs):
final_Z = self.Z - rhs.Z
final_A = self.A - rhs.A
if final_A < 0 or final_Z < 0:
print("Illegal minus operation on Nuclei!")
return Nucleus(0,0)
else:
return Nucleus(final_Z, final_A)
def Plus(self, rhs):
return Nucleus(self.Z + rhs.Z, self.A + rhs.A)
class Reaction:
DEG2RAD = np.pi/180.0 #degrees to radians
C = 299792458 #speed of light m/s
QBRHO2P = 1.0E-9*C #Converts qbrho to p (kG*cm -> MeV/c)
DISP = 1.96
MAG = 0.39
def __init__(self, zt, at, zp, ap, ze, ae, beamKE, theta, bfield):
self.Target = Nucleus(zt, at)
self.Projectile = Nucleus(zp, ap)
self.Ejectile = Nucleus(ze, ae)
self.Residual = (self.Target.Plus(self.Projectile)).Minus(self.Ejectile)
self.BKE = beamKE
self.Theta = theta * self.DEG2RAD
self.Bfield = bfield
self.Name = self.Target.Symbol +"("+ self.Projectile.Symbol +","+ self.Ejectile.Symbol +")"+ self.Residual.Symbol
def GetEjectileKineticEnergy(self, Elevel) :
Q = self.Target.GSMass + self.Projectile.GSMass - (self.Ejectile.GSMass + self.Residual.GSMass + Elevel)
Ethresh = -Q*(self.Ejectile.GSMass+self.Residual.GSMass)/(self.Ejectile.GSMass + self.Residual.GSMass - self.Projectile.GSMass)
if self.BKE < Ethresh:
return 0.0
term1 = np.sqrt(self.Projectile.GSMass*self.Ejectile.GSMass*self.BKE)/(self.Ejectile.GSMass + self.Residual.GSMass)*np.cos(self.Theta)
term2 = (self.BKE*(self.Residual.GSMass - self.Projectile.GSMass) + self.Residual.GSMass*Q)/(self.Ejectile.GSMass + self.Residual.GSMass)
ke1 = term1 + np.sqrt(term1**2.0 + term2)
ke2 = term1 - np.sqrt(term1**2.0 + term2)
if ke1 > 0:
return ke1**2.0
else :
return ke2**2.0
def GetFocalPlaneZOffset(self):
ejectKE = self.GetEjectileKineticEnergy(0.0)
ejectP = np.sqrt(ejectKE**2.0 + 2.0*ejectKE*self.Ejectile.GSMass)
rho = ejectP/(self.QBRHO2P*self.Bfield*self.Ejectile.Z)
K = np.sqrt(self.Projectile.GSMass*self.Ejectile.GSMass*self.BKE/ejectKE)*np.sin(self.Theta)
K /= self.Ejectile.GSMass + self.Residual.GSMass - np.sqrt(self.Projectile.GSMass*self.Ejectile.GSMass*self.BKE/ejectKE)*np.cos(self.Theta)
return -1.0*K*rho*self.DISP*self.MAG
def ChangeReactionParameters(self, bke, theta, bfield) :
self.BKE = bke
self.Theta = theta*self.DEG2RAD
self.Bfield = bfield

View File

@ -474,11 +474,14 @@ class SpancGUI(QMainWindow):
self.fileMenu = self.menuBar().addMenu("&File") self.fileMenu = self.menuBar().addMenu("&File")
saveAction = QAction("&Save...",self) saveAction = QAction("&Save...",self)
openAction = QAction("&Open...",self) openAction = QAction("&Open...",self)
saveFitAction = QAction("Save Fit Plot...", self)
self.fileMenu.addAction(saveAction) self.fileMenu.addAction(saveAction)
self.fileMenu.addAction(openAction) self.fileMenu.addAction(openAction)
self.fileMenu.addAction(saveFitAction)
self.fileMenu.addAction("&Exit", self.close) self.fileMenu.addAction("&Exit", self.close)
saveAction.triggered.connect(self.HandleSave) saveAction.triggered.connect(self.HandleSave)
openAction.triggered.connect(self.HandleOpen) openAction.triggered.connect(self.HandleOpen)
saveFitAction.triggered.connect(self.HandleSaveFit)
self.addMenu = self.menuBar().addMenu("&New") self.addMenu = self.menuBar().addMenu("&New")
newTargetAction = QAction("New target...", self) newTargetAction = QAction("New target...", self)
@ -614,6 +617,11 @@ class SpancGUI(QMainWindow):
pickle.dump(self.spanc, savefile, pickle.HIGHEST_PROTOCOL) pickle.dump(self.spanc, savefile, pickle.HIGHEST_PROTOCOL)
savefile.close() savefile.close()
def HandleSaveFit(self):
fileName = QFileDialog.getSaveFileName(self, "Save Fit Image","./","Image Files (*.png, *.eps)")
if fileName[0]:
self.fitCanvas.fig.savefig(fileName[0])
def HandleOpen(self): def HandleOpen(self):
fileName = QFileDialog.getOpenFileName(self, "Open Input","./","Text Files (*.pickle)") fileName = QFileDialog.getOpenFileName(self, "Open Input","./","Text Files (*.pickle)")
if fileName[0]: if fileName[0]:
@ -690,7 +698,7 @@ class SpancGUI(QMainWindow):
xarray, yarray, uxarray, uyarray = self.spanc.PerformFits() xarray, yarray, uxarray, uyarray = self.spanc.PerformFits()
fitarray = np.linspace(np.amin(xarray), np.amax(xarray), 1000) fitarray = np.linspace(np.amin(xarray), np.amax(xarray), 1000)
self.fitCanvas.axes.cla() self.fitCanvas.axes.cla()
self.fitCanvas.axes.errorbar(xarray, yarray, yerr=uyarray, xerr=uxarray, marker="o", linestyle="None") self.fitCanvas.axes.errorbar(xarray, yarray, yerr=uyarray, xerr=uxarray, marker="o", linestyle="None", elinewidth=2.0)
self.fitCanvas.axes.plot(fitarray, self.spanc.fitters[fit_type].EvaluateFunction(fitarray)) self.fitCanvas.axes.plot(fitarray, self.spanc.fitters[fit_type].EvaluateFunction(fitarray))
self.fitCanvas.axes.set_xlabel(r"$x$ (mm)") self.fitCanvas.axes.set_xlabel(r"$x$ (mm)")
self.fitCanvas.axes.set_ylabel(r"$\rho$ (cm)") self.fitCanvas.axes.set_ylabel(r"$\rho$ (cm)")