Reports until 12:21, Thursday 30 October 2014
H1 SYS
jameson.rollins@LIGO.ORG - posted 12:21, Thursday 30 October 2014 - last comment - 13:27, Sunday 02 November 2014(14739)
new cdsutils.avg() interface and bug fixes

The current cdsutils installation (r361) has a new and improved NDS avg() function.  The previous version was buggy, was calculating the standard deviation incorrectly,  and had a clunky interface.  This new version fixes those issues:

fixes to standard deviation calculation

The standard deviation was previously being calculated incorrectly and the returned values were wrong (off by some unknown but kind of large factor).  The new version uses the python numpy.var() function to calculate the variance, from which the standard deviation is calculated.  It has been verified to be correct.

channel IFO prefixes no longer need to be specified

Previously, the avg() function required full channel names, with IFO prefixes.  This new version works like the ezca interface whereby the IFO prefix can be left off of the channel name.  This makes things much cleaner, and allows scripts to be portable.  E.g., instead of:

cdsutils.avg(2, IFO+':LSC-DARM_OUT')

just do:

cdsutils.avg(2, 'LSC-DARM_OUT')

new format for returned values

Probably the thing that's going to cause the most trouble is that the interface to the function has been fixed up.  Previously, the function was returning a dictionary of channel:avg key pairs.  This was very clunky to use.

The return value of the function now mirrors the input argument.  So for instance, if a single channel is requested, a single avg value is returned.  If a list of channels is requested, a list of average values is returned, in the same order as the input channel list.  So calls like:

avg = cdsutils.avg(2, 'LSC-DARM_OUT').values()[0]

can now just be:

avg = cdsutils.avg(2, 'LSC-DARM_OUT')

If the stddev option is provided, the output will be an (avg, stddev) tuple, or if multiple channels is requested, a list of such tuples, e.g.:

avg, stddev = cdsutils.avg(2, 'LSC-DARM_OUT', True)

I have fixed all calls to cdsutil.avg() that I could find in the USERAPPS/release.  I likely didn't catch everything, though, so be aware of the new interface and update your code appropriately.

Comments related to this report
rana.adhikari@LIGO.ORG - 23:07, Friday 31 October 2014 (14791)

controls@opsws5:sbin 0$ cdsutils -h

Usage:
  -c [OPTION...] - GStreamer initialization
 
Help Options:
  -h, --help                        Show help options
  --help-all                        Show all help options
  --help-gst                        Show GStreamer Options
 
controls@opsws5:sbin 0$ cdsutils avg -h
Usage:
  -c [OPTION...] - GStreamer initialization
 
Help Options:
  -h, --help                        Show help options
  --help-all                        Show all help options
  --help-gst                        Show GStreamer Options

rana.adhikari@opsws5|~> cdsutils avg -n 2 H1:LSC-MICH_IN1
ignoring first online block...
received: 1098858364 + 1.0
received: 1098858365 + 1.0
-195.380218506
 
Also would be helpful if these extraneous junk messages can be removed from the output. The idea of the "-n" flag is that only the number is returned so that we can use it in command line scripting.
jameson.rollins@LIGO.ORG - 13:27, Sunday 02 November 2014 (14797)

I pushed a new version of cdsutils (r366) that fixes the issue with the help.  Commands were being intercepted by one of the gstreamer libraries:

jameson.rollins@operator1:~ 0$ cdsutils -h
usage: cdsutils  

Advanced LIGO Control Room Utilites

Available commands:

  read         read EPICS channel value
  write        write EPICS channel value
  switch       read/switch buttons in filter module
  sfm          decode/encode filter module switch values
  step         step EPICS channels over specified range
  servo        servo EPICS channel with simple integrator (pole at zero)
  trigservo    servo EPICS channel with trigger
  avg          average one or more NDS channels
  audio        play NDS channel as audio stream
  dv           plot time series of NDS channels
  water        NOT SUPPORTED: No module named PyQt4

  version      print version info and exit
  help         this help

Add '-h' after individual commands for command help.
jameson.rollins@operator1:~ 0$ 

The "junk" messages, as you refer to them, in the avg output are actually just logging that are going to stderr, and therefore do not affect the stdout output:

jameson.rollins@operator1:~ 0$ foo=$(cdsutils avg -n 2 H1:LSC-MICH_IN1)
ignoring first online block...
received: 1098998811 + 1.0
received: 1098998812 + 1.0
jameson.rollins@operator1:~ 0$ echo $foo
75.2394218445
jameson.rollins@operator1:~ 0$