//
// PURPOSE: Trigger the first two on minimum fluorescence threshold and outlier
// rejection only.  Trigger the rest using the peak detection algorithm.
//
// AUTHORS: 1) Yanwu and Rob; 2 October 2009
//
// Omitting a threshold shuts it off.
//
// For outlier rejection, there must be ngood samples (that pass the
// threshold tests) out of the last nsamples to trigger a gulp.
//

option_PTL_INL = 0;   // 0 = Phytoplankton Thin Layer (PTL); 1 = Intermediate Nepheloid Layer (INL)

option_Front_TempOrFl = 0; // 0 = temperature front; 1 = fluorescence front.

option_into_upwelling = 0;   // 0 = out-of-upwelling; 1 = into-upwelling
//option_into_upwelling = 1;   // 0 = out-of-upwelling; 1 = into-upwelling

option_BaselineWindow_RunningOrSliding = 1; // Window type for calculating the signal baseline = %d (0 = from time zero to now; 1 = over a number of yo-yo profiles)

num_profiles_BaselineWindow = 10; // Number of yo-yo profiles to average for giving the signal background = %d (No more than 20. Used only when window type for calculating the signal baseline = 1)

option_ClosenessOfTwoCrossings = 0;   // Whether requiring closeness of the 1st and 2nd crossings. 0 = No; 1 = Yes.

option_PeaksAtSurface = 1;   // Whether peaks are likely to be at sea surface. 0 = No; 1 = Yes.

ratio_pktrigs_ctrltrigs = 100; // One control-triggering after every 3rd peak-triggering.

len_window_full = 8;

//timewindow_peakbaseline = 3600.0; // Seconds

timewindow_peakbaseline = 1200.0; // Seconds

alpha_fl	= 1.5;

alpha_bb	= 1.2;

beta_fl	= 0.6;

beta_bb	= 0.6;

delta_dep	= 1.0;		// Meters

delta_fl_bb_rise	= 1.0e-4;	// Raw fl676, or bb470, or bb676 measurement

delta_fl_bb_drop	= 1.0e-5;	// Raw fl676, or bb470, or bb676 measurement

dep_shallow_upwelling = 5.0; // In meters. Shallow depth bound for calculating temp homogeneity in water column.

dep_midshallow_upwelling = 10.0; // In meters. Mid-shallow depth for calculating temp homogeneity in water column.

dep_middeep_upwelling = 15.0; // In meters. Mid-deep depth for calculating temp homogeneity in water column.

dep_deep_upwelling = 20.0; // In meters. Deep depth bound for calculating temp homogeneity in water column.

//thresh_TempDiffInUpwelling = 0.2; // Deg. C. Threshold of the vertical temperature homegeneity index for detecting an upwelling water column.
thresh_TempDiffInUpwelling = 0.5; // Deg. C. Threshold of the vertical temperature homegeneity index for detecting an upwelling water column.

thresh_NumProfilesInUpwelling = 3; // Minimum number of consecutive profiles for declaring an upwelling water column.
//thresh_NumProfilesInUpwelling = 5; // Minimum number of consecutive profiles for declaring an upwelling water column.

num_ProfilesAvgTempDiff = 3; // Window length (number of profiles) for low-pass filtering deltaTvert.

num_ProfilesGapTempDiff = 5; // Gap (in number of profiles) btn low-pass filtered deltaTvert for front detection.

step_TempDiffInTempFront = 0.2; // Deg. C. Step change of temperature difference btn shallow and deep depths for detecting a temperature front

thresh_TempDiffInTempFront = 0.5; // Deg. C. Upper limit of temperature difference btn shallow and deep depths for detecting a front

thresh_NumProfilesInTempFront = 3; // Minimum number of consecutive profiles for declaring a temperature front.

dep_shallow_fl = 2.0; // In meters. Shallow depth bound in fluorescence front detection

num_ProfilesAvgFl = 5; // Number of profiles for averaging fl_max

num_ProfilesGapFl = 5; // Gap (in number of profiles) btn present profile and the last profile participating in averaging fl_max

step_FlInFlFront = 0.001; // Raw measurement. Step change of fl_max for detecting a fluorescence front.

thresh_NumProfilesInFlFront = 3; // Minimum number of consecutive profiles for declaring an fl front.

peakDetection0 = 1;
upwellingDetection0 = 0;
frontDetection0 = 0;
mindepth0 = 1.5;         	// Meters
minfl676_0 = 0.002;
minTempDiffVert0 = 0.5;
GulperNumberFiredBefore0 = 3;
timelockoutpeak0 = 900.0;       // Seconds
//timemaxwait0 = 43200.0;       // Seconds
timemaxwait0 = 64800.0;       // Seconds
//mindepthmaxwait0 = 10.0;         	// Meters
//maxdepthmaxwait0 = 11.0;         	// Meters

