Changeset 1014
- Timestamp:
- Jul 14, 2012 8:50:54 AM (11 years ago)
- Location:
- specdomain/trunk/src/specdomain/comparison
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
specdomain/trunk/src/specdomain/comparison/auto.mac
r1011 r1014 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 65 definedby 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 defined 65 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 ``auto_setup``::135 136 > qdo auto.mac137 > auto_setup134 file and run :spec:def:`auto_setup`:: 135 136 > qdo auto.mac 137 > auto_setup 138 138 139 139 Dependencies … … 142 142 Dependencies on other macros: 143 143 144 * filter.mac(used to control the attenuators):145 146 - filter_trans147 - 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)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) 153 153 154 154 Impact … … 156 156 The following chained macro definitions are affected by this macro: 157 157 158 * user_prescan_head159 * user_chk_counts (provided in our modified ``count`` command)160 * user_precount158 * :spec:def:`user_prescan_head` 159 * :spec:def:`user_chk_counts` (from our modified :spec:def:`count` command) 160 * :spec:def:`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_precount 259 auto_prescan_head --> _auto_prescan_head 260 auto_user_chk_counts --> _auto_user_chk_counts 261 262 - moved the macro definitions for the above macros out of the 263 :spec:def:`auto_set_level` macro to avoid unnecessary nested definitions. 264 265 254 266 TO DO 255 267 ----- … … 258 270 - complete documentation 259 271 - insert hyperlinks into documentation 272 260 273 """ 261 274 262 #============================================================================== 263 264 #============================================================================== 275 ############################################################################### 265 276 # Global variable definitions 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 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 291 298 292 299 # set default values for global variables 300 AUTO_MAC = DOFILE 293 301 AUTO_COUNTER = det 294 302 AUTO_LEVEL = 0 … … 309 317 AUTO_DEBUG = 0 310 318 311 #============================================================================== 319 320 ############################################################################### 312 321 # Macro command definitions 313 # ==============================================================================322 ############################################################################### 314 323 315 324 #------------------------------------------------------------------------------ 316 325 # allow for misspelled help commands 317 def autohelp 'auto_help'326 #def autohelp '{auto_help}' 318 327 319 328 def auto_help '{ … … 497 506 Turn off any automatic filter and exposure adjustments. 498 507 499 U sage::508 USAGE:: 500 509 501 510 > auto_off 502 511 503 .. note:: This command is equivalent to ``auto_set_level 0`` 504 505 .. seealso:: 512 NOTE: 513 This command is equivalent to ``auto_set_level 0`` 514 515 SEE ALSO: 506 516 :spec:def:`auto_set_level`, 507 517 :spec:def:`auto_on` … … 517 527 def auto_on '{ 518 528 """ 519 See :spec:def:`auto_set_level` 520 """ 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 521 535 auto_set_level $* 522 536 … … 528 542 Set the level of automatic filter and exposure adjustments. 529 543 530 U sage::544 USAGE:: 531 545 532 546 > auto_set_level [<level>] 533 547 > auto_on [<level>] 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:: 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:: 551 561 552 562 > auto_set_level … … 556 566 turns on automatic filter adjustments (level 1) 557 567 558 .. note:: 559 ``auto_set_level`` and ``auto_on`` are equivalent to each other 560 561 .. seealso:: 568 NOTE: 569 :spec:def:`auto_set_level` and :spec:def:`auto_on` are equivalent to 570 each other. 571 572 SEE ALSO: 562 573 :spec:def:`auto_off` 563 574 … … 595 606 } 596 607 597 #-------------------------------------------598 # define necessary chained macro definitions599 600 #--------------------601 def auto_prescan_head \'602 # =================603 # if automatic filter setting is active start scan with very low604 # filter transmission605 if(AUTO_LEVEL > 0){606 AUTO_ORIG_EXPTIME = COUNT_TIME607 filter_trans 1e-8608 if(AUTO_LEVEL > 1){609 # start with low exposure times610 COUNT_TIME = AUTO_EXP_LOW611 _ctime = COUNT_TIME612 }613 }614 # add auto_cleanup to cleanup_once615 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 time633 AUTO_ORIG_EXPTIME = COUNT_TIME634 # set the pilot exposure time635 COUNT_TIME = AUTO_PILOT_EXPTIME636 _ctime = COUNT_TIME637 AUTO_SET_PILOT = 0638 }639 }640 \'641 642 #---------------643 def auto_cleanup \'644 # ============645 # drop in filters after finishing, since we do not know where we end up646 # (center of a peak for dscan?)647 AUTO_SET_PILOT = 1648 AUTO_FILTER_LOCK = 0649 if(AUTO_LEVEL > 0){650 filter_trans 1e-8651 }652 cdef("cleanup_once", "", "auto_cleanup_once_key", "delete")653 \'654 655 656 608 #-------------------------------------------- 657 609 # include necessary chained macro definitions … … 660 612 if (AUTO_LEVEL > 0){ 661 613 662 # addauto_prescan_head to user_prescan_head663 cdef("user_prescan_head", " auto_prescan_head; ", "auto_prescan_head_key",\664 0x10)665 666 # addauto_user_chk_counts to user_chk_counts667 cdef("user_chk_counts", " auto_user_chk_counts; ", \614 #: add _auto_prescan_head to user_prescan_head 615 cdef("user_prescan_head", "{_auto_prescan_head}; ", \ 616 "auto_prescan_head_key", 0x10) 617 618 #: add _auto_user_chk_counts to user_chk_counts 619 cdef("user_chk_counts", "{_auto_user_chk_counts}; ", \ 668 620 "auto_user_chk_counts_key") 669 621 670 # addauto_precount to user_precount671 cdef("user_precount", " auto_precount; ", "auto_precount_key", 0x10)672 673 # addauto_cleanup to the end of user_scan_tail674 cdef("user_scan_tail"," auto_cleanup; ", \622 #: add _auto_precount to user_precount 623 cdef("user_precount", "{_auto_precount}; ", "auto_precount_key", 0x10) 624 625 #: add _auto_cleanup to the end of user_scan_tail 626 cdef("user_scan_tail","{_auto_cleanup}; ", \ 675 627 "auto_user_scan_tail_key",0x20) 676 677 628 } 678 629 … … 686 637 if (AUTO_LEVEL < 1) { 687 638 688 # removeauto_prescan_head from user_prescan_head639 #: remove _auto_prescan_head from user_prescan_head 689 640 cdef("user_prescan_head", "", "auto_prescan_head_key", "delete") 690 641 691 # removeauto_user_chk_counts from user_chk_counts642 #: remove _auto_user_chk_counts from user_chk_counts 692 643 cdef("user_chk_counts", "", "auto_user_chk_counts_key", "delete") 693 644 694 # removeauto_precount from user_precount645 #: remove _auto_precount from user_precount 695 646 cdef("user_precount", "", "auto_precount_key", "delete") 696 647 697 # remove auto_cleanup from user_scan_tail and cleanup_once648 #: remove _auto_cleanup from user_scan_tail 698 649 cdef("user_scan_tail", "", "auto_user_scan_tail_key", "delete") 650 #: remove _auto_cleanup from cleanup_once 699 651 cdef("cleanup_once", "", "auto_cleanup_once_key", "delete") 700 652 } … … 710 662 exposure time adjustments. 711 663 712 Description: 713 664 DESCRIPTION: 714 665 Need some more details here... 715 666 716 717 Usage:: 667 USAGE:: 718 668 719 669 > auto_set_mode [<mode>] … … 723 673 when called with no arguments, the user is prompted 724 674 725 E xample::675 EXAMPLE:: 726 676 727 677 > auto_set_mode 1 728 678 use the pilot exposure mode for automatic adjustments. 729 679 730 .. seealso:: 731 680 SEE ALSO: 732 681 :spec:def:`auto_setup` 733 682 … … 767 716 adjustments. 768 717 769 U sage::718 USAGE:: 770 719 771 720 > auto_set_exposure [<min> <max>] … … 773 722 when called with no arguments, the user is prompted 774 723 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:: 724 EXAMPLE:: 783 725 784 726 > auto_set_exposure 1 10 727 set the minimum exposure time to 1 sec and the maximum to 10 sec 785 728 786 729 """ … … 811 754 Display the current auto settings. 812 755 813 U sage::756 USAGE:: 814 757 815 758 > auto_show … … 857 800 Display the current auto-level exposure settings. 858 801 859 U sage::802 USAGE:: 860 803 861 804 > auto_show_exposure … … 869 812 870 813 871 # ==============================================================================814 ############################################################################### 872 815 # Internal macros 873 #============================================================================== 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 874 892 875 893 #------------------------------------------------------------------------------ 876 894 def _auto_print_setup '{ 877 895 """ 878 Summary 879 ------- 880 Prints the configuration options and current values to screen 881 882 .. note:: 896 Print the configuration options and current values to screen 897 898 NOTE: 883 899 The option numbers must be kept in sync between 884 900 :spec:def:`_auto_set_option` and … … 919 935 def _auto_set_option '{ 920 936 """ 921 Sets a new value for a given option 922 923 Description: 924 937 Sets a new value for a given option. 938 939 DESCRIPTION: 925 940 Sets a new value for a given option from the options menu that was created 926 941 with the :spec:def:`_auto_print_setup` command. 927 942 928 .. note::929 930 931 943 NOTE: 944 The option numbers must be kept in sync between 945 :spec:def:`_auto_set_option` and 946 :spec:def:`_auto_print_setup`. 932 947 933 948 """ … … 1163 1178 Analyze the previous exposure 1164 1179 1165 Description: 1166 1180 DESCRIPTION: 1167 1181 This macro retrieves the necessary information to analyze the last exposure 1168 1182 and to initiate adjustments, if necessary. Usually, this step consists only … … 1172 1186 etc. 1173 1187 1174 U sage::1188 USAGE:: 1175 1189 1176 1190 > _auto_analyze_exposure … … 1188 1202 Calculate and apply necessary exposure time and filter adjustments. 1189 1203 1190 Description: 1191 1192 The function returns 1 if transmission or exposure time are changed, 0 1193 otherwise. 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() 1194 1211 1195 1212 """ … … 1407 1424 Make sure the user-entered exposure times are consistent 1408 1425 1409 U sage::1426 USAGE:: 1410 1427 1411 1428 > _auto_check_exposure … … 1429 1446 Make sure the user-entered count levels are consistent 1430 1447 1431 U sage::1448 USAGE:: 1432 1449 1433 1450 > _auto_check_levels … … 1459 1476 round it to the given count time precision. 1460 1477 1461 U sage::1478 USAGE:: 1462 1479 1463 1480 > adjusted_time = _auto_calc_exposure(requested_time) … … 1486 1503 Determines whether the auto-adjusting has been successful. 1487 1504 1488 D escription:1505 DESCRIPTION: 1489 1506 1490 1507 If the current exposure does not meet the required criteria, counting … … 1493 1510 The function returns 1 in case of success, 0 otherwise. 1494 1511 1495 U sage::1512 USAGE:: 1496 1513 1497 1514 > success = _auto_adjust_redo() 1498 1515 1499 .. note::1500 1501 1516 NOTE: 1517 This macro makes use of the :spec:def:`recount` macro, which has to be 1518 added to SPEC during the startup procedure. 1502 1519 1503 1520 """ … … 1546 1563 Clears the terminal screen 1547 1564 1548 Description: 1549 1565 DESCRIPTION: 1550 1566 Clears the screen without losing the screen history or messing up the 1551 1567 scrolling capabilities (this has been a problem for certain terminals) … … 1553 1569 returning the cursor to the top left corner. 1554 1570 1555 U sage::1571 USAGE:: 1556 1572 1557 1573 > _clear_screen … … 1576 1592 } 1577 1593 1578 # ==============================================================================1594 ############################################################################### 1579 1595 # End of $Id: $ 1580 # ==============================================================================1596 ###############################################################################
Note: See TracChangeset
for help on using the changeset viewer.