Changeset 1017
- Timestamp:
- Jul 15, 2012 8:45:39 AM (11 years ago)
- Location:
- specdomain/trunk/src/specdomain
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
specdomain/trunk/src/specdomain/comparison/auto.mac
r1014 r1017 62 62 ---------------------------------------- 63 63 The filter adjustment assures a high incident photon rate within a band 64 just below the rate limit of the detector. The width of the band is defined65 by the step size in transmission, defined in AUTO_FILTER_FACTOR,64 just below the rate limit of the detector. The width of the band is 65 defined by the step size in transmission, defined in AUTO_FILTER_FACTOR, 66 66 which is used for each correction. If the count rate is higher than 67 67 AUTO_RATE_LIMIT, the transmission is immediately reduced by … … 132 132 133 133 No special configuration is needed to run these macros. Simply load the macro 134 file and run :spec:def:`auto_setup`::135 136 137 134 file and run ``auto_setup``:: 135 136 > qdo auto.mac 137 > auto_setup 138 138 139 139 Dependencies … … 142 142 Dependencies on other macros: 143 143 144 * :spec:macrofile:`filter.mac`(used to control the attenuators):145 146 - :spec:def:`filter_trans`147 - :spec:def:`filter_get_trans()`148 - :spec:def:`filter_get_trans_up()`149 - :spec:def:`filter_get_mask()`150 - :spec:def:`filter_max()`151 152 * :spec:def:`recount`(modified count command used to retake an exposure)144 * filter.mac (used to control the attenuators): 145 146 - filter_trans 147 - filter_get_trans() 148 - filter_get_trans_up() 149 - filter_get_mask() 150 - filter_max() 151 152 * recount (modified count command used to retake an exposure) 153 153 154 154 Impact … … 156 156 The following chained macro definitions are affected by this macro: 157 157 158 * :spec:def:`user_prescan_head`159 * :spec:def:`user_chk_counts` (from our modified :spec:def:`count` command)160 * :spec:def:`user_precount`158 * user_prescan_head 159 * user_chk_counts (provided in our modified ``count`` command) 160 * user_precount 161 161 162 162 File information … … 252 252 SPHINX code documentation suite. 253 253 254 2012/07/13 (CS):255 256 - renamed some private macros to start with underscores::257 258 auto_precount --> _auto_precount259 auto_prescan_head --> _auto_prescan_head260 auto_user_chk_counts --> _auto_user_chk_counts261 262 - moved the macro definitions for the above macros out of the263 :spec:def:`auto_set_level` macro to avoid unnecessary nested definitions.264 265 266 254 TO DO 267 255 ----- … … 270 258 - complete documentation 271 259 - insert hyperlinks into documentation 272 273 260 """ 274 261 275 ############################################################################### 262 #============================================================================== 263 264 #============================================================================== 276 265 # Global variable definitions 277 ############################################################################### 278 279 global AUTO_MAC #: Save the name of this macro file 280 global AUTO_LEVEL #: Type of adjustments {0,1,2} 281 global AUTO_MODE #: Adjustment mode (pilot vs. post-exp) {0,1} 282 global AUTO_COUNTER #: Counter to monitor 283 global AUTO_COUNT_RBV #: Counter read back value (measured counts) 284 global AUTO_RETRY_MAX #: Maximum number of retries 285 global AUTO_EXP_LOW #: Low exposure time limit 286 global AUTO_EXP_HIGH #: High exposure time limit 287 global AUTO_PILOT_EXPTIME #: Exposure time for pilot exposures 288 global AUTO_RATE_LIMIT #: High rate limit 289 global AUTO_COUNT_HIGH #: High count limit 290 global AUTO_COUNT_TARGET #: Target count level 291 global AUTO_COUNT_LOW #: Low count limit 292 global AUTO_FILTER_FACTOR #: Filter transmission factor for adjustments 293 global AUTO_COUNT_PREC #: Count time precision (rounding) 294 global AUTO_FILTER_LOCK #: Lock if rate-limited 295 global AUTO_SET_PILOT #: Set pilot exposure time in user_precount 296 global AUTO_ORIG_EXPTIME #: Save the original requested count time 297 global AUTO_DEBUG #: Debug flag 266 #============================================================================== 267 268 # Save the name of this macro file (Used for the help function). 269 global AUTO_MAC 270 AUTO_MAC = DOFILE 271 272 global AUTO_LEVEL # Type of adjustments {0,1,2} 273 global AUTO_MODE # Adjustment mode (pilot/post-exp){0,1} 274 global AUTO_COUNTER # Counter to monitor 275 global AUTO_COUNT_RBV # Counter read back value (measured counts) 276 global AUTO_RETRY_MAX # Maximum number of retries 277 global AUTO_EXP_LOW # low exposure time limit 278 global AUTO_EXP_HIGH # highexposure time limit 279 global AUTO_PILOT_EXPTIME # exposure time for pilot exposures 280 global AUTO_RATE_LIMIT # High rate limit 281 global AUTO_COUNT_HIGH # High count limit 282 global AUTO_COUNT_TARGET # Target count level 283 global AUTO_COUNT_LOW # Low count limit 284 global AUTO_FILTER_FACTOR # Filter transmission factor for adjustments 285 global AUTO_COUNT_PREC # Count time precision (rounding) 286 287 global AUTO_FILTER_LOCK # Lock if rate-limited 288 global AUTO_SET_PILOT # Set pilot exposure time in user_precount 289 global AUTO_ORIG_EXPTIME # save the original requested count time 290 global AUTO_DEBUG # debug flag 298 291 299 292 # set default values for global variables 300 AUTO_MAC = DOFILE301 293 AUTO_COUNTER = det 302 294 AUTO_LEVEL = 0 … … 317 309 AUTO_DEBUG = 0 318 310 319 320 ############################################################################### 311 #============================================================================== 321 312 # Macro command definitions 322 # ##############################################################################313 #============================================================================== 323 314 324 315 #------------------------------------------------------------------------------ 325 316 # allow for misspelled help commands 326 #def autohelp '{auto_help}'317 def autohelp 'auto_help' 327 318 328 319 def auto_help '{ … … 506 497 Turn off any automatic filter and exposure adjustments. 507 498 508 U SAGE::499 Usage:: 509 500 510 501 > auto_off 511 502 512 NOTE: 513 This command is equivalent to ``auto_set_level 0`` 514 515 SEE ALSO: 503 .. note:: This command is equivalent to ``auto_set_level 0`` 504 505 .. seealso:: 516 506 :spec:def:`auto_set_level`, 517 507 :spec:def:`auto_on` … … 527 517 def auto_on '{ 528 518 """ 529 Turn on automatic filter and exposure adjustments. 530 531 This macro is identical to :spec:def:`auto_set_level`. Please refer to the 532 :spec:def:`auto_set_level` documentation for more details. 533 """ 534 519 See :spec:def:`auto_set_level` 520 """ 535 521 auto_set_level $* 536 522 … … 542 528 Set the level of automatic filter and exposure adjustments. 543 529 544 U SAGE::530 Usage:: 545 531 546 532 > auto_set_level [<level>] 547 533 > auto_on [<level>] 548 549 If now arguement is given, the user is prompted for input. The argument 550 ``<level>`` can be one of the following: 551 552 ===== ================================================================= 553 Level Description 554 ===== ================================================================= 555 ``0`` No automatic adjustments are made 556 ``1`` Only filters are adjusted, no exposure time adjustments 557 ``2`` Both filters and exposure times are automatically adjusted 558 ===== ================================================================= 559 560 EXAMPLES:: 534 where <level> can be one of the following: 535 0 - automatic filter and exposure OFF 536 1 - automatic filter ON, automatic exposure OFF 537 2 - automatic filter and exposure ON 538 if <level> is ommitted, the users is asked for input 539 540 541 ===== ================================================================= 542 Level Description 543 ===== ================================================================= 544 0 No automatic adjustments are made 545 1 Only filters are adjusted, no exposure time adjustments 546 2 Both filters and exposure times are automatically adjusted 547 ===== ================================================================= 548 549 550 Examples:: 561 551 562 552 > auto_set_level … … 566 556 turns on automatic filter adjustments (level 1) 567 557 568 NOTE: 569 :spec:def:`auto_set_level` and :spec:def:`auto_on` are equivalent to 570 each other. 571 572 SEE ALSO: 558 .. note:: 559 ``auto_set_level`` and ``auto_on`` are equivalent to each other 560 561 .. seealso:: 573 562 :spec:def:`auto_off` 574 563 … … 606 595 } 607 596 597 #------------------------------------------- 598 # define necessary chained macro definitions 599 600 #-------------------- 601 def auto_prescan_head \' 602 # ================= 603 # if automatic filter setting is active start scan with very low 604 # filter transmission 605 if(AUTO_LEVEL > 0){ 606 AUTO_ORIG_EXPTIME = COUNT_TIME 607 filter_trans 1e-8 608 if(AUTO_LEVEL > 1){ 609 # start with low exposure times 610 COUNT_TIME = AUTO_EXP_LOW 611 _ctime = COUNT_TIME 612 } 613 } 614 # add auto_cleanup to cleanup_once 615 cdef("cleanup_once","auto_cleanup; ", "auto_cleanup_once_key",0x20) 616 \' 617 618 #----------------------- 619 def auto_user_chk_counts \' 620 # ==================== 621 if(AUTO_LEVEL > 0){ 622 # automatic filter and exposure setting (if activated) 623 success = _auto_adjust_redo() 624 } 625 \' 626 627 #---------------- 628 def auto_precount \' 629 # ============= 630 if(AUTO_LEVEL > 0){ 631 if(AUTO_MODE == 1 & AUTO_SET_PILOT == 1){ 632 # remember the original exposure time 633 AUTO_ORIG_EXPTIME = COUNT_TIME 634 # set the pilot exposure time 635 COUNT_TIME = AUTO_PILOT_EXPTIME 636 _ctime = COUNT_TIME 637 AUTO_SET_PILOT = 0 638 } 639 } 640 \' 641 642 #--------------- 643 def auto_cleanup \' 644 # ============ 645 # drop in filters after finishing, since we do not know where we end up 646 # (center of a peak for dscan?) 647 AUTO_SET_PILOT = 1 648 AUTO_FILTER_LOCK = 0 649 if(AUTO_LEVEL > 0){ 650 filter_trans 1e-8 651 } 652 cdef("cleanup_once", "", "auto_cleanup_once_key", "delete") 653 \' 654 655 608 656 #-------------------------------------------- 609 657 # include necessary chained macro definitions … … 612 660 if (AUTO_LEVEL > 0){ 613 661 614 # : add _auto_prescan_head to user_prescan_head615 cdef("user_prescan_head", " {_auto_prescan_head}; ",\616 "auto_prescan_head_key",0x10)617 618 # : add _auto_user_chk_counts to user_chk_counts619 cdef("user_chk_counts", " {_auto_user_chk_counts}; ", \662 # add auto_prescan_head to user_prescan_head 663 cdef("user_prescan_head", "auto_prescan_head; ", "auto_prescan_head_key",\ 664 0x10) 665 666 # add auto_user_chk_counts to user_chk_counts 667 cdef("user_chk_counts", "auto_user_chk_counts; ", \ 620 668 "auto_user_chk_counts_key") 621 669 622 # : add _auto_precount to user_precount623 cdef("user_precount", " {_auto_precount}; ", "auto_precount_key", 0x10)624 625 # : add _auto_cleanup to the end of user_scan_tail626 cdef("user_scan_tail"," {_auto_cleanup}; ", \670 # add auto_precount to user_precount 671 cdef("user_precount", "auto_precount; ", "auto_precount_key", 0x10) 672 673 # add auto_cleanup to the end of user_scan_tail 674 cdef("user_scan_tail","auto_cleanup; ", \ 627 675 "auto_user_scan_tail_key",0x20) 676 628 677 } 629 678 … … 637 686 if (AUTO_LEVEL < 1) { 638 687 639 # : remove _auto_prescan_head from user_prescan_head688 # remove auto_prescan_head from user_prescan_head 640 689 cdef("user_prescan_head", "", "auto_prescan_head_key", "delete") 641 690 642 # : remove _auto_user_chk_counts from user_chk_counts691 # remove auto_user_chk_counts from user_chk_counts 643 692 cdef("user_chk_counts", "", "auto_user_chk_counts_key", "delete") 644 693 645 # : remove _auto_precount from user_precount694 # remove auto_precount from user_precount 646 695 cdef("user_precount", "", "auto_precount_key", "delete") 647 696 648 # : remove _auto_cleanup from user_scan_tail697 # remove auto_cleanup from user_scan_tail and cleanup_once 649 698 cdef("user_scan_tail", "", "auto_user_scan_tail_key", "delete") 650 #: remove _auto_cleanup from cleanup_once651 699 cdef("cleanup_once", "", "auto_cleanup_once_key", "delete") 652 700 } … … 662 710 exposure time adjustments. 663 711 664 DESCRIPTION: 712 Description: 713 665 714 Need some more details here... 666 715 667 USAGE:: 716 717 Usage:: 668 718 669 719 > auto_set_mode [<mode>] … … 673 723 when called with no arguments, the user is prompted 674 724 675 E XAMPLE::725 Example:: 676 726 677 727 > auto_set_mode 1 678 728 use the pilot exposure mode for automatic adjustments. 679 729 680 SEE ALSO: 730 .. seealso:: 731 681 732 :spec:def:`auto_setup` 682 733 … … 716 767 adjustments. 717 768 718 U SAGE::769 Usage:: 719 770 720 771 > auto_set_exposure [<min> <max>] … … 722 773 when called with no arguments, the user is prompted 723 774 724 EXAMPLE:: 775 Arguments: 776 777 :param float min_exptime: minimum exposure time [s] 778 :param float max_exptime: maximum exposure time [s] 779 780 Example: 781 782 * set the minimum exposure time to 1 sec and the maximum to 10 sec:: 725 783 726 784 > auto_set_exposure 1 10 727 set the minimum exposure time to 1 sec and the maximum to 10 sec728 785 729 786 """ … … 754 811 Display the current auto settings. 755 812 756 U SAGE::813 Usage:: 757 814 758 815 > auto_show … … 800 857 Display the current auto-level exposure settings. 801 858 802 U SAGE::859 Usage:: 803 860 804 861 > auto_show_exposure … … 812 869 813 870 814 # ##############################################################################871 #============================================================================== 815 872 # Internal macros 816 ############################################################################### 817 818 #------------------------------------------------------------------------------ 819 def _auto_cleanup '{ 820 """ 821 Cleanup routine for automatic filter/exposure control 822 """ 823 824 # drop in filters after finishing, since we do not know where we end up 825 # (center of a peak for dscan?) 826 AUTO_SET_PILOT = 1 827 AUTO_FILTER_LOCK = 0 828 if(AUTO_LEVEL > 0){ 829 filter_trans 1e-10 830 } 831 #: remove _auto_cleanup_once from cleanup_once 832 cdef("cleanup_once", "", "auto_cleanup_once_key", "delete") 833 }' 834 835 836 #------------------------------------------------------------------------------ 837 def _auto_prescan_head '{ 838 """ 839 Prepare for automatic filter/exposure control before the start of a scan 840 841 This inserts filters with a transmission of 1e-10, sets some values in 842 the global variables and adds a cleanup routine to ``cleanup_once``. 843 """ 844 845 # if automatic filter setting is active start scan with very low 846 # filter transmission 847 if(AUTO_LEVEL > 0){ 848 AUTO_ORIG_EXPTIME = COUNT_TIME 849 filter_trans 1e-10 850 if(AUTO_LEVEL > 1){ 851 # start with low exposure times 852 COUNT_TIME = AUTO_EXP_LOW 853 _ctime = COUNT_TIME 854 } 855 } 856 #: add _auto_cleanup to cleanup_once 857 cdef("cleanup_once","{_auto_cleanup}; ", "auto_cleanup_once_key",0x20) 858 }' 859 860 861 #------------------------------------------------------------------------------ 862 def _auto_user_chk_counts '{ 863 """ 864 Check if counts are valid and retake exposure if necessary. 865 """ 866 867 if(AUTO_LEVEL > 0){ 868 # automatic filter and exposure setting (if activated) 869 success = _auto_adjust_redo() 870 } 871 }' 872 873 874 #------------------------------------------------------------------------------ 875 def _auto_precount '{ 876 """ 877 Prepare for automatic filter/exposure control at beginning of count command. 878 """ 879 880 if(AUTO_LEVEL > 0){ 881 if(AUTO_MODE == 1 & AUTO_SET_PILOT == 1){ 882 # remember the original exposure time 883 AUTO_ORIG_EXPTIME = COUNT_TIME 884 # set the pilot exposure time 885 COUNT_TIME = AUTO_PILOT_EXPTIME 886 _ctime = COUNT_TIME 887 AUTO_SET_PILOT = 0 888 } 889 } 890 }' 891 873 #============================================================================== 892 874 893 875 #------------------------------------------------------------------------------ 894 876 def _auto_print_setup '{ 895 877 """ 896 Print the configuration options and current values to screen 897 898 NOTE: 878 Summary 879 ------- 880 Prints the configuration options and current values to screen 881 882 .. note:: 899 883 The option numbers must be kept in sync between 900 884 :spec:def:`_auto_set_option` and … … 935 919 def _auto_set_option '{ 936 920 """ 937 Sets a new value for a given option. 938 939 DESCRIPTION: 921 Sets a new value for a given option 922 923 Description: 924 940 925 Sets a new value for a given option from the options menu that was created 941 926 with the :spec:def:`_auto_print_setup` command. 942 927 943 NOTE:944 The option numbers must be kept in sync between945 :spec:def:`_auto_set_option` and946 :spec:def:`_auto_print_setup`.928 .. note:: 929 The option numbers must be kept in sync between 930 :spec:def:`_auto_set_option` and 931 :spec:def:`_auto_print_setup`. 947 932 948 933 """ … … 1178 1163 Analyze the previous exposure 1179 1164 1180 DESCRIPTION: 1165 Description: 1166 1181 1167 This macro retrieves the necessary information to analyze the last exposure 1182 1168 and to initiate adjustments, if necessary. Usually, this step consists only … … 1186 1172 etc. 1187 1173 1188 U SAGE::1174 Usage:: 1189 1175 1190 1176 > _auto_analyze_exposure … … 1202 1188 Calculate and apply necessary exposure time and filter adjustments. 1203 1189 1204 DESCRIPTION: 1205 1206 The function returns 1 if transmission or exposure time have been changed, 1207 0 otherwise. 1208 1209 USAGE:: 1210 > changed = _auto_adjust() 1190 Description: 1191 1192 The function returns 1 if transmission or exposure time are changed, 0 1193 otherwise. 1211 1194 1212 1195 """ … … 1424 1407 Make sure the user-entered exposure times are consistent 1425 1408 1426 U SAGE::1409 Usage:: 1427 1410 1428 1411 > _auto_check_exposure … … 1446 1429 Make sure the user-entered count levels are consistent 1447 1430 1448 U SAGE::1431 Usage:: 1449 1432 1450 1433 > _auto_check_levels … … 1476 1459 round it to the given count time precision. 1477 1460 1478 U SAGE::1461 Usage:: 1479 1462 1480 1463 > adjusted_time = _auto_calc_exposure(requested_time) … … 1503 1486 Determines whether the auto-adjusting has been successful. 1504 1487 1505 D ESCRIPTION:1488 Description: 1506 1489 1507 1490 If the current exposure does not meet the required criteria, counting … … 1510 1493 The function returns 1 in case of success, 0 otherwise. 1511 1494 1512 U SAGE::1495 Usage:: 1513 1496 1514 1497 > success = _auto_adjust_redo() 1515 1498 1516 NOTE:1517 This macro makes use of the :spec:def:`recount` macro, which has to be1518 added to SPEC during the startup procedure.1499 .. note:: 1500 This macro makes use of the :spec:def:`recount` macro, which has to be 1501 added to SPEC during the startup procedure. 1519 1502 1520 1503 """ … … 1563 1546 Clears the terminal screen 1564 1547 1565 DESCRIPTION: 1548 Description: 1549 1566 1550 Clears the screen without losing the screen history or messing up the 1567 1551 scrolling capabilities (this has been a problem for certain terminals) … … 1569 1553 returning the cursor to the top left corner. 1570 1554 1571 U SAGE::1555 Usage:: 1572 1556 1573 1557 > _clear_screen … … 1592 1576 } 1593 1577 1594 # ##############################################################################1578 #============================================================================== 1595 1579 # End of $Id: $ 1596 # ##############################################################################1580 #============================================================================== -
specdomain/trunk/src/specdomain/doc/bugs.rst
r1016 r1017 9 9 * fix the signature recognition for roles 10 10 * fix the signature handling for roles and directives 11 * grep detection of macros fails for def declarations in extended comments (TRAC ticket #11)::12 13 > I found the cause of the processing error. It must have something to do14 > the the regex you use to identify definitions. Line 65 in the header15 > docstring started with the word "defined". Somehow that triggered the16 > regexp, which collected everything up to the next "(", which happens to be17 > on line 69 "(2*AUTO_FILTER_FACTOR)".18 > I temporarily fixed the problem by moving the word "defined" to the end of19 > the previous line, but this fluke could potentially arise again. Is there20 > a way of not searching for any of the function declarations (def, cdef,21 > rdef, global, ...) inside a docstring? Otherwise, you may have to improve22 > the regex. -
specdomain/trunk/src/specdomain/sphinxcontrib/specmacrofileparser.py
r1007 r1017 87 87 string_start 88 88 + r'\s*?' # optional blank space 89 + r'(r?def) '# 1: def_type (rdef | def)89 + r'(r?def)\s' # 1: def_type (rdef | def) 90 90 + non_greedy_whitespace 91 91 + macro_name_match # 2: macro_name
Note: See TracChangeset
for help on using the changeset viewer.