stella.sensor
Class SolZSensor

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by util.rmi.RmiPropertyContainer
                  extended by util.rmi.AbstractRmiCaster
                      extended by stella.sensor.AbstractSensor
                          extended by stella.sensor.TimerTaskSensor
                              extended by stella.sensor.DataSensor
                                  extended by stella.sensor.CumulativeSensor
                                      extended by stella.sensor.PredictiveSensor
                                          extended by stella.sensor.SmoothingSensor
                                              extended by stella.sensor.DerivativeSensor
                                                  extended by stella.sensor.WeatherSensor
                                                      extended by stella.sensor.SolZSensor
All Implemented Interfaces:
Cloneable, Remote, Caster, DataCaster, RmiDataCaster, RmiErrorCaster, Cumulating, Deriving, Predicting, Smoothing, Telemetering, WeatherJudging, WeatherCaster, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying, RmiCaster, RmiPropertyBearing, PI
Direct Known Subclasses:
FakeSolZSensor, NoiseSolZSensor, WeirdSolZSensor

public class SolZSensor
extends WeatherSensor
implements PI

This is a non-abstract implementation of a WeatherSensor. It calculates the height of the sun from the current date and returns it as a sensor reading. It is also a WeatherSensor because it may produce WeatherEvents when the sun's zenith distance crosses the threshold value defined in its properties. This class is not very apt for testing the various sensor aspects, use the subclass NoiseSolZSensor for this purpose.

If one wants to implement updated versions for the site, sidereal time or solar position calculator, simple adds the fully qualified class name, like astro.SimpleSol to the properties. All of the updated classes must have an empty constructor.

This sensor adds the following properties if they are not set already:

Note that this class uses its own properties to construct its ConvertToPhysical instance, the CosineConversion.


Nested Class Summary
static class SolZSensor.Test
          Test purpose mainly.
 
Nested classes/interfaces inherited from class stella.sensor.TimerTaskSensor
TimerTaskSensor.SensorRead
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private static String DEFINVERSE
          The default inverse treatment.
private static Map DEFPROP
          The default properties.
private static String DEFRAW
          The default class name for raw-weather.
private static Class DEFSID
          The default sidereal time calculator if non is given in the properties file.
private static Class DEFSITE
          The default site if non is given in the properties file.
private static Class DEFSOL
          The default solar position calculator if non is given in the properties file.
private static String DEFZ
          The default z solar toggle value.
static String KEY_SIDEREAL
          The key describing the sidereal time calculator.
static String KEY_SITE
          The key describing the sensors location.
static String KEY_SOLARPOSITION
          The key describing the solar position calculator.
private  Site place
          The location of this sensor.
private  double sid
          The last calculated sidereal time.
private  SiderealTiming sidereal
          The class converting dates into sidereal time.
private  SolarPosition sol
          The class converting dates into solar positions.
 
Fields inherited from class stella.sensor.WeatherSensor
KEY_DERIVATIVEINVALID, KEY_DERIVATIVEPARAMETER, KEY_INVERSE, KEY_INVERSEDERIVATIVE, KEY_JUDGEDERIVATIVE, KEY_JUDGEPREDICT, KEY_JUDGERAW, KEY_JUDGESMOOTH, KEY_PREDICTINVALID, KEY_PREDICTPARAMETER, KEY_RAWINVALID, KEY_RAWPARAMETER, KEY_RETARDBADDERIVATIVE, KEY_RETARDBADPREDICT, KEY_RETARDBADRAW, KEY_RETARDBADSMOOTH, KEY_RETARDGOODDERIVATIVE, KEY_RETARDGOODPREDICT, KEY_RETARDGOODRAW, KEY_RETARDGOODSMOOTH, KEY_SMOOTHINVALID, KEY_SMOOTHPARAMETER
 
Fields inherited from class stella.sensor.DerivativeSensor
DEFRAWDERIVATIVE, derive, KEY_DERIVATIVEADVISE, KEY_DERIVE, KEY_PATH, KEY_RAWDERIVATIVE, z
 
Fields inherited from class stella.sensor.SmoothingSensor
f, g, KEY_SMOOTH, KEY_SMOOTHADVISE
 
Fields inherited from class stella.sensor.PredictiveSensor
KEY_BASE, KEY_CHI, KEY_EXTRAPOLATE, KEY_FUTURE, KEY_PREDICTADVISE, predict
 
Fields inherited from class stella.sensor.CumulativeSensor
KEY_AVERAGE, KEY_MEMORY, KEY_PACK
 
Fields inherited from class stella.sensor.DataSensor
DEFRAWFORMAT, DEFREPORT, DEFSIGMAFORMAT, KEY_RAWFORMAT, KEY_REPORT, KEY_SIGMAFORMAT
 
Fields inherited from class stella.sensor.TimerTaskSensor
KEY_RESPAWN
 
Fields inherited from class stella.sensor.AbstractSensor
KEY_BIND, KEY_BINDNAME, KEY_CONVERT, KEY_DESCRIPTION, KEY_SENSORNAME
 
Fields inherited from class util.rmi.AbstractRmiCaster
ALTERNATEHOST, ALTERNATEPORT, KEY_EXPORTPORT, KEY_REGISTRYHOST, KEY_REGISTRYPORT
 
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 vec_math.PI
HOUR, PIHALF, PITWO, RADIAN
 
Fields inherited from interface stella.rmi.RmiDataCaster
NAMING_EXTENSION
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Constructor Summary
protected SolZSensor()
          Empty constructor, do not use.
  SolZSensor(Map qualify)
          Constructs a fully-qualified sol z sensor.
 
Method Summary
protected  double calculateZ(Date now)
          Calculate the cosine of the solar zenith distance at the given time.
 void deriveAt(double raw)
          The implementation of the deriving interface.
 SiderealTiming getSiderealTiming()
          Returns the SiderealTiming instance used to convert system time to sidereal time.
 Site getSite()
          Returns the Site instance this sensor was constructed for.
 SolarPosition getSolarPosition()
          Returns the SolarPosition instance used to calculate the Sun's position out of the actual date.
protected  void numericalDeriveAt(double raw)
          An escape path for subclasses of sol z sensor that want to use the original numerical derivator.
 void predictFrom(double lastraw)
          Predicts from the actual data point to the near future.
 double readSensor()
          Reads the sensor.
 boolean validReading()
          The solar height sensor is always valid if the observing site is defined.
 
Methods inherited from class stella.sensor.WeatherSensor
addWeatherListener, conductOneMeasure, currentlyClear, currentlyRetarding, generateDataEvent, getMinClearUpTime, getSensorInitInfo, goodFromDerivative, goodFromPredict, goodFromRaw, goodFromSmooth, isDerivativeRetard, isPredictRetard, isRawRetard, isSmoothRetard, judgeWeather, notifyWeatherListener, removeWeatherListener, status
 
Methods inherited from class stella.sensor.DerivativeSensor
getDerivativeFormat, getDerivativeToggleInfo, getDerivator, getLastDerivative, isDerivativeAdvise, isDeriving, newData, regetDerive, registerDerivator
 
Methods inherited from class stella.sensor.SmoothingSensor
getLastSmooth, getSmoother, getSmoothToggleInfo, isSmoothAdvise, isSmoothing, regetSmooth, registerSmoother, smoothOne
 
Methods inherited from class stella.sensor.PredictiveSensor
getExtrapolation, getLastPredict, getPredictToggleInfo, isPredictAdvise, isPredicting, isReliable, regetPredict
 
Methods inherited from class stella.sensor.CumulativeSensor
cumulateOne, getLastRaw, getLastTime, getMaxSize, getMemory, getSize
 
Methods inherited from class stella.sensor.DataSensor
addDataListener, addRmiDataListener, exit, getRawFormat, getSigmaFormat, removeDataListener, removeRmiDataListener, report
 
Methods inherited from class stella.sensor.TimerTaskSensor
cancel, equals, getRawToggleInfo, getReading, getRespawn, getTimeOfRead, hashCode, initSensorTimerTask, isReady, regetRaw, setTimeOfRead, validReading
 
Methods inherited from class stella.sensor.AbstractSensor
addRmiErrorListener, createSensor, getBindName, getConvert, getSensorDescription, getSensorName, init, notifyErrorListener, removeRmiErrorListener, setConvert, toString
 
Methods inherited from class util.rmi.AbstractRmiCaster
bindAlternate, bindToRegistry, bindToRegistry, bindToRegistry, casterExit, casterExit, getBindName, isValid, unbindFromRegistry, unbindFromRegistry
 
Methods inherited from class util.rmi.RmiPropertyContainer
containsRemoteProperty, getRemoteProperties, getRemoteProperty, setRemoteProperty
 
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
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface stella.sensor.Cumulating
cumulateOne, getLastRaw, getLastTime, getMaxSize, getSize, getTimeOfRead, regetRaw
 
Methods inherited from interface util.rmi.RmiCaster
bindToRegistry, isValid, unbindFromRegistry
 
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
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 

Field Detail

KEY_SITE

public static final String KEY_SITE
The key describing the sensors location.

See Also:
Constant Field Values

KEY_SIDEREAL

