Parsers
superfish.parsers
Classes
Functions:
superfish.parsers.parse_automesh
parse_automesh(file)
Read an automesh input file into lines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
str
|
Path to the automesh (.AM) input file. |
required |
Returns:
| Type | Description |
|---|---|
list of str
|
Lines of the file, with line endings preserved. |
Source code in superfish/parsers.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
superfish.parsers.parse_fish_t7
parse_fish_t7(t7file, geometry='cylindrical')
Parse a Fish T7 file.
The T7 header should have::
xmin(cm), xmax(cm), nx-1
freq(MHz)
ymin(cm), ymax(cm), ny-1
followed by 4 columns of data: Ez, Er, E, Hphi.
TODO: Poisson problems, detect rectangular or cylindrical coordinates
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t7file
|
str
|
Path to the T7 file. |
required |
geometry
|
str
|
Problem geometry. Only |
'cylindrical'
|
Returns:
| Type | Description |
|---|---|
FishT7Data
|
Parsed data with keys:
|
Source code in superfish/parsers.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | |
superfish.parsers.parse_header_lines
parse_header_lines(lines)
Parse the SFO header lines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lines
|
list of str
|
Lines of the header group. |
required |
Returns:
| Type | Description |
|---|---|
SFOHeader
|
Parsed header with keys:
|
Source code in superfish/parsers.py
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 | |
superfish.parsers.parse_header_variable
parse_header_variable(line)
Parse a single variable line from the SFO header table.
The line follows the table header::
Variable Code Value Description
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
str
|
Line from the header table. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
key |
str
|
Variable name. |
value |
int or float
|
Variable value. |
description |
str
|
Variable description. |
in_automesh |
bool
|
True if the variable was set in the automesh input (code |
Source code in superfish/parsers.py
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | |
superfish.parsers.parse_poisson_t7
parse_poisson_t7(t7file, type='electric', geometry='cylindrical')
Parse a Poisson T7 file.
The T7 header should have::
xmin(cm), xmax(cm), nx-1
ymin(cm), ymax(cm), ny-1
followed by 2 columns of data:
type == "electric": Er, Ez in V/cm.type == "magnetic": Br, Bz in G.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t7file
|
str
|
Path to the T7 file. |
required |
type
|
(electric, magnetic)
|
Type of field data in the file. |
"electric"
|
geometry
|
str
|
Problem geometry. Only |
'cylindrical'
|
Returns:
| Type | Description |
|---|---|
PoissonT7Data
|
Parsed data with keys:
|
Source code in superfish/parsers.py
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | |
superfish.parsers.parse_sfo
parse_sfo(filename, verbose=False)
Master parser for the SFO file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the SFO file. |
required |
verbose
|
bool
|
Print a message for groups that have no parser. |
False
|
Returns:
| Type | Description |
|---|---|
SFOOutput
|
Parsed output with keys:
|
Source code in superfish/parsers.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
superfish.parsers.parse_sfo_beam_energy
parse_sfo_beam_energy(lines)
Parse the beam energy group.
Extracts the V0 value from the field normalization group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lines
|
list of str
|
Lines of the group. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
values |
dict
|
|
units |
dict
|
|
Source code in superfish/parsers.py
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 | |
superfish.parsers.parse_sfo_into_groups
parse_sfo_into_groups(filename)
Parse an SFO file into groups.
Groups are delimited by separator lines that start with
-------------------.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the SFO file. |
required |
Returns:
| Type | Description |
|---|---|
list of SFOGroup
|
One dict per group, with keys:
|
Source code in superfish/parsers.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
superfish.parsers.parse_sfo_segment
parse_sfo_segment(lines)
Parse a wall segment group.
The group starts with a line like
Power and fields on wall segment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lines
|
list of str
|
Lines of the wall segment group, including the first (type) line. |
required |
Returns:
| Type | Description |
|---|---|
WallSegmentData
|
Parsed segment with keys:
|
Source code in superfish/parsers.py
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 | |
superfish.parsers.parse_sfo_summary_group
parse_sfo_summary_group(lines)
Parse the summary group lines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lines
|
list of str
|
Lines of the summary group. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
values |
dict
|
Summary quantity name to value. |
units |
dict
|
Summary quantity name to unit string. |
Source code in superfish/parsers.py
610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 | |
superfish.parsers.parse_sfo_summary_group_line
parse_sfo_summary_group_line(line)
Parse a single summary group line.
Handles the special multi-value lines (field normalization,
integration path, beta, Q, Rs*Q, r/Q, average/maximum fields);
anything else falls back to :func:parse_simple_summary_line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
str
|
Summary line. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
values |
dict
|
Quantity name to value. |
units |
dict
|
Quantity name to unit string. |
Source code in superfish/parsers.py
673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 | |
superfish.parsers.parse_simple_summary_line
parse_simple_summary_line(line)
Parse a simple summary line with one key and one value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
str
|
Line of the form |
required |
Returns:
| Name | Type | Description |
|---|---|---|
values |
dict
|
Key to value. Empty if the line has no |
units |
dict
|
Key to unit string (empty string if the line has no unit). |
Source code in superfish/parsers.py
640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 | |
superfish.parsers.parse_wall_segment_line1
parse_wall_segment_line1(line)
Parse the first line of a wall segment group.
Helper for :func:parse_sfo_segment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
str
|
Line of the form
|
required |
Returns:
| Type | Description |
|---|---|
dict
|
Keys |
Source code in superfish/parsers.py
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 | |
superfish.parsers.process_group
process_group(group, verbose=False)
Process a single output group dict into usable data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group
|
SFOGroup
|
Group dict with |
required |
verbose
|
bool
|
Print a message when no parser exists for the group type. |
False
|
Returns:
| Type | Description |
|---|---|
SFOSummary or WallSegment or UnparsedGroup
|
Parsed group with a |
Source code in superfish/parsers.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |