stella.sql
Class NightlyStatistic

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

public class NightlyStatistic
extends AbstractSql

A night report reports on statistic on a nightly basis. The base class only extracts data from the db depending on the column names setting and provide some statistical methods. The interpretation of the data is left to its subclasses.


Nested Class Summary
static class NightlyStatistic.Duty
           
static class NightlyStatistic.Env
          Test only if the rise and set time is correctly calculated.
static class NightlyStatistic.Night
          Test only if the rise and set time is correctly calculated.
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
static String DEFPASSWORD
          The key to the password for db-acces if not default.
static String DEFUSERNAME
          The key to the user name for db-acces if not default.
static String KEY_RISETWILIGHT
          The key to the good-weather toggle height of the sun.
static String KEY_SETTWILIGHT
          The key to the good-weather toggle height of the sun.
 
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
NightlyStatistic(Map<String,String> prop)
           
 
Method Summary
 Date[] duskToDawn(Date around)
          From a given date we calculate the starting and ending date of the night, whose center is closest to the specified date.
 Date[] duskToDawn(Date around, double hset, double hrise)
          From a given date we calculate the starting and ending date of the night, whose center is closest to the specified date.
private  String getDateRestriciton(String begin, String end, Date night, double hset, double hrise)
          Returns a date restriciton for a given night and twilight zones.
 Map<String,List<DataCard>> getDone(List<String> col, List<String> as, Map<String,Function> f, String add, Date around)
           
 Map<String,List<DataCard>> getDone(List<String> col, List<String> as, Map<String,Function> f, String add, Date around, double hset, double hrise)
          Returns the queried columns from the done table as mapping from 'retreived-as' columns to list of doubles.If the timestamp is queried via the start column, this is converted to a Double holding the ms since 1970.
 Map<String,List<DataCard>> getDone(List<String> col, String add, Date around)
           
private  double getEnvCount(Date now, String addsel)
          Get the roof-open time at that night.
 Map<String,List<DataCard>> getEnvironment(List<String> col, Date around)
          Returns the named environement column as a list of doubles.
 Map<String,List<DataCard>> getEnvironment(List<String> col, List<String> as, Map<String,Function> f, Date around)
          Returns the named environement column as a list of doubles.
 Map<String,List<DataCard>> getEnvironment(List<String> col, List<String> as, Map<String,Function> f, Date around, double hset, double hrise)
          Returns the named environement column as a list of doubles.
 double getExposureTimeSum(Date night)
          Get the sum of all exposure times at a given night in seconds.
private  double getExpSum(Date night, String addsel)
           
 Map<String,List<DataCard>> getJoint(List<String> col, List<String> as, Map<String,Function> f, String add, Date around)
           
 Map<String,List<DataCard>> getJoint(List<String> col, List<String> as, Map<String,Function> f, String add, Date around, double hset, double hrise)
          Returns the queried columns from the done and obs table as mapping from 'retreived-as' columns to list of doubles.
 Map<String,List<DataCard>> getJoint(List<String> col, Map<String,Function> f, String add, Date around)
           
 double getNightCount(Date night, double solz)
          Get the maximum time for sun below horizon at that night.
 Map<String,List<DataCard>> getObs(List<String> col, List<String> as, Map<String,Function> f, String add, Date around)
           
 Map<String,List<DataCard>> getObs(List<String> col, List<String> as, Map<String,Function> f, String add, Date around, double hset, double hrise)
          Returns the queried columns from the obs table as mapping from 'retreived-as' columns to list of doubles.
 Map<String,List<DataCard>> getObs(List<String> col, String add, Date around)
           
 double getRoofOpenCount(Date night)
          Get the roof-open time at that night.
 double getScienceTimeSum(Date night)
          Get the sum of all scientific times at a given night in seconds.
private  Map<String,List<DataCard>> parseToMap(String id, String datekey, List<String> query, List<String> as, Map<String,Function> f, String table, String where)
          We parse a result set to a mapping of column names to doubles.
 
Methods inherited from class mysql.AbstractSql
getPassword, getTable, getUserName, init, 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

KEY_SETTWILIGHT

public static final String KEY_SETTWILIGHT
The key to the good-weather toggle height of the sun.

See Also:
Constant Field Values

KEY_RISETWILIGHT

public static final String KEY_RISETWILIGHT
The key to the good-weather toggle height of the sun.

See Also:
Constant Field Values

DEFUSERNAME

public static final String DEFUSERNAME
The key to the user name for db-acces if not default.

See Also:
Constant Field Values

DEFPASSWORD

public static final String DEFPASSWORD
The key to the password for db-acces if not default.

See Also:
Constant Field Values
Constructor Detail

NightlyStatistic

public NightlyStatistic(Map<String,String> prop)
Method Detail

getExposureTimeSum

public double getExposureTimeSum(Date night)
Get the sum of all exposure times at a given night in seconds.

Parameters:
night - midnight of the day in question.

getScienceTimeSum

public double getScienceTimeSum(Date night)
Get the sum of all scientific times at a given night in seconds.


getNightCount

public double getNightCount(Date night,
                            double solz)
Get the maximum time for sun below horizon at that night.


getRoofOpenCount

public double getRoofOpenCount(Date night)
Get the roof-open time at that night.


getObs

