Changeset 14455 for fact/tools/PyDimCtrl/ScriptsForPyDimCtrl.py
- Timestamp:
- 10/03/12 20:04:48 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/PyDimCtrl/ScriptsForPyDimCtrl.py
r14454 r14455 4 4 from factdimserver import * 5 5 import numpy as np 6 import types 6 7 7 8 last_drive_kwargs = {} … … 9 10 10 11 bias_calibration = {} 12 13 def wait_nice(self, state_num, timeout=None): 14 if not hasattr(self, 'stn'): 15 raise TypeError(self.name+' has no CMD called STATE') 16 if timeout == None: 17 timeout = float('inf') 18 else: 19 timeout = float(timeout) 20 start = time.time() 21 intermed = time.time()-1. 22 while not self.stn == state_num: 23 time.sleep(0.1) 24 if time.time() - intermed >= 1.: 25 print fad_control.events()[0], 'events @', ftm_control.trigger_rates()[3], 'Hz' 26 intermed = time.time() 27 28 if time.time() >= start+timeout: 29 return False 30 return True 31 32 fad_control.wait_nice = types.MethodType( wait_nice, fad_control) 33 11 34 12 35 def FadConnectCrate( crate ): … … 441 464 print 'data taking for Wobble 2 finished' 442 465 print '--------------------------------------' 443 444 def TakeCrab():445 """ Data taking and tracking script for Crab446 """447 print '======================================'448 print 'Data taking and tracking script for'449 print 'Crab'450 print '======================================'451 print 'starting up...'452 453 # changing tracking to Crab Wobble 1454 TrackCrabWobble1()455 456 # Wait for drivectrl to reply that its tracking the given source457 WaitForTracking()458 459 DataTaking1()460 461 # changing tracking to Crab Wobble 2462 TrackCrabWobble2()463 464 # Wait for drivectrl to reply that its tracking the given source465 WaitForTracking()466 467 # data taking to Crab Wobble 2468 DataTaking2()469 470 # Stop tracking471 StopTracking()472 473 print '======================================'474 print 'Data taking and tracking script for'475 print 'Crab FINISHED'476 print '======================================'477 478 466 479 467 def TrackCrabWobble1(): … … 888 876 return False 889 877 890 import types 891 892 def wait_nice(self, state_num, timeout=None): 893 if not hasattr(self, 'stn'): 894 raise TypeError(self.name+' has no CMD called STATE') 895 if timeout == None: 896 timeout = float('inf') 897 else: 898 timeout = float(timeout) 899 start = time.time() 900 intermed = time.time()-1. 901 while not self.stn == state_num: 902 time.sleep(0.1) 903 if time.time() - intermed >= 1.: 904 print fad_control.events()[0], 'events @', ftm_control.trigger_rates()[3], 'Hz' 905 intermed = time.time() 906 907 if time.time() >= start+timeout: 908 return False 909 return True 910 911 fad_control.wait_nice = types.MethodType( wait_nice, fad_control) 878 912 879 913 880 … … 952 919 953 920 return GUII.mean(), GUII.std(), GUII.max(), GUII.min() 921 922 def TakeCrab(): 923 """ Data taking and tracking script for Crab 924 """ 925 print '======================================' 926 print 'Data taking and tracking script for' 927 print 'Crab' 928 print '======================================' 929 print 'starting up...' 930 931 # changing tracking to Crab Wobble 1 932 TrackCrabWobble1() 933 934 # Wait for drivectrl to reply that its tracking the given source 935 WaitForTracking() 936 937 DataTaking1() 938 939 # changing tracking to Crab Wobble 2 940 TrackCrabWobble2() 941 942 # Wait for drivectrl to reply that its tracking the given source 943 WaitForTracking() 944 945 # data taking to Crab Wobble 2 946 DataTaking2() 947 948 # Stop tracking 949 StopTracking() 950 951 print '======================================' 952 print 'Data taking and tracking script for' 953 print 'Crab FINISHED' 954 print '======================================' 955 956 957 def TakeMrk501(): 958 print '====================================== 959 print 'Data taking and tracking script for 960 print 'Mrk 501 961 print '====================================== 962 print 'starting up... 963 964 965 # changing tracking to Mrk501 Wobble 1 966 TrackMrk501Wobble1() 967 968 # Wait for drivectrl to reply that its tracking the given source 969 WaitForTracking() 970 971 # starting data taking of Mrk501 972 DataTaking1() 973 974 # changing tracking to Mrk501 Wobble 2 975 TrackMrk501Wobble2() 976 977 # Wait for drivectrl to reply that its tracking the given source 978 WaitForTracking() 979 980 # data taking to Mrk501 Wobble 2 981 DataTaking2() 982 983 # Stop tracking 984 StopTracking() 985 986 987 988 def TrackSourceWobbleX( sourcename, wobble_pos ) 989 """ general Tracking function 990 """ 991 wp = int(wobble_pos) 992 if wp != 1 and wp != 2: 993 raise ValueError('wobble_pos *must* be 1 or 2') 994 995 if sourcename not in sourcedict: 996 print sourcedict.keys() 997 raise ValueError('sourcename: '+ sourcename +' must be in sourcedict.') 998 999 print 'moving telescope to wobble position ', wp, 'of ', sourcename 1000 print '...waiting for DRIVE_CONTROL' 1001 print ' to be in state 6: Armed' 1002 1003 drive_control.wait(6) #Armed 1004 print 'DRIVE: ARMED' 1005 time.sleep(5.) 1006 1007 wobble_offset = sourcedict[sourcename]['wobble_offset'] 1008 wobble_angle = sourcedict[sourcename]['wobble_angle'+str(wp)] 1009 sourcename += '\0' 1010 1011 last_drive_method = drive_control.track_source 1012 last_drive_kwargs = { 'wobble_offset' : wobble_offset, 1013 'wobble_angle' : wobble_angle, 1014 'source_name' : sourcename } 1015 last_drive_method(**last_drive_kwargs) 1016 1017 print '... done' 1018 1019 source_list = [ 1020 ['Crab', 0.6 , 50, -130], 1021 ["1ES 2344+51.4", 0.6 , 90, -90 ], 1022 ["Mrk 501", 0.6, -22, -22+180 ], 1023 ["Mrk 421", 0.6, 90, -90 ], 1024 ["1ES 1218+304", 0.6, -5, -5+180 ], 1025 ["1ES 1959+650", 0.6, 155, 155-180 ], 1026 ["Dark Patch 2", 0.6 , 90, -90 ], 1027 ["Dark Patch 3", 0.6 , 90, -90 ], 1028 ["H 1426+428", 0.6 , 90, -90 ], 1029 ["IC 310", 0.6, -18, -18+180 ], 1030 ["PKS 2155-304", 0.6, 90, -90 ] ] 1031 1032 sourcedict{} 1033 1034 def make_sourcedict(): 1035 for s in source_list: 1036 sourcedict[s[0]] = {} 1037 sourcedict[s[0]]['wobble_offset'] = s[1] 1038 sourcedict[s[0]]['wobble_angle1'] = s[2] 1039 sourcedict[s[0]]['wobble_angle2'] = s[3] 1040 1041 1042 def TrackCrabWobble1_new(): 1043 """ changing tracking to "Crab" Wobble 1 1044 """ 1045 TrackSourceWobbleX( 'Crab', 1) 1046 1047 def TrackCrabWobble2_new(): 1048 """ changing tracking to "Crab" Wobble 1 1049 """ 1050 TrackSourceWobbleX( 'Crab', 2) 1051 1052 1053 def TakeSource( name ): 1054 if name not in sourcedict: 1055 print name, 'not in dict of sources, possible sources are:' 1056 print sorted(sourcedict.keys()) 1057 raise ValueError('wrong source name') 1058 1059 TrackSourceWobbleX( name, 1) # Track Wobble pos 1 of source 1060 WaitForTracking() 1061 DataTaking1() 1062 1063 TrackSourceWobbleX( name, 2) # Track Wobble pos 2 of source 1064 WaitForTracking() 1065 DataTaking2() 1066 1067 StopTracking()
Note:
See TracChangeset
for help on using the changeset viewer.