5. Using the Scripts

The scripts that I have written are in pure python. They are used to do various things with the Control System and clients. Since they read the tcsutils.py files you don’t need to know the URL’s for the Routes_def-label and Event_Routes_def-label. All scripts should be located in /opt/het/hetdex/bin. These scripts utilize the python interface described in Chapter 3 Hetlib Python Interface.

5.1. User Scripts

5.1.1. chksys

This bash shell script searches the system process table and prints the lines associated with the control systems to the standard output. At this time it is a shell script with no command line flags. There is no general way to search for control systems so this script simply searchs by name. If you create a new control system, then you will have to modifiy this script.

5.1.2. getposition

Usage: getposition [options]

Get the position of the tracker and print all the coordinates, ITF, RTF, and TSF

Options:

-h, --help  show this help message and exit

Example:

$ getposition
{u'__ack': u'false',
u'__async': u'false',
u'__data': u'false',
u'__data_time': u'1502812057.453914950',
u'__done': u'true',
u'__effective_id': 262987,
u'__error': u'false',
u'__handler': u'tracker_position',
u'__origin': u'tcsutils.pyc0.530180389939_tcs107451.htcs.107451.0327b23c6->tcp://192.168.66.31:30300',
u'__original_id': 2,
u'__pid': 121862,
u'__wire_time': u'1502812057.453915299',
u'itf.phi': 0.047562,
u'itf.rho': -0.039519,
u'itf.theta': 0.235037,
u'itf.x': 1824.1775,
u'itf.y': -1837.147486,
u'itf.z': -2.73196,
u'rtf.phi': 0,
u'rtf.rho': -0.039519,
u'rtf.theta': 3e-06,
u'rtf.x': 1799.1873,
u'rtf.y': -1799.4097,
u'rtf.z': -3e-05,
u'time': u'1502812057.265000000',
u'trajectory': u'false',
u'tsf.h1': -0.0001,
u'tsf.h2': 0,
u'tsf.h3': 0,
u'tsf.h4': 0,
u'tsf.h5': 0.0001,
u'tsf.h6': -0.0001,
u'tsf.lx': 1799.1878,
u'tsf.rho': -0.0395,
u'tsf.ux': 1799.1868,
u'tsf.y': -1799.4097}

5.1.3. getSpectTemperatures

Usage: getSpectTemperatures [options]

Get the spectrograph hardware status.

Options:

-h, --help            show this help message and exit
-v, --version         show program's version number and exit
-o FILE, --output FILE
                      append output to FILE
-l, --lrs2, --ldas    get LRS2 temperatures
-V, --virus, --vdas   get Virus temperatures
-s sort_flag, --sort sort_flag
                      sort_flag must be one of ['IFU', 'SSA', 'SID', 'CID',
                      'MUX', 'IFU', 'HIGHCCD', 'LOWCCD', 'HIGHCRYO',
                      'LOWCRYO'] (default IFUSLOT)
-p print_options, --print print_options
                      print_options, must one or more of ['ALL', 'TEMPS',
                      'CCDTEMPS', 'CRYOTEMPS', 'CRYOPRESS', 'HEATER',
                      'TROUBLE'] (default TEMPS)
--no-update           do not ask for a hardware update, just use the last
                      value
--no-header           Don't print the header string
--print-commands      print the set_ccd_temp() commands

Example:

 $ getSpectTemperatures -Vl -s SID
 2017-08-15T19:07:13       Cryo    Left  Right    Left  Right   Left Right
    IFU SSA SID CID MUX    Temp   SetPt  SetPt    Temp   Temp  Volts Volts
 1  093 157 008 040 007  -180.0  -105.0 -105.0  -105.0 -105.0  0.848 0.644
 2  106 136 012 103 005  -173.6  -105.0 -105.0  -105.0 -105.0  0.941 0.749
 3  103 152 013 061 007  -179.9  -110.0 -105.0  -110.0 -105.0  0.822 0.754
 4  104 153 016 055 007  -178.7  -110.0 -110.0  -110.0 -110.0  0.801 0.782
 5  086 135 017 026 005  -174.3  -110.0 -110.0  -110.0 -110.0  0.677 1.138
 6  095 158 020 065 007  -177.2  -100.0 -105.0  -100.0 -105.0  0.613 0.653
 7  083 137 024 030 005  -179.2  -110.0 -110.0  -110.0 -110.0  0.983 0.901
 8  076 154 025 056 007  -175.7  -110.0 -110.0  -110.0 -110.0  0.785 0.814
 9  085 122 027 090 004  -170.9  -100.0 -105.0  -100.0 -105.0  0.956 0.569