public static final String KEY_SIDEREAL
The key describing the sidereal time calculator.

See Also:
Constant Field Values

KEY_SOLARPOSITION

public static final String KEY_SOLARPOSITION
The key describing the solar position calculator.

See Also:
Constant Field Values

DEFSITE

private static Class DEFSITE
The default site if non is given in the properties file. Defaults to TenerifeSite.


DEFSID

private static Class DEFSID
The default sidereal time calculator if non is given in the properties file. Defaults to astro.sidTimer.


DEFSOL

private static Class DEFSOL
The default solar position calculator if non is given in the properties file. Defaults to astro.SimpleSol.


DEFRAW

private static final String DEFRAW
The default class name for raw-weather.

See Also:
Constant Field Values

DEFZ

private static final String DEFZ
The default z solar toggle value.


DEFINVERSE

private static final String DEFINVERSE
The default inverse treatment.


DEFPROP

private static final Map DEFPROP
The default properties.


place

private Site place
The location of this sensor. Derived by class-loading of the appropriate property.


sidereal

private SiderealTiming sidereal
The class converting dates into sidereal time. Derived by class-loading of the appropriate property.


sol

private SolarPosition sol
The class converting dates into solar positions. Derived by class-loading of the appropriate property.


sid

private double sid
The last calculated sidereal time.

Constructor Detail

SolZSensor

protected SolZSensor()
              throws RemoteException
Empty constructor, do not use.

Throws:
RemoteException

SolZSensor

public SolZSensor(Map qualify)
           throws ClassNotFoundException,
                  InstantiationException,
                  IllegalAccessException,
                  RemoteException
Constructs a fully-qualified sol z sensor. Use of this constructor guarantees that the Map keys name, respawn, memory, pack, zsolar (the toggle value for nightfall, in radians), site, sidereal, and solarposition are always set. Note that the last three properties describe class names, so the must be valid resolvable classnames, otherwise the default calculators are used.

Parameters:
group - The ThreadGroup this thread belongs to.
name - The name of this thread (sensor).
qualify - The Map object describing this sensor.
Throws:
ClassNotFoundException - Should never be thrown, only on implementation errors.
InstantiationException - Should never be thrown, only on implementation errors.
IllegalAccessException - Should never be thrown, only on implementation errors.
RemoteException
Method Detail

readSensor

public double readSensor()
Reads the sensor. For the calculated sol z sensor this means the calculation of the solar position and the local sidereal time at the actual date. The calculation is done using the helper classes Sol, Sidereal and place which may be defined in the properties at construct.

Specified by:
readSensor in class TimerTaskSensor
Returns:
The cosine of the actual solar zenith distance.
See Also:
ConvertToPhysical

calculateZ

protected double calculateZ(Date now)
Calculate the cosine of the solar zenith distance at the given time. Called by the readSensor() method.


validReading

public boolean validReading()
The solar height sensor is always valid if the observing site is defined.

Specified by:
validReading in interface Telemetering

getSite

public Site getSite()
Returns the Site instance this sensor was constructed for. Use of the fully qualified constructor guarantess that this property is set.


getSiderealTiming

public SiderealTiming getSiderealTiming()
Returns the SiderealTiming instance used to convert system time to sidereal time. Care must be taken to register the right calculator for the systems clock time zone.


getSolarPosition

public SolarPosition getSolarPosition()
Returns the SolarPosition instance used to calculate the Sun's position out of the actual date.


deriveAt

public void deriveAt(double raw)
The implementation of the deriving interface. Sol z is a calculated sensor, therefore it can easyly calculate the derivative. Note that the value stored is the derivative of cos(z) with time, as the raw reading is cos(z). Note also that the first derivative in solar time means multiplying the first derivative in sidereal time with the solar to sidereal time intervall conversion factor SiderealTiming.SOL_TO_SID. To avoid recalculation of the sidereal time, the raw-reading value (i.e. the cosine of the solar zenith distance) is used in this method. Though the sidereal time was set at the last calculation of sensor-raw, this sid is used to determine the sign of the derivative.
Changes in the solar position with time are not included.

Specified by:
deriveAt in interface Deriving
Overrides:
deriveAt in class DerivativeSensor
Parameters:
raw - The actual raw reading of the sensor.

predictFrom

public void predictFrom(double lastraw)
Predicts from the actual data point to the near future. This is no problem for the solz sensor.

Specified by:
predictFrom in interface Predicting
Overrides:
predictFrom in class PredictiveSensor
Parameters:
lastraw - The current raw measurement

numericalDeriveAt

protected void numericalDeriveAt(double raw)
An escape path for subclasses of sol z sensor that want to use the original numerical derivator.