Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
384 changes: 189 additions & 195 deletions src/org/aavso/tools/vstar/util/period/wwz/WWZStatistic.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,204 +23,198 @@
/**
* A single Weighted Wavelet Transform datapoint.
*
* The comments for each data member below are taken from the WWZ
* documentation, (C) AAVSO.
* The comments for each data member below are taken from the WWZ documentation,
* (C) AAVSO.
*
* @see org.aavso.tools.vstar.util.period.wwz.WeightedWaveletZTransform
*/
public class WWZStatistic implements IPeriodAnalysisDatum {

/** The time being examined, in time units. */
private double tau;

/** The frequency being tested, in cycles per time unit. */
private double freq;

/**
* Value of the WWZ; this is approximately an F-statistic with N(eff) and 2
* degrees of freedom, and expected value 1. It indicates whether or not
* there is a periodic fluctuation at the given time, of the given
* frequency.
*/
private double wwz;

/**
* Weighted wavelet amplitude; if the signal is periodic at the frequency
* being tested, this gives the (real semi-) amplitude of the corresponding
* best-fit sinusoid.
*/
private double amp;

/**
* Mean apparent magnitude of the object at time tau.
*/
private double mave;

/**
* The effective number of data for the given time and frequency being
* tested.
*/
private double neff;

/**
* Constructor.
*
* @param tau
* The time being examined, in time units.
* @param freq
* The frequency being tested, in cycles per time unit.
* @param wwz
* Value of the WWZ.
* @param amp
* Weighted wavelet amplitude.
* @param mave
* Mean apparent magnitude of the object at time tau.
* @param neff
* The effective number of data for the given time and frequency.
*/
public WWZStatistic(double tau, double freq, double wwz, double amp,
double mave, double neff) {
this.tau = tau;
this.freq = freq;
this.wwz = wwz;
this.amp = amp;
this.mave = mave;
this.neff = neff;
}

/**
* @return the tau
*/
public double getTau() {
return tau;
}

/**
* @return the freq
*/
public double getFrequency() {
return freq;
}

/**
* @return the period (reciprocal of the frequency).
*/
public double getPeriod() {
return 1.0 / freq;
}

/**
* @return the wwz
*/
public double getWwz() {
return wwz;
}

/**
* @return the amp
*/
public double getSemiAmplitude() {
return amp;
}

/**
* @return the mave
*/
public double getMave() {
return mave;
}

/**
* @return the neff
*/
public double getNeff() {
return neff;
}

// Remaining methods from IPeriodAnalysisDatum

@Override
public double getPower() {
return getWwz();
}

@Override
public boolean equals(Object other) {
boolean isEqual = false;

if (other instanceof WWZStatistic) {
WWZStatistic that = (WWZStatistic) other;
isEqual = this.tau == that.tau && this.freq == that.freq
&& this.wwz == that.wwz && this.amp == that.amp
&& this.mave == that.mave && this.neff == that.neff;
}

return isEqual;
}

@Override
public String toString() {
return String
.format("tau=%1.4f, freq=%1.4f, wwz=%1.4f, amp=%1.4f, mave=%1.4f, neff=%1.4f",
tau, freq, wwz, amp, mave, neff);
}

/**
* Given a coordinate type, return the corresponding value from this
* statistic object.
*
* @param type
* The coordinate type.
* @return The value of that coordinate for this instance.
*/
public final double getValue(WWZCoordinateType type) {
double value = 0;

switch (type) {
case TAU:
value = getTau();
break;
case FREQUENCY:
value = getFrequency();
break;
case PERIOD:
value = getPeriod();
break;
case WWZ:
value = getWwz();
break;
case SEMI_AMPLITUDE:
value = getSemiAmplitude();
break;
case MEAN_MAG:
value = getMave();
break;
case EFFECTIVE_NUM_DATA:
value = getNeff();
break;
}

return value;
}

@Override
// Required by IPeriodAnalysisDatum implement clause; probably unused by
// caller.
// TODO: use additional PeriodAnalysisCoordinateType, abolishing the need
// for WWZCoordinateType.
public double getValue(PeriodAnalysisCoordinateType type) {
double value = 0;

if (type == PeriodAnalysisCoordinateType.FREQUENCY) {
value = getFrequency();
} else if (type == PeriodAnalysisCoordinateType.PERIOD) {
value = getPeriod();
} else if (type == PeriodAnalysisCoordinateType.AMPLITUDE) {
value = getSemiAmplitude();
} else if (type == PeriodAnalysisCoordinateType.POWER) {
value = getPower();
}

return value;
}
/** The time being examined, in time units. */
private double tau;

/** The frequency being tested, in cycles per time unit. */
private double freq;

/**
* Value of the WWZ; this is approximately an F-statistic with N(eff) and 2
* degrees of freedom, and expected value 1. It indicates whether or not there
* is a periodic fluctuation at the given time, of the given frequency.
*/
private double wwz;

/**
* Weighted wavelet amplitude; if the signal is periodic at the frequency being
* tested, this gives the (real semi-) amplitude of the corresponding best-fit
* sinusoid.
*/
private double amp;

/**
* Mean apparent magnitude of the object at time tau.
*/
private double mave;

/**
* The effective number of data for the given time and frequency being tested.
*/
private double neff;

/**
* Constructor.
*
* @param tau The time being examined, in time units.
* @param freq The frequency being tested, in cycles per time unit.
* @param wwz Value of the WWZ.
* @param amp Weighted wavelet amplitude.
* @param mave Mean apparent magnitude of the object at time tau.
* @param neff The effective number of data for the given time and frequency.
*/
public WWZStatistic(double tau, double freq, double wwz, double amp, double mave, double neff) {
this.tau = tau;
this.freq = freq;
this.wwz = wwz;
this.amp = amp;
this.mave = mave;
this.neff = neff;
}

/**
* @return the tau
*/
public double getTau() {
return tau;
}

/**
* @return the freq
*/
public double getFrequency() {
return freq;
}

/**
* @return the period (reciprocal of the frequency).
*/
public double getPeriod() {
return 1.0 / freq;
}

/**
* @return the wwz
*/
public double getWwz() {
return wwz;
}

/**
* @return the amp
*/
public double getSemiAmplitude() {
return amp;
}

/**
* @return the mave
*/
public double getMave() {
return mave;
}

/**
* @return the neff
*/
public double getNeff() {
return neff;
}

// Remaining methods from IPeriodAnalysisDatum

@Override
public double getPower() {
return getWwz();
}

@Override
public boolean equals(Object other) {
boolean isEqual = false;

if (other instanceof WWZStatistic) {
WWZStatistic that = (WWZStatistic) other;
isEqual = this.tau == that.tau && this.freq == that.freq && this.wwz == that.wwz && this.amp == that.amp
&& this.mave == that.mave && this.neff == that.neff;
}

return isEqual;
}

@Override
public String toString() {
return String.format("tau=%1.4f, freq=%1.4f, wwz=%1.4f, " +
"amp=%1.4f, mave=%1.4f, neff=%1.4f",
tau, freq, wwz, amp, mave, neff);
}

public String toStructString() {
return String.format("{ %f, %f, %f, %f, %f, %f }",
tau, freq, wwz, amp, mave, neff);
}

/**
* Given a coordinate type, return the corresponding value from this statistic
* object.
*
* @param type The coordinate type.
* @return The value of that coordinate for this instance.
*/
public final double getValue(WWZCoordinateType type) {
double value = 0;

switch (type) {
case TAU:
value = getTau();
break;
case FREQUENCY:
value = getFrequency();
break;
case PERIOD:
value = getPeriod();
break;
case WWZ:
value = getWwz();
break;
case SEMI_AMPLITUDE:
value = getSemiAmplitude();
break;
case MEAN_MAG:
value = getMave();
break;
case EFFECTIVE_NUM_DATA:
value = getNeff();
break;
}

return value;
}

@Override
// Required by IPeriodAnalysisDatum implement clause; probably unused by
// caller.
// TODO: use additional PeriodAnalysisCoordinateType, abolishing the need
// for WWZCoordinateType.
public double getValue(PeriodAnalysisCoordinateType type) {
double value = 0;

if (type == PeriodAnalysisCoordinateType.FREQUENCY) {
value = getFrequency();
} else if (type == PeriodAnalysisCoordinateType.PERIOD) {
value = getPeriod();
} else if (type == PeriodAnalysisCoordinateType.AMPLITUDE) {
value = getSemiAmplitude();
} else if (type == PeriodAnalysisCoordinateType.POWER) {
value = getPower();
}

return value;
}
}
Loading
Loading