10  094 155 032 098 007  -175.9   -90.0 -100.0   -77.3 -100.0  0.000 0.603
11  073 151 037 059 006  -179.8  -110.0 -105.0  -110.0 -105.0  0.606 0.791
12  096 134 038 062 005  -184.6  -100.0 -110.0  -100.0 -110.0  0.722 0.760
13  084 133 041 041 003  -179.1  -105.0 -105.0  -105.0 -105.0  0.984 1.154
14  075 132 047 052 005  -181.2  -100.0 -105.0  -100.0 -105.0  0.724 0.766
15  105 138 051 080 005  -172.1   -95.0 -100.0   -95.0 -100.0  0.842 0.522
16  044 238 202 038 002  -177.2  -105.0 -105.0  -105.0 -105.0  1.320 1.675
17  045 248 305 078 001  -173.2  -105.0 -105.0  -105.0 -105.0  1.251 1.174
18  074 131 307 105 005  -174.2  -100.0 -100.0  -100.0 -100.0  0.874 0.622
19  066 121 502 100 000  -200.6  -110.0 -110.0  -110.0 -110.0  1.050 1.190
20  056 111 503 069 000  -182.7  -110.0 -110.0  -110.0 -110.0  0.536 1.183

5.1.4. getUptime

Usage: getUptime [options]

Show the server uptime in decimal days, decimal hours, decimal minutes, decimal seconds, or days, hours, minutes, seconds as ddd:hh:mm:ss.

Options:

-h, --help            show this help message and exit
-v, --version         show program's version number and exit
--verbose             print useful(?) information (does nothing at this time)
--pretty-print {dd,dh,dm,ds,dhms} pretty print the output (default dhms)
-A, --all             uptime for all the systems,
-a, --apc             uptime for the apc system,
-L, --legacy          uptime for the legacy system,
-l, --lrs2            uptime for the lrs2 system,
-n, --named           uptime for the named server,
-p, --pas             uptime for the pas server,
-P, --pfip            uptime for the pfip server,
-t, --tracker         uptime for the tracker server,
-T, --tcs             uptime for the tcs server,
-V, --virus           uptime for the virus system

Example:

$ getUptime -V
virus uptime: 003:21:54:25 ddd:hh:mm:ss

$ getUptime -V -l
virus uptime: 003:21:54:25 ddd:hh:mm:ss
lrs2 uptime: 003:21:04:57 ddd:hh:mm:ss

$ getUptime -T --pretty-print dd
tcs uptime: 2.894 days

5.1.5. hettime

Usage: hettime [options] [time]

Convert between various notions of time at HET. ‘time’ may be either index time, an ISO-8601 string, or unixtime. The return values are the input time converted to all three formats. If no time is given on the command line, use the current time.

Options:

--version   show program's version number and exit
-h, --help  show this help message and exit

Example:

# Index time
$ hettime 77145
77145.0 55545.0 1970-01-01T15:25:45

# ISO time string
$ hettime 2017-08-15T15:25:45
77145.0 1502810745.0 2017-08-15T15:25:45

# Unix time
$ hettime 1502810745.0
77145.0 1502810745.0 2017-08-15T15:25:45

5.1.6. monitor

Usage: monitor [options]

Monitor one or several processes within Tcs.

Options:

--version             show program's version number and exit
-h, --help            show this help message and exit
-t, --tracker         catch the tracker server output.
-T, --tcs             catch the tcs server output.
-p, --pas             catch the pas server output.
-P, --pfip            catcj the pfip server output.
-l, --logger          catch the log server output
-L, --legacy          catch the legacy system output.
-g, --gui             catch the gui system output.
-v, --verbose         Send output to stdout as well as the output file.
-o FILE, --output=FILE
                      Send output to FILE (default
                      ./data/Mon/yyyymmddThhmmss_mon.log)
--system-filter=SYSTEM_FILTER
                      Specify filters on the system..
--source-filter=SOURCE_FILTER
                      Specify filters on the source
--key-filter=KEY_FILTER
                      Specify filters on the key.

Description:

The monitor program has the almost the same flags as startsys. I usually start it separately from the other systems. You can specify the filters us usual but you should probably quote the string values. This is a python programs so the command line parser is slightly different from the C++ version in the control systems.

