How do we run scripts?¶
Often there's some repetive set of exposures that we want to take, where it's hard to automate through the TUI GUI. At this point, it might help to generate and run a script. One obvious use for scripts is for taking calibrations; once you're done observing on sky, you might use a script to run through a bunch of default calibrations using the internal calibration lamps.
from kosmoscraftroom.scripts import *
Create a ScriptWriter
object to help make simple calibration scripts.
- The
slits
anddispersers
dictionaries define which slits/dispersers you want to calibrate, as well as the TUI drop-down menu positions for each. The dispersers are unlikely to change quickly, but the slits will probably change between different observing runs, so be sure to check the slit positions are correct! - The
binning
keyword indicates what (x,y)-pixel binning is happening, necessary to adjust exposure times relative to their unbinned suggestions. - The
prefix
keyword defines a prefix that will be added in front of each filename. If it includes a slash/
, then files will appear in a new subdirectory.
s = ScriptWriter(
slits={"20-ctr": 3, "1.18-ctr": 5},
dispersers={"red": 6, "blue": 3},
binning=[2, 2],
prefix="kosmos-calibrations/",
)
Assuming dispersers to calibrate are... position #6 = red position #3 = blue Assuming slits to calibrate are... position #3 = 20-ctr position #5 = 1.18-ctr Assuming binning is... 2x2 Before running this script, check in the KOSMOS window: ' disperser can be anything slit can be anything filter1 must be empty filter2 must be empty calibration stage can be anything binning can be anything neon/krypton/argon/quartz can be anything
Now, let's take some calibration data:
bias
showing the baseline readout level for the detector, including offsets between the readout amplifiers and structure near the detector edges. A sequence of biases can also be used to measure/confirm the readout noise.dark
showing the counts accumulated during a finite exposure, even without being illuminated by light. The average dark current on KOSMOS is low enough that darks are typically not necessary for any bright star observations.neon
,argon
,krypton
are internal arc lamps used for wavelength calibration, to determine which pixels are illuminated by which wavelengthsquartz
are flat field observations to measure the pixel-to-pixel sensitivity variations of the detector, to determine variations in the slit size at different spatial positions, and to reveal the effects of detector fringing at red wavelengths
Because the lamp exposures that actually shine line on the detector will depend on the slit and the disperser, the .take_lamps
function will loop over all options for each included in the above ScriptWriter
object definition.
s.take_bias(n=10)
s.take_dark(t=120, n=5)
for lamp in ["neon", "argon", "krypton"]:
s.take_lamps(lamp, n=3)
s.take_lamps("quartz", n=10)
s.take_bias(n=5)
We can print
the script to look at it...
s.print()
#set binning to 2x2 kosmos set rowBin=2 colBin=2 #taking 10 bias calibrations kosmos set calstage=in neon=off krypton=off argon=off quartz=off kosmosExpose bias n=10 name="kosmos-calibrations/2x2/cals/bias" seq=nextByDir comment="" #taking 5 dark calibrations kosmos set calstage=in neon=off krypton=off argon=off quartz=off kosmosExpose dark n=5 time=120.00 name="kosmos-calibrations/2x2/cals/dark" seq=nextByDir comment="" #taking 3 neon calibrations kosmos set calstage=in neon=on krypton=off argon=off quartz=off # lamp neon, slit=20-ctr (1/2), disperser=red (1/2), 3 iterations kosmos set slit=3 disperser=6 kosmosExpose flat time=0.03 n=3 name="kosmos-calibrations/2x2/cals/red-20-ctr-neon" seq=nextByDir comment="" # lamp neon, slit=20-ctr (1/2), disperser=blue (2/2), 3 iterations kosmos set slit=3 disperser=3 kosmosExpose flat time=0.05 n=3 name="kosmos-calibrations/2x2/cals/blue-20-ctr-neon" seq=nextByDir comment="" # lamp neon, slit=1.18-ctr (2/2), disperser=red (1/2), 3 iterations kosmos set slit=5 disperser=6 kosmosExpose flat time=0.42 n=3 name="kosmos-calibrations/2x2/cals/red-1.18-ctr-neon" seq=nextByDir comment="" # lamp neon, slit=1.18-ctr (2/2), disperser=blue (2/2), 3 iterations kosmos set slit=5 disperser=3 kosmosExpose flat time=0.85 n=3 name="kosmos-calibrations/2x2/cals/blue-1.18-ctr-neon" seq=nextByDir comment="" #turning off lamps kosmos set calstage=in neon=off krypton=off argon=off quartz=off #taking 3 argon calibrations kosmos set calstage=in neon=off krypton=off argon=on quartz=off # lamp argon, slit=20-ctr (1/2), disperser=red (1/2), 3 iterations kosmos set slit=3 disperser=6 kosmosExpose flat time=0.05 n=3 name="kosmos-calibrations/2x2/cals/red-20-ctr-argon" seq=nextByDir comment="" # lamp argon, slit=20-ctr (1/2), disperser=blue (2/2), 3 iterations kosmos set slit=3 disperser=3 kosmosExpose flat time=1.12 n=3 name="kosmos-calibrations/2x2/cals/blue-20-ctr-argon" seq=nextByDir comment="" # lamp argon, slit=1.18-ctr (2/2), disperser=red (1/2), 3 iterations kosmos set slit=5 disperser=6 kosmosExpose flat time=0.85 n=3 name="kosmos-calibrations/2x2/cals/red-1.18-ctr-argon" seq=nextByDir comment="" # lamp argon, slit=1.18-ctr (2/2), disperser=blue (2/2), 3 iterations kosmos set slit=5 disperser=3 kosmosExpose flat time=19.07 n=3 name="kosmos-calibrations/2x2/cals/blue-1.18-ctr-argon" seq=nextByDir comment="" #turning off lamps kosmos set calstage=in neon=off krypton=off argon=off quartz=off #taking 3 krypton calibrations kosmos set calstage=in neon=off krypton=on argon=off quartz=off # lamp krypton, slit=20-ctr (1/2), disperser=red (1/2), 3 iterations kosmos set slit=3 disperser=6 kosmosExpose flat time=0.03 n=3 name="kosmos-calibrations/2x2/cals/red-20-ctr-krypton" seq=nextByDir comment="" # lamp krypton, slit=20-ctr (1/2), disperser=blue (2/2), 3 iterations kosmos set slit=3 disperser=3 kosmosExpose flat time=0.75 n=3 name="kosmos-calibrations/2x2/cals/blue-20-ctr-krypton" seq=nextByDir comment="" # lamp krypton, slit=1.18-ctr (2/2), disperser=red (1/2), 3 iterations kosmos set slit=5 disperser=6 kosmosExpose flat time=0.42 n=3 name="kosmos-calibrations/2x2/cals/red-1.18-ctr-krypton" seq=nextByDir comment="" # lamp krypton, slit=1.18-ctr (2/2), disperser=blue (2/2), 3 iterations kosmos set slit=5 disperser=3 kosmosExpose flat time=12.71 n=3 name="kosmos-calibrations/2x2/cals/blue-1.18-ctr-krypton" seq=nextByDir comment="" #turning off lamps kosmos set calstage=in neon=off krypton=off argon=off quartz=off #taking 10 quartz calibrations kosmos set calstage=in neon=off krypton=off argon=off quartz=on # lamp quartz, slit=20-ctr (1/2), disperser=red (1/2), 10 iterations kosmos set slit=3 disperser=6 kosmosExpose flat time=0.38 n=10 name="kosmos-calibrations/2x2/cals/red-20-ctr-quartz" seq=nextByDir comment="" # lamp quartz, slit=20-ctr (1/2), disperser=blue (2/2), 10 iterations kosmos set slit=3 disperser=3 kosmosExpose flat time=2.00 n=10 name="kosmos-calibrations/2x2/cals/blue-20-ctr-quartz" seq=nextByDir comment="" # lamp quartz, slit=1.18-ctr (2/2), disperser=red (1/2), 10 iterations kosmos set slit=5 disperser=6 kosmosExpose flat time=6.36 n=10 name="kosmos-calibrations/2x2/cals/red-1.18-ctr-quartz" seq=nextByDir comment="" # lamp quartz, slit=1.18-ctr (2/2), disperser=blue (2/2), 10 iterations kosmos set slit=5 disperser=3 kosmosExpose flat time=33.90 n=10 name="kosmos-calibrations/2x2/cals/blue-1.18-ctr-quartz" seq=nextByDir comment="" #turning off lamps kosmos set calstage=in neon=off krypton=off argon=off quartz=off #taking 5 bias calibrations kosmos set calstage=in neon=off krypton=off argon=off quartz=off kosmosExpose bias n=5 name="kosmos-calibrations/2x2/cals/bias" seq=nextByDir comment=""
...or we can copy the script to the clipboard, making it easy to paste into the TUI Scripts > Run_Commands
window.
s.copy()
Your TUI script has been copied to the clipboard. Please paste into the TUI `Run_Commands` window.
After pasting the script into Run_Commands
, click Start
to run through the commands one by one. The command currently being run will be underlined. TUI must remain open for the script to complete; if TUI closes, the current exposure series will likely finish, but the script will stop before going on to the next command.