peakDetection1 = 1;
upwellingDetection1 = 0;
frontDetection1 = 0;
mindepth1 = 1.5;         	// Meters
minTempDiffVert1 = 0.5;
GulperNumberFiredBefore1 = 0;
timelockoutpeak1 = 900.0;       // Seconds
GulperNumberRefMaxWait1 = 0;
timemaxwait1 = 3600.0;       // Seconds
//mindepthmaxwait1 = 10.0;         	// Meters
//maxdepthmaxwait1 = 11.0;         	// Meters

peakDetection2 = 1;
upwellingDetection2 = 0;
frontDetection2 = 0;
mindepth2 = 1.5;         	// Meters
minTempDiffVert2 = 0.5;
GulperNumberFiredBefore2 = 1;
timelockoutpeak2 = 900.0;       // Seconds
GulperNumberRefMaxWait2 = 1;
timemaxwait2 = 3600.0;       // Seconds
//mindepthmaxwait2 = 10.0;         	// Meters
//maxdepthmaxwait2 = 11.0;         	// Meters

peakDetection3 = 0;
upwellingDetection3 = 0;
frontDetection3 = 1;
mindepth3 = 1.5;         	// Meters
maxdepth3 = 20.0;         	// Meters
GulperNumberFiredBefore3 = 7;
timelockoutfront3 = 200.0;       // Seconds
//timemaxwait3 = 41400.0;       // Seconds
timemaxwait3 = 63000.0;       // Seconds
//mindepthmaxwait3 = 10.0;         	// Meters
//maxdepthmaxwait3 = 11.0;         	// Meters

peakDetection4 = 0;
upwellingDetection4 = 0;
frontDetection4 = 1;
mindepth4 = 1.5;         	// Meters
maxdepth4 = 20.0;         	// Meters
GulperNumberFiredBefore4 = 3;
timelockoutfront4 = 200.0;       // Seconds
GulperNumberRefMaxWait4 = 3;
timemaxwait4 = 1800.0;       // Seconds
//mindepthmaxwait4 = 10.0;         	// Meters
//maxdepthmaxwait4 = 11.0;         	// Meters

peakDetection5 = 0;
upwellingDetection5 = 0;
frontDetection5 = 1;
mindepth5 = 1.5;         	// Meters
maxdepth5 = 20.0;         	// Meters
GulperNumberFiredBefore5 = 4;
timelockoutfront5 = 200.0;       // Seconds
GulperNumberRefMaxWait5 = 4;
timemaxwait5 = 1800.0;       // Seconds
//mindepthmaxwait5 = 10.0;         	// Meters
//maxdepthmaxwait5 = 11.0;         	// Meters

peakDetection6 = 0;
upwellingDetection6 = 0;
frontDetection6 = 1;
mindepth6 = 1.5;         	// Meters
maxdepth6 = 20.0;         	// Meters
GulperNumberFiredBefore6 = 5;
timelockoutfront6 = 200.0;       // Seconds
GulperNumberRefMaxWait6 = 5;
timemaxwait6 = 1800.0;       // Seconds
//mindepthmaxwait6 = 10.0;         	// Meters
//maxdepthmaxwait6 = 11.0;         	// Meters

peakDetection7 = 0;
upwellingDetection7 = 1;
frontDetection7 = 0;
mindepth7 = 10.0;         	// Meters
maxdepth7 = 11.0;         	// Meters
//timeLockOutAtStart7 = 21600.0;    // Seconds
//timemaxwait7 = 32400.0;       // Seconds
timemaxwait7 = 52200.0;       // Seconds
mindepthmaxwait7 = 10.0;         	// Meters
maxdepthmaxwait7 = 11.0;         	// Meters

peakDetection8 = 0;
upwellingDetection8 = 1;
frontDetection8 = 0;
mindepth8 = 10.0;         	// Meters
maxdepth8 = 11.0;         	// Meters
GulperNumberFiredBefore8 = 7;
timelockoutupwelling8 = 500.0;       // Seconds
GulperNumberRefMaxWait8 = 7;
timemaxwait8 = 1800.0;       // Seconds
mindepthmaxwait8 = 10.0;         	// Meters
maxdepthmaxwait8 = 11.0;         	// Meters

peakDetection9 = 0;
upwellingDetection9 = 1;
frontDetection9 = 0;
mindepth9 = 10.0;         	// Meters
maxdepth9 = 11.0;         	// Meters
GulperNumberFiredBefore9 = 8;
timelockoutupwelling9 = 500.0;       // Seconds
GulperNumberRefMaxWait9 = 8;
timemaxwait9 = 1800.0;       // Seconds
mindepthmaxwait9 = 10.0;         	// Meters
maxdepthmaxwait9 = 11.0;         	// Meters