Example:

A typical usage would be monitor -t -T -L -p -o 20141119a_mon.txt which will listen to the tracker_server, tcs_server, legacyServer, and pasServer event routes and place the output in 20141119a_mon.txt. Not all the available flags in the tcs_monitor are available in the python version. So if you want to specify alternate routes or configure files you will need to use tcs_monitor directly.

5.1.7. moveITF

Usage: moveITF [options] left|right|home|zero|x y z rho theta phi

Move to the requested ITF position. The position may be one of the pre-defined positions or six ITF coordinates. The default velocity is track. If both track and slew speeds are set on the command line, then the script will exit since it does not know what you want. Verbose mode will print useful information about what is happening. Quiet mode will print nothing at all, not even errors. The default is to not print the useful information but to print error messages.

left == (-1800, -1800, 0, 0, 0, 0)

right = (+1800, -1800, 0, 0, 0, 0)

home = (0, -1800, 0, 0, 0, 0)

zero = (0, 0, 0, 0, 0, 0)

Options:

-h, --help     show this help message and exit
-t, --track    move at tracker speed
-s, --slew     move at slew speed (default)
-S, --slow     move at slow speed (default Fast)
-v, --verbose  display more useful (or not) information about progress
-q, --quiet    do not print any information

5.1.8. moveRTF

Usage: moveRTF [options] left|right|home|zero|x y z rho theta phi

Move to the requested RTF position. The position may be one of the pre-defined positions or six RTF coordinates. The default velocity is track. If both track and slew speeds are set on the command line, then the script will exit since it does not know what you want. Verbose mode will print useful information about what is happening. Quiet mode will print nothing at all, not even errors. The default is to not print the useful information but to print error messages.

left == (-1800, -1800, 0, 0, 0, 0)

right = (+1800, -1800, 0, 0, 0, 0)

home = (0, -1800, 0, 0, 0, 0)

zero = (0, 0, 0, 0, 0, 0)

Options:

-h, --help     show this help message and exit
-t, --track    move at tracker speed
-s, --slew     move at slew speed (default)
-S, --slow     move at slow speed (default Fast)
-v, --verbose  display more useful (or not) information about progress
-q, --quiet    do not print any information

5.1.9. moveTSF

Usage: moveTSF [options] left|right|home|zero|ux lx y rho h1 h2 h3 h4 h5 h6

Move to the requested TSF position. The position may be one of the pre-defined positions or ten TSF coordinates. The default velocity is track. If both track and slew speeds are set on the command line, then the script will exit since it does not know what you want. Verbose mode will print useful information about what is happening. Quiet mode will print nothing at all, not even errors. The default is to not print the useful information but to print error messages.

left == (-1800, -1800, -1800, 0, 0, 0, 0, 0, 0, 0)

right = (+1800, +1800, -1800, 0, 0, 0, 0, 0, 0, 0)

home = (0, 0, -1800, 0, 0, 0, 0, 0, 0, 0)

zero = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

Options:

-h, --help     show this help message and exit
-t, --track    move at tracker speed
-s, --slew     move at slew speed (default)
-S, --slow     move at slow speed (default Fast)
-v, --verbose  display more useful (or not) information about progress
-q, --quiet    do not print any information

5.1.10. startsys

This has been replaced by init scripts run by the service command. The command is deprecated.

The startsys command will start the various control systems depending on the command line flags. These controls systems are started with the standard command line flags defined in tcsconfig.py and the default configuration file in /opt/het/hetdex/etc/conf. If the -v flag is also given then the standard output of the control systems is sent to the screen; otherwise the output is sent to /dev/null. The script finishes by sleeping within a while loop. This allows the user to interupt the script and thereby kill all the control system there were started. (This works mostly.)

Usage: startsys [options]

Set up and start processes involved in the Tcs system.

Options:

--version             show program's version number and exit
-h, --help            show this help message and exit
-x, --no-tmcs         no TMCS hardware available, use simulator if starting
                      tracker.
-t, --tracker         start the tracker server.
-T, --tcs             start the tcs server.
-p, --pas             start the pas server.
-P, --pfip            start the pfip server.
-l, --logger          turn on logging and start the log server
-L, --legacy          start the legacy system.
-m, --monitor         start the monitor system.
-g, --gui             start the gui system.
--plot                start the plotters
-v, --verbose         Send output to stdout.
--tap                 Turn on message tapping for all systems
--disable-mount-model
                      Turn off TCS mount model.
