stella.sql
Class OffLimitAlarm

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by mysql.AbstractSql
                  extended by stella.sql.NightlyStatistic
                      extended by stella.sql.OffLimitAlarm
All Implemented Interfaces:
Cloneable, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying
Direct Known Subclasses:
OffLimitVisual

public class OffLimitAlarm
extends NightlyStatistic

A class that uses nighly statistics to check for abnoramlities in certain parameters. If gross off-limits are encountered, an e-mail notification is sent to the administrator.


Nested Class Summary
 
Nested classes/interfaces inherited from class stella.sql.NightlyStatistic
NightlyStatistic.Duty, NightlyStatistic.Env, NightlyStatistic.Night
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private  Map<String,Statistic> env
          The retrieved data as column names to statistics.
private  Map<String,Statistic> envtimes
          The retrieved data as column names to statistics.
static String KEY_DONELIST
          The fields to query from the env table.
static String KEY_DONENAMES
          How the returned columns are named.
static String KEY_DONEWHERE
          Additional constraints for the done table query.
static String KEY_ENVLIST
          The fields to query from the env table.
static String KEY_ENVNAMES
          How the returned columns are named.
static String KEY_JOINTLIST
          The fields to query from the env table.
static String KEY_JOINTNAMES
          How the returned columns are named.
static String KEY_JOINTWHERE
          Additional constraints for the joint table query.
static String KEY_OBSLIST
          The fields to query from the obs table.
static String KEY_OBSNAMES
          How the returned columns are named.
static String KEY_OBSWHERE
          Additional constraints for the obs table query.
static String KEY_SCILIST
          The fields to query from the obs table, with imagetyp=1.
static String KEY_SCINAMES
          How the returned columns are named.
static String KEY_SCIWHERE
          Additional constraints for the sci query, should include imagetyp=1.
static String KEY_TELESCOPE
          The issuing telescopes.
static String NULL
          String instead of limits indicating that this has no meaning.
private  Map<String,Map<String,Statistic>> tel
          The retrieved data as column names to statistics.
static char TELESCOPESEPARATOR
          character sparating telescope name from offending column name.
private  Map<String,Map<String,List<Object>>> telkeys
          The retrieved data as column names to keys (unique ids).
private  Map<String,Map<String,Statistic>> teltimes
          The retrieved data as column names to statistics.
 
Fields inherited from class stella.sql.NightlyStatistic
DEFPASSWORD, DEFUSERNAME, KEY_RISETWILIGHT, KEY_SETTWILIGHT
 
Fields inherited from class mysql.AbstractSql
KEY_TABLE
 
Fields inherited from class util.PropertyBundles
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_RESOURCEBUNDLES
 
Fields inherited from class util.PropertyResources
KEY_NOINITONCREATE, localurl, locate, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_URL, urlset
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Constructor Summary
OffLimitAlarm(Map<String,String> prop)
          Constructs a new off-limit alarm log.
 
Method Summary
 void addDone(List<String> donelist, List<String> doneas, Map<String,Function> f, String add, Date now)
          Retrieve and cache all information for the date in question.
 void addEnvironment(List<String> envlist, List<String> envas, Map<String,Function> f, Date now)
          Retrieve and cache all information for the date in question.
 void addJoint(List<String> jointlist, List<String> jointas, Map<String,Function> f, String add, Date now)
          Retrieve and cache all information for the date in question.
 void addObs(List<String> obslist, List<String> obsas, Map<String,Function> f, String add, Date now)
          Retrieve and cache all information for the date in question.
 void clearStats()
           
static Map<String,Statistic> convertToStatistic(Map<String,List<DataCard>> log, int index)
          Converts a mapping of strings to List of doubles into a mapping of strings to statistics.
static Map<String,List<Object>> extractUnique(Map<String,List<DataCard>> log)
          We take all the data cards and extract the unique IDs found for the given field names.
 Map<String,Double> getAverageEnvOffs(Map<String,Vector2D> avmap)
          From the retireved mappings of column names to list of doubles, we return the column names of those whose average are outside the bounds mapped to the average.
private  Map<String,Double> getAverageOffenders(Map<String,Statistic> stats, Map<String,Vector2D> avmap)
          From the retireved mappings of column names to list of doubles, we return the column names of those whose average are outside the bounds mapped to the average.
 Map<String,Double> getAverageTelOffs(String telescope, Map<String,Vector2D> avmap)
          From the retireved mappings of column names to list of doubles, we return the column names of those whose average are outside the bounds mapped to the average.
 Statistic getEnvStatistic(String key)
          Returns the statistic on a column in the env table.
 Statistic getEnvTimes(String key)
          Returns the statistic on a column in the env table.
 Map<String,Double> getMinMaxEnvOffs(Map<String,Vector2D> avmap)
          From the retireved mappings of column names to list of doubles, we return the column names of those whose average are outside the bounds mapped to the average.
private  Map<String,Double> getMinMaxOffenders(Map<String,Statistic> stats, Map<String,Vector2D> avmap)
          From the retireved mappings of column names to list of doubles, we return the column names of those whose min/max are outside the bounds mapped to the offending value.
 Map<String,Double> getMinMaxTelOffs(String telescope, Map<String,Vector2D> avmap)
          From the retireved mappings of column names to list of doubles, we return the column names of those whose min/max are outside the bounds mapped to the offending value.
 Map<String,Double> getSigmaEnvOffs(Map<String,Double> limit)
          From the retireved mappings of column names to list of doubles, we return the column names of those whose average are outside the bounds mapped to the average.
private  Map<String,Double> getSigmaOffenders(Map<String,Statistic> stats, Map<String,Double> limit)
          From the retireved mappings of column names to list of doubles, we return the column names of those whose standard deviaition is higher than the allowed maximum, mapped to the offending value.
 Map<String,Double> getSigmaTelOffs(String telescope, Map<String,Double> limit)
          From the retireved mappings of column names to list of doubles, we return the column names of those whose standard deviaition is higher than the allowed maximum, mapped to the offending value.
 Map<String,Double> getSpanEnvOffs(Map<String,Double> limit)
          From the retireved mappings of column names to list of doubles, we return the column names of those whose average are outside the bounds mapped to the average.
private  Map<String,Double> getSpanOffenders(Map<String,Statistic> stats, Map<String,Double> limit)
          From the retireved mappings of column names to list of doubles, we return the column names of those whose span deviaition is higher than the allowed maximum, mapped to the offending value.
 Map<String,Double> getSpanTelOffs(String telescope, Map<String,Double> limit)
          From the retireved mappings of column names to list of doubles, we return the column names of those whose span deviaition is higher than the allowed maximum, mapped to the offending value.
 List<Object> getTelescopeKeys(String telescope, String key)
          Returns the list of uniques for a telescope.
 List<String> getTelescopes()
          Returns the list of telescopes.
 Statistic getTelescopeStatistic(String telescope, String key)
          Returns the statistic on a column in the env table.
 Statistic getTelescopeTimes(String telescope, String key)
          Returns the statistic on a column in the env table.
 void init()
          If we are not the default user of the database, try to add ourself here.
static Map<String,Map<String,Double>> telescopeDoubleMapping(List<String> tels, String prop)
          Converts a string-to-string mapping into a string-toVector2D mapping, using the telescope names provided.
static Map<String,Map<String,Vector2D>> telescopeVectorMapping(List<String> tels, String prop)
          Converts a string-to-string mapping into a string-toVector2D mapping, using the telescope names provided.
static Map<String,Vector2D> vectorMapping(String prop)
          Converts a string-to-string mapping into a string-to Vector2D mapping
 
Methods inherited from class stella.sql.NightlyStatistic
duskToDawn, duskToDawn, getDone, getDone, getDone, getEnvironment, getEnvironment, getEnvironment, getExposureTimeSum, getJoint, getJoint, getJoint, getNightCount, getObs, getObs, getObs, getRoofOpenCount, getScienceTimeSum
 
Methods inherited from class mysql.AbstractSql
getPassword, getTable, getUserName, isEntry
 
Methods inherited from class util.PropertyBundles
clone, getLocalized, getLocalized, getLocalizedString, getLocalizedString, loadResource
 
Methods inherited from class util.PropertyResources
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, keyCreate, keyCreate, reload, setApplet
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, reload, removeProperty, rescanned, setObject, setProperties, setProperty, stringProperties, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 
Methods inherited from interface util.PropertySupplying
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringProperties
 

Field Detail

NULL

public static final String NULL
String instead of limits indicating that this has no meaning.

See Also:
Constant Field Values

TELESCOPESEPARATOR

public static final char TELESCOPESEPARATOR
character sparating telescope name from offending column name.

See Also:
Constant Field Values

KEY_TELESCOPE

public static final String KEY_TELESCOPE
The issuing telescopes.

See Also:
Constant Field Values

KEY_ENVLIST

public static final String KEY_ENVLIST
The fields to query from the env table. May include expressions.

See Also:
Constant Field Values

KEY_ENVNAMES

public static final String KEY_ENVNAMES
How the returned columns are named. Can be null.

See Also:
Constant Field Values

KEY_OBSLIST

public static final String KEY_OBSLIST
The fields to query from the obs table. May include expressions.

See Also:
Constant Field Values

KEY_OBSNAMES

public static final String KEY_OBSNAMES
How the returned columns are named. Can be null.

See Also:
Constant Field Values

KEY_OBSWHERE

public static final String KEY_OBSWHERE
Additional constraints for the obs table query.

See Also:
Constant Field Values

KEY_SCILIST

public static final String KEY_SCILIST
The fields to query from the obs table, with imagetyp=1.

See Also:
Constant Field Values

KEY_SCINAMES

public static final String KEY_SCINAMES
How the returned columns are named. Can be null.

See Also:
Constant Field Values

KEY_SCIWHERE

public static final String KEY_SCIWHERE
Additional constraints for the sci query, should include imagetyp=1.

See Also:
Constant Field Values

KEY_DONELIST

public static final String KEY_DONELIST
The fields to query from the env table. May include expressions.

See Also:
Constant Field Values

KEY_DONENAMES

public static final String KEY_DONENAMES
How the returned columns are named. Can be null.

See Also:
Constant Field Values

KEY_DONEWHERE

public static final String KEY_DONEWHERE
Additional constraints for the done table query.

See Also:
Constant Field Values

KEY_JOINTLIST

public static final String KEY_JOINTLIST
The fields to query from the env table. May include expressions.

See Also:
Constant Field Values

KEY_JOINTNAMES

public static final String KEY_JOINTNAMES
How the returned columns are named. Can be null.

See Also:
Constant Field Values

KEY_JOINTWHERE

public static final String KEY_JOINTWHERE
Additional constraints for the joint table query.

See Also:
Constant Field Values

env

private Map<String,Statistic> env
The retrieved data as column names to statistics.


envtimes

private Map<String,Statistic> envtimes
The retrieved data as column names to statistics.


tel

private Map<String,Map<String,Statistic>> tel
The retrieved data as column names to statistics.


teltimes

private Map<String,Map<String,Statistic>> teltimes
The retrieved data as column names to statistics.


telkeys

private Map<String,Map<String,List<Object>>> telkeys
The retrieved data as column names to keys (unique ids).

Constructor Detail

OffLimitAlarm

public OffLimitAlarm(Map<String,String> prop)
Constructs a new off-limit alarm log.

Method Detail

init

public void init()
Description copied from class: AbstractSql
If we are not the default user of the database, try to add ourself here.

Specified by:
init in interface Initializable
Overrides:
init in class AbstractSql

clearStats

public void clearStats()

addEnvironment

public void addEnvironment(List<String> envlist,
                           List<String> envas,
                           Map<String,Function> f,
                           Date now)
Retrieve and cache all information for the date in question.


addObs

public void addObs(List<String> obslist,
                   List<String> obsas,
                   Map<String,Function> f,
                   String add,
                   Date now)
Retrieve and cache all information for the date in question.


addDone

public void addDone(List<String> donelist,
                    List<String> doneas,
                    Map<String,Function> f,
                    String add,
                    Date now)
Retrieve and cache all information for the date in question.


addJoint

public void addJoint(List<String> jointlist,
                     List<String> jointas,
                     Map<String,Function> f,
                     String add,
                     Date now)
Retrieve and cache all information for the date in question.


getTelescopes

public List<String> getTelescopes()
Returns the list of telescopes.


getEnvStatistic

public Statistic getEnvStatistic(String key)
Returns the statistic on a column in the env table.


getEnvTimes

public Statistic getEnvTimes(String key)
Returns the statistic on a column in the env table.


getTelescopeStatistic

public Statistic getTelescopeStatistic(String telescope,
                                       String key)
Returns the statistic on a column in the env table.


getTelescopeTimes

public Statistic getTelescopeTimes(String telescope,
                                   String key)
Returns the statistic on a column in the env table.


getTelescopeKeys

public List<Object> getTelescopeKeys(String telescope,
                                     String key)
Returns the list of uniques for a telescope.


vectorMapping

public static Map<String,Vector2D> vectorMapping(String prop)
                                          throws ParseException
Converts a string-to-string mapping into a string-to Vector2D mapping

Throws:
ParseException

telescopeVectorMapping

public static Map<String,Map<String,Vector2D>> telescopeVectorMapping(List<String> tels,
                                                                      String prop)
                                                               throws ParseException
Converts a string-to-string mapping into a string-toVector2D mapping, using the telescope names provided. Each key is mapped to a double-tokenizable list, semi-colons separating the entries for each telescope. E.g. dettemp=-200,-100;-220,-80:further keys

Throws:
ParseException

telescopeDoubleMapping

public static Map<String,Map<String,Double>> telescopeDoubleMapping(List<String> tels,
                                                                    String prop)
                                                             throws ParseException
Converts a string-to-string mapping into a string-toVector2D mapping, using the telescope names provided. Each key is mapped to a semi-colons separated list for the entries for each telescope. E.g. dettemp=-200;-220:further keys

Throws:
ParseException

getAverageEnvOffs

public Map<String,Double> getAverageEnvOffs(Map<String,Vector2D> avmap)
From the retireved mappings of column names to list of doubles, we return the column names of those whose average are outside the bounds mapped to the average.


getMinMaxEnvOffs

public Map<String,Double> getMinMaxEnvOffs(Map<String,Vector2D> avmap)
From the retireved mappings of column names to list of doubles, we return the column names of those whose average are outside the bounds mapped to the average.


getSigmaEnvOffs

public Map<String,Double> getSigmaEnvOffs(Map<String,Double> limit)
From the retireved mappings of column names to list of doubles, we return the column names of those whose average are outside the bounds mapped to the average.


getSpanEnvOffs

public Map<String,Double> getSpanEnvOffs(Map<String,Double> limit)
From the retireved mappings of column names to list of doubles, we return the column names of those whose average are outside the bounds mapped to the average.


getAverageTelOffs

public Map<String,Double> getAverageTelOffs(String telescope,
                                            Map<String,Vector2D> avmap)
From the retireved mappings of column names to list of doubles, we return the column names of those whose average are outside the bounds mapped to the average.


getMinMaxTelOffs

public Map<String,Double> getMinMaxTelOffs(String telescope,
                                           Map<String,Vector2D> avmap)
From the retireved mappings of column names to list of doubles, we return the column names of those whose min/max are outside the bounds mapped to the offending value.


getSigmaTelOffs

public Map<String,Double> getSigmaTelOffs(String telescope,
                                          Map<String,Double> limit)
From the retireved mappings of column names to list of doubles, we return the column names of those whose standard deviaition is higher than the allowed maximum, mapped to the offending value.


getSpanTelOffs

public Map<String,Double> getSpanTelOffs(String telescope,
                                         Map<String,Double> limit)
From the retireved mappings of column names to list of doubles, we return the column names of those whose span deviaition is higher than the allowed maximum, mapped to the offending value.


convertToStatistic

public static Map<String,Statistic> convertToStatistic(Map<String,List<DataCard>> log,
                                                       int index)
Converts a mapping of strings to List of doubles into a mapping of strings to statistics. After a call to this method, no more values can be usefully added to the double list, without calling this method again.


extractUnique

public static Map<String,List<Object>> extractUnique(Map<String,List<DataCard>> log)
We take all the data cards and extract the unique IDs found for the given field names.


getAverageOffenders

private Map<String,Double> getAverageOffenders(Map<String,Statistic> stats,
                                               Map<String,Vector2D> avmap)
From the retireved mappings of column names to list of doubles, we return the column names of those whose average are outside the bounds mapped to the average.


getMinMaxOffenders

private Map<String,Double> getMinMaxOffenders(Map<String,Statistic> stats,
                                              Map<String,Vector2D> avmap)
From the retireved mappings of column names to list of doubles, we return the column names of those whose min/max are outside the bounds mapped to the offending value.


getSigmaOffenders

private Map<String,Double> getSigmaOffenders(Map<String,Statistic> stats,
                                             Map<String,Double> limit)
From the retireved mappings of column names to list of doubles, we return the column names of those whose standard deviaition is higher than the allowed maximum, mapped to the offending value.


getSpanOffenders

private Map<String,Double> getSpanOffenders(Map<String,Statistic> stats,
                                            Map<String,Double> limit)
From the retireved mappings of column names to list of doubles, we return the column names of those whose span deviaition is higher than the allowed maximum, mapped to the offending value.