Simple Scans in Python Ferdi Franceschini 2008-09-17 12:52 <command>runscan </command>command You can run a scan with the runscan command.  With this command you can acquire data with the histogram memory server while scanning against a "drivable" device, eg motors, temperature controllers.  By default this saves time resolved, ie HISTOGRAM_XYT data at each scan point. Multi-dimensional scans, where you would like to scan say temperature and a motor, have to be done in a batch file, or by using a python for loop, which may contain a runhmscan. See Chapter5. Batch Manager from gumpy.commons import sics The data acquired at each scan point is saved before going to the next point. sics.runscan( "scanvar", start, stop, numpoints, "mode", preset, channel) Arguments must be in the order described Note that force datatype savetype are optional in tcl, have an hdb_path, but are not included in the runscan signature, but should be. Note that instruments may not have an hmscan hdb_path e.g. Quokka. scanvar a drivable device, ie a motor or temperature controller etc start the start position for the scan variable stop the stop position for the scan variable numpoints the number of scan points (the start and stop positions will be included in the scan) mode Allowed mode one of: time unlimited period count frame MONITOR_n (where n=1,2,3 ...) If you set the mode to MONITOR_1 then the histogram server will stop when MONITOR_1 reaches the preset number of counts which has been set with the following preset parameter preset the acquisition duration at each scan point, this is in second if the mode is time, or counts if the mode is count or MONITOR_n <command>runscan </command> <option>options</option> These parameters must be supplied as a name-value pair, e.g. datatype They can be given in any order. force val Force a scan Allowed val one of: (default) If you really want to, you can force a scan when the instrument isn't ready. This can be useful for getting a background reference. datatype val Select the histogram memory datatype to save in your data file. Allowed val one of: (default) savetype val Allowed val one of: (default) By default your data will be saved in a file with a three letter instrument prefix and a run number.  If you use savetype then the data will be written to a scratch file called scratch.nx.hdf <command>runscan </command>example runscan This will run a four point scan with the sphi motor starting at 0 and stopping at 2.  The data will be acquired over five seconds at each point, with the default datatype HISTOGRAM_XYT, and saved in a file with a three letter instrument prefix and run number. <command>runscan </command>example runscan MONITOR_2 3000 savetype datatype force This example sets all runscan parameters <command>bmonscan </command>command You can run a beam monitor scan with the bmonscan command.  With this command you can acquire data with a counter in the histogram memory server while scanning against a "drivable" device, eg motors. The main detector is not required. Generally this would be used to align an instrument, e.g. alignment of a monochromator or sample crystal. Additional information can be found in the chapters "Counters", "User Defined Scans" and "Batch Manager". bmonscan will create a data file of type BEAM_MONITOR. Multi-dimensional scans have to be done in a batch file, or by using a tcl for loop, which may contain a runscan. See the chapter "Batch Manager". Unlike runscan, bmonscan is a standard SICS scan object. This means you can configure, interrogate and control bmonscan using the commands in the chapter "User Defined Scans". This section has only a summary of the most used commands, which allows you to do a one variable scan. The data acquired at each scan point is saved before going to the next point. bmonscan run NP mode preset Executes a scan. NP is the number of scan points mode is the counter mode, either or preset is the preset value for the counter Scan data is written to an output file. tree interface /commands/scan/bmonscan/NP tree interface /commands/scan/bmonscan/mode tree interface /commands/scan/bmonscan/preset bmonscan clear Clears the list of scan variables. Must be called before each scan that has different parameters. bmonscan add variable start increment Adds the variable specified by the argument variable to the list of variables scanned in the next scan. The arguments start and increment define the starting point and the step width for the scan on this variable. tree interface /commands/scan/bmonscan/scan_variable tree interface /commands/scan/bmonscan/scan_start tree interface /commands/scan/bmonscan/scan_increment bmonscan getvarpar i Prints the name, start and step of the scan variable number i tree interface /commands/scan/bmonscan/scan_variable bmonscan setchannel n Sets the beam monitor to collect data from, where n is an integer ID for the beam monitor to use. setchannel uses zero-based counting, so 0 is bm1 etc. tree interface /commands/scan/bmonscan/channel bmonscan example bmonscan clear clears the list of scan variables bmonscan add stth 0 0.1 adds the motor stth to the scan, with a starting value of 0 degrees and an increment value 0.1 degrees bmonscan getvarpar 0 lets you check the variable you are scanning, its start and step value. In this case it returns bmonscan.stth = 0.000000 = 0.100000 bmonscan setchannel 0 selects the first beam monitor, aka bm1. You'll need to check physically where this beam monitor is on the instrument you're driving bmonscan run 10 monitor 10000 runs the scan with 10 scan points, in counter mode with a preset of 10000 counts.