--valgrind=FILE       Enable valgrind for a particular system.  The log file
                      is written to <system>-valgrind.log in the current
                      directory.

5.1.11. syscmd

Usage: syscmd option command

Send a synchronous command to a particular control system

If no command is specified, then the help() command is executed. This results in a list of available handlers for the control system. To find out specific information about a particular command, use the extended form of the help command. For example, to find out the detail of the Tcs go_next() command use

syscmd -T “help(command=’go_next’)”

The return value of syscmd is the return value of the command.

Options:

--version      show program's version number and exit
-h, --help     show this help message and exit
-t, --tracker  send a command to the tracker server (default help())
-T, --tcs      send a command to the tcs server (default help()).
-p, --pas      send a command to the pas server (default help())
-P, --pfip     send a command to the pfip server (default help()).
-L, --legacy   send a command to the legacy system (default help()).
-g, --gui      send a command to the gui system (default help()).
-v, --verbose  Send output to stdout.

Examples:

$ syscmd -l 'get_heater_voltage()'
{u'__ack': u'false',
u'__async': u'false',
u'__data': u'false',
u'__data_time': u'1502813354.967412900',
u'__done': u'true',
u'__effective_id': 6574,
u'__error': u'false',
u'__handler': u'get_heater_voltage',
u'__origin': u'tcsutils.pyc0.0929679765573_lrs2108337.htcs.108337.0327b23c6->tcp://192.168.66.15:31300',
u'__original_id': 2,
u'__pid': 29135,
u'__wire_time': u'1502813354.967414133',
u'lrs2.mux.000.spec.502.cntl.100.ccd.left.15609.voltage': 1.046802,
u'lrs2.mux.000.spec.502.cntl.100.ccd.right.15612.voltage': 1.185606,
u'lrs2.mux.000.spec.503.cntl.069.ccd.left.21162.voltage': 0.53953,
u'lrs2.mux.000.spec.503.cntl.069.ccd.right.21090.voltage': 1.18294}

5.1.12. tap

Usage: tap [options]

Send the tap command to control systems.

Options:

--version      show program's version number and exit
-h, --help     show this help message and exit
-t, --tracker  tap the tracker server.
-T, --tcs      tap the tcs server.
-p, --pas      tap the pas server.
-P, --pfip     tap the pfip server.
-L, --legacy   tap the legacy system.
-g, --gui      tap the gui system.
-v, --verbose  Send output to stdout.

5.1.13. trajectory

Usage: trajectory [options] [- - ra_hr dec_deg]

Set up and start a trajectory

Options:

--version             show program's version number and exit
-h, --help            show this help message and exit

Object trajectories:
  -s SATELLITE_NAME, --satellite=SATELLITE_NAME
                      generate a trajectory from a satellite..
  -S FILE, --sat-data=FILE
                      use FILE instead of /opt/het/hetdex/etc/point/geo.txt
                      for satellite information.
  -f FILE, --file=FILE
                      generate a trajectory from FILE.
  -e FILE, --ephemeris=FILE
                      generate a trajectory from the ephemeris file FILE.

Engineering trajectories:
  -c, --current       generate a trajectory for lst at the current azimuth
  -F, --Full          generate a full trajectory (must specify azimuth)
  -l, --lst           a trajectory at az=180.0 and Ra=LST (starts from
                      center of tracker)
  --lst-east          a trajectory at az=65.0 and Ra=LST (starts from center
                      of tracker)
  --lst-west          a trajectory at az=295.0 and Ra=LST (starts from
                      center of tracker)

Global options:
  -a AZIMUTH, --azimuth=AZIMUTH
                      [cur|current|best|nnn.nnn] generate a trajectory with
                      selected azimuth (default best).
  -E EQUINOX, --equinox=EQUINOX
                      use EQUINOX instead of 2000.0.
  -w, --west          generate a trajectory in the west (default east).
  --use-struct        move the structure if necessary. legacyServer must be
                      running.
  --use-dome          move the dome if necessary. legacyServer must be
                      running.
  -v, --verbose       be noisy about our actions.

Description:

trajectory will generate and run a trajectory with in the Tcs. If requested, it will move the structure as well. This is a single step process. It is not like to old Tcs where we would load a trajectory first, then tell the system when to go later. Both the load and gonext steps are performed with this command. If a trajectory is currently running, this command will return an error message.

Example:

There are a couple of ways that I use trajectory. The first way is just the usual track, where the structure moves to the calculated azimuth