public Map<String,List<DataCard>> getObs(List<String> col,
                                         String add,
                                         Date around)

getObs

public Map<String,List<DataCard>> getObs(List<String> col,
                                         List<String> as,
                                         Map<String,Function> f,
                                         String add,
                                         Date around)

getObs

public Map<String,List<DataCard>> getObs(List<String> col,
                                         List<String> as,
                                         Map<String,Function> f,
                                         String add,
                                         Date around,
                                         double hset,
                                         double hrise)
Returns the queried columns from the obs table as mapping from 'retreived-as' columns to list of doubles. If the timestamp is queried via the dateobs column, this is converted to a Double holding the ms since 1970.


getDone

public Map<String,List<DataCard>> getDone(List<String> col,
                                          String add,
                                          Date around)

getDone

public Map<String,List<DataCard>> getDone(List<String> col,
                                          List<String> as,
                                          Map<String,Function> f,
                                          String add,
                                          Date around)

getDone

public Map<String,List<DataCard>> getDone(List<String> col,
                                          List<String> as,
                                          Map<String,Function> f,
                                          String add,
                                          Date around,
                                          double hset,
                                          double hrise)
Returns the queried columns from the done table as mapping from 'retreived-as' columns to list of doubles.If the timestamp is queried via the start column, this is converted to a Double holding the ms since 1970.


getJoint

public Map<String,List<DataCard>> getJoint(List<String> col,
                                           Map<String,Function> f,
                                           String add,
                                           Date around)

getJoint

public Map<String,List<DataCard>> getJoint(List<String> col,
                                           List<String> as,
                                           Map<String,Function> f,
                                           String add,
                                           Date around)

getJoint

public Map<String,List<DataCard>> getJoint(List<String> col,
                                           List<String> as,
                                           Map<String,Function> f,
                                           String add,
                                           Date around,
                                           double hset,
                                           double hrise)
Returns the queried columns from the done and obs table as mapping from 'retreived-as' columns to list of doubles. If the timestamp is queried via the dateobs column, this is converted to a Double holding the ms since 1970.


getEnvironment

public Map<String,List<DataCard>> getEnvironment(List<String> col,
                                                 Date around)
Returns the named environement column as a list of doubles.


getEnvironment

public Map<String,List<DataCard>> getEnvironment(List<String> col,
                                                 List<String> as,
                                                 Map<String,Function> f,
                                                 Date around)
Returns the named environement column as a list of doubles.


getEnvironment

public Map<String,List<DataCard>> getEnvironment(List<String> col,
                                                 List<String> as,
                                                 Map<String,Function> f,
                                                 Date around,
                                                 double hset,
                                                 double hrise)
Returns the named environement column as a list of doubles. If the timestamp is queried via the date column, this is converted to a Double holding the ms since 1970.


parseToMap

private Map<String,List<DataCard>> parseToMap(String id,
                                              String datekey,
                                              List<String> query,
                                              List<String> as,
                                              Map<String,Function> f,
                                              String table,
                                              String where)
We parse a result set to a mapping of column names to doubles. If no specific column names are given, the query names are used. If the special column datekey is requested, the result is interpreted as a timestamp, and its nano-sec precision time converted to a double, as ms since 1970.


duskToDawn

public Date[] duskToDawn(Date around)
From a given date we calculate the starting and ending date of the night, whose center is closest to the specified date.

Returns:
The set time on 0 and the rise time on 1, such that tset

duskToDawn

public Date[] duskToDawn(Date around,
                         double hset,
                         double hrise)
From a given date we calculate the starting and ending date of the night, whose center is closest to the specified date.

Returns:
The set time on 0 and the rise time on 1, such that tset

getDateRestriciton

private String getDateRestriciton(String begin,
                                  String end,
                                  Date night,
                                  double hset,
                                  double hrise)
Returns a date restriciton for a given night and twilight zones. Give the start and end column to add to the selection. Queries can be as complex as select start,duration,start+CAST(textcat(text(duration/1000), text(' seconds')) as interval) as end from done where start+CAST(textcat(text(duration/1000), text(' seconds')) as interval) < '2009-11-01' limit 10; results in start | duration | end -------------------------+----------+------------------------- 2009-01-02 16:52:40.57 | 2543 | 2009-01-02 16:52:42.57 2009-01-02 16:52:43.298 | 100846 | 2009-01-02 16:54:23.298 2009-01-02 16:54:24.331 | 100971 | 2009-01-02 16:56:04.331 2009-01-02 16:56:05.486 | 99852 | 2009-01-02 16:57:44.486 2009-01-02 16:57:45.521 | 100834 | 2009-01-02 16:59:25.521 2009-01-02 16:59:26.533 | 99857 | 2009-01-02 17:01:05.533 2009-01-02 17:01:06.577 | 99813 | 2009-01-02 17:02:45.577 2009-01-02 17:02:46.571 | 100828 | 2009-01-02 17:04:26.571 2009-01-02 17:04:27.652 | 99830 | 2009-01-02 17:06:06.652 2009-01-02 17:06:07.667 | 99828 | 2009-01-02 17:07:46.667


getEnvCount

private double getEnvCount(Date now,
                           String addsel)
Get the roof-open time at that night.


getExpSum

private double getExpSum(Date night,
                         String addsel)