trajectory -v --use-struct -- <ra> <dec> #where <ra> <dec> are in decimal degrees.

The other way is to use the current structure azimuth

trajectory -v -a current -- <ra> <dec>

or you can ignore the structure all together and specify an azimuth yourself

trajectory -v -a <az> -- <ra> <dec> # if you do not specify the –use-struct flag, the structure will not move.

If you get an error message that the azimuth and direction don’t agree, then try using the –west flag. This message should only occur on tracks in the north or the south.

5.1.14. vnctrk

This is a simple shell script that excutes vncviewer with the proper geometry and connects to the tracker engineering computer. This allows the operator to remotely view the Control Desk interface.

5.1.15. rdesktrk

This is a simple shell script that excutes rdesktop with the proper geometry and connects to the tracker engineering computer. This allows the operator to remotely view the Control Desk interface.

5.2. Test Scripts

5.2.1. mountTest

Usage: mountTest [options]

Run part or all of a 97 point test

Options:

-h, --help            show this help message and exit
-l LIST, --list=LIST  run the "97", "21", "Q1" through "Q4" point list, or
                      some other defined list (default "97")
-o OUTPUT_FILE, --output-file=OUTPUT_FILE
                      use the file OUTPUT_FILE for the results (default is
                      "./data/mountTest_out.csv).

5.2.2. dmipoints

Usage: dmipoints [options]

Run part or all of a 97 point test collecting DMI and TTC data. See Points.py for more information about the available points.

Options:

--version             show program's version number and exit
-h, --help            show this help message and exit
-l LIST, --list=LIST  run the "97", "21", "Q1" through "Q4" point list, or
                      some other defined list (default "97")
-v, --verbose         monitor all systems on stderr
-g, --gui             start gui so operator can monitor

5.2.3. dmittc

Usage: dmittc.py [options] azimuth

This script runs a full trajectory at the given azimuth and collects DMI and TTC data. These data are collected in the log /opt/het/hetdex/logs/data/Mon/dmittcs/dmittc_YYYYMMDDThhmmss_az.mon

Options:

-h, --help       show this help message and exit
-v, --verbose    monitor all systems on stderr
-V, --version    print version infomation
-g, --gui        start gui so operator can monitor
-t, --test       use the test values in the monitor output
-n, --no-struct  do not use the structure (default - use structure)
--closeTT        close the Tip/Tilt control loop
--closeDMI       close the DMI control loop

5.3. Admin Scripts

5.3.1. get_geo

A shell script that retrieves the geo-sychronous satellite orbital elements from http://celestrak.com/NORAD/elements/geo.txt. The script is run daily at 23:00 hours on the machine htcs from the hetdex user’s crontab file. The file resides in /opt/het/hetdex/etc/point/data/geo.txt.

5.3.2. get_ser7

A shell script that retrieves the Earth Orientation Bulletin from the U.S. Naval Observatory at ftp://maia.usno.navy.mil/ser7/ser7.dat. The script is run weekly on Thursdays at 23:00 hours on the machine htcs from the hexdex user’s crontab file. The file resides in /opt/het/hetdex/etc/ser7.dat.

5.3.3. tcs_query

Query a database for a specific event type

$ ./tcs_query –help

This is a utility for generating a csv-formatted text file by querying a TCS database containing events identified by: <system>.<source>.<key>

The key to extract is specified by:
–key=<system>.<source>.<key>
For example, to extract the key identified by system=pfip, source=’acq_shutter’, key=’status’, use
–key=’pfip.acq_shutter.status’

The entries listed in the output file will be the attributes for the specified key(s), ordered by time. If no key parameter is provided, the output from the utility will be a list of the unique keys contained in the database file.

The file output will be sent to stdout, unless the –outfile parameter is provided with a file name. When a specific key is requested using the –key option, the output file generated will contain values for all the attributes of that event key, ordered by time.

The name of the output file is specifed using the option:
–outfile=<filename>

The output file name is defaulted to stdout The name of the database file to search is specified with the option:

–dbfile=<filename>

The meta-data attributes are, by default, included in the output. If you wish to reduce data redundancy and query time, specify a list of meta attributes to include, e.g.:

–meta=’__data_time_string,__pid’
By default, the data delimiter in the output file is <tab>. If you wish to specify a different delimiter, use:
–delim=’,’

Names of the attributes will be listed at the beginning of the output file, if the –attribs option is used.