//
// 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_FireAll = 0;   // 0 = No; 1 = Yes.

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

option_RHOD = 0;   // 0 = Not using rhodamine signal; 1 = Alternately capturing chlorophyll peaks (and controls) and rhodamine peaks (and controls); 2 = Only capturing rhodamine peaks (and controls). 

gulps_ChlOrRhod = 1; //If alternately capturing chl and rhodamine, number of gulps for each signal (this parameter is only relevant for option_RHOD == 1).

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 = 5;
//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 = 20; // One control-triggering after every Nth peak-triggering. If N>=20, it means no control sample.

len_window_full = 8;

//timewindow_peakbaseline = 3600.0; // Seconds
timewindow_peakbaseline = 600.0; // Seconds

alpha_fl	= 1.2;
//alpha_fl	= 1.5;

alpha_bb	= 1.2;

alpha_rhod	= 1.2;

beta_fl	= 0.6;

beta_bb	= 0.6;

beta_rhod = 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

//Need to update.
delta_rhod_rise	= 1.0e-3;	// Raw rhodamine measurement
delta_rhod_drop	= 1.0e-4;	// Raw rhodamine 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.25; // Deg. C. Threshold of the vertical temperature homegeneity index for detecting an upwelling water column.
thresh_TempDiffInUpwelling = 0.3; // 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.3; // Deg. C.
//thresh_TempDiffInTempFront = 0.5; // Deg. C.
// When option_into_upwelling = 1 (flying into upwelling water): upper limit of temperature difference btn shallow and deep depths for detecting a front.
// When option_into_upwelling = 0 (flying out of upwelling water): lower limit.

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 = 0;
upwellingDetection0 = 0;
frontDetection0 = 0;
mindepth0 = 1.5;         	// Meters
mintemperature0 = 13.95;
maxtemperature0 = 14.05;
timeLockOutAtStart0 = 60.0;    // Seconds
timemaxwait0 = 500.0;       // Seconds
//mindepthmaxwait0 = 10.0;         	// Meters
//maxdepthmaxwait0 = 11.0;         	// Meters

peakDetection1 = 0;
upwellingDetection1 = 0;
frontDetection1 = 0;
mindepth1 = 1.5;         	// Meters
mintemperature1 = 12.45;
maxtemperature1 = 12.55;
GulperNumberFiredBefore1 = 0;
timelockoutpeak1 = 350.0;       // Seconds
timemaxwait1 = 1000.0;       // Seconds
//mindepthmaxwait1 = 10.0;         	// Meters
//maxdepthmaxwait1 = 11.0;         	// Meters

peakDetection2 = 0;
upwellingDetection2 = 0;
frontDetection2 = 0;
mindepth2 = 1.5;         	// Meters
mintemperature2 = 13.95;
maxtemperature2 = 14.05;
GulperNumberFiredBefore2 = 1;
timelockoutpeak2 = 350.0;       // Seconds
timemaxwait2 = 1500.0;       // Seconds
//mindepthmaxwait2 = 10.0;         	// Meters
//maxdepthmaxwait2 = 11.0;         	// Meters

peakDetection3 = 0;
upwellingDetection3 = 0;
frontDetection3 = 0;
mindepth3 = 1.5;         	// Meters
mintemperature3 = 12.45;
maxtemperature3 = 12.55;
GulperNumberFiredBefore3 = 2;
timelockoutpeak3 = 350.0;       // Seconds
timemaxwait3 = 2000.0;       // Seconds
//mindepthmaxwait3 = 10.0;         	// Meters
//maxdepthmaxwait3 = 11.0;         	// Meters

peakDetection4 = 0;
upwellingDetection4 = 0;
frontDetection4 = 0;
mindepth4 = 1.5;         	// Meters
mintemperature4 = 13.95;
maxtemperature4 = 14.05;
GulperNumberFiredBefore4 = 3;
timelockoutpeak4 = 350.0;       // Seconds
timemaxwait4 = 2500.0;       // Seconds
//mindepthmaxwait4 = 10.0;         	// Meters
//maxdepthmaxwait4 = 11.0;         	// Meters

peakDetection5 = 0;
upwellingDetection5 = 0;
frontDetection5 = 0;
GulperNumberFiredBefore5 = 4;
mindepth5 = 1.5;         	// Meters
mintemperature5 = 12.45;
maxtemperature5 = 12.55;
//timelockoutpeak5 = 350.0;       // Seconds
timeLockOutAtStart5 = 60.0;    // Seconds
timemaxwait5 = 550.0;       // Seconds
//mindepthmaxwait5 = 10.0;         	// Meters
//maxdepthmaxwait5 = 11.0;         	// Meters

peakDetection6 = 0;
upwellingDetection6 = 0;
frontDetection6 = 0;
mindepth6 = 1.5;         	// Meters
mintemperature6 = 13.95;
maxtemperature6 = 14.05;
GulperNumberFiredBefore6 = 5;
timelockoutpeak6 = 350.0;       // Seconds
timemaxwait6 = 1100.0;       // Seconds
//mindepthmaxwait6 = 10.0;         	// Meters
//maxdepthmaxwait6 = 11.0;         	// Meters

peakDetection7 = 0;
upwellingDetection7 = 0;
frontDetection7 = 0;
mindepth7 = 1.5;         	// Meters
mintemperature7 = 12.45;
maxtemperature7 = 12.55;
GulperNumberFiredBefore7 = 6;
timelockoutpeak7 = 350.0;    // Seconds
timemaxwait7 = 1650.0;       // Seconds
//mindepthmaxwait7 = 5.0;         	// Meters
//maxdepthmaxwait7 = 6.0;         	// Meters

peakDetection8 = 0;
upwellingDetection8 = 0;
frontDetection8 = 0;
mindepth8 = 1.5;         	// Meters
mintemperature8 = 13.95;
maxtemperature8 = 14.05;
GulperNumberFiredBefore8 = 7;
timelockoutpeak8 = 350.0;       // Seconds
timemaxwait8 = 2200.0;       // Seconds
//mindepthmaxwait8 = 5.0;         	// Meters
//maxdepthmaxwait8 = 6.0;         	// Meters

peakDetection9 = 0;
upwellingDetection9 = 0;
frontDetection9 = 0;
mindepth9 = 1.5;         	// Meters
mintemperature9 = 12.45;
maxtemperature9 = 12.55;
GulperNumberFiredBefore9 = 8;
timelockoutpeak9 = 350.0;       // Seconds
timemaxwait9 = 2750.0;       // Seconds
//mindepthmaxwait9 = 5.0;         	// Meters
//maxdepthmaxwait9 = 6.0;         	// Meters

peakDetection10 = 0;
upwellingDetection10 = 0;
frontDetection10 = 0;
mindepth10 = 1.5;         	// Meters
mintemperature10 = 13.95;
maxtemperature10 = 14.05;
GulperNumberFiredBefore10 = 9;
//timelockoutpeak10 = 350.0;       // Seconds
timeLockOutAtStart10 = 60.0;    // Seconds
timemaxwait10 = 500.0;       // Seconds
//mindepthmaxwait10 = 5.0;         	// Meters
//maxdepthmaxwait10 = 6.0;         	// Meters

peakDetection11 = 0;
upwellingDetection11 = 0;
frontDetection11 = 0;
mindepth11 = 1.5;         	// Meters
mintemperature11 = 12.45;
maxtemperature11 = 12.55;
GulperNumberFiredBefore11 = 10;
timelockoutpeak11 = 350.0;       // Seconds
timemaxwait11 = 1000.0;       // Seconds
//mindepthmaxwait11 = 5.0;         	// Meters
//maxdepthmaxwait11 = 6.0;         	// Meters

peakDetection12 = 0;
upwellingDetection12 = 0;
frontDetection12 = 0;
mindepth12 = 1.5;         	// Meters
mintemperature12 = 13.95;
maxtemperature12 = 14.05;
GulperNumberFiredBefore12 = 11;
timelockoutpeak12 = 350.0;       // Seconds
timemaxwait12 = 1500.0;       // Seconds
//mindepthmaxwait12 = 5.0;         	// Meters
//maxdepthmaxwait12 = 6.0;         	// Meters

peakDetection13 = 0;
upwellingDetection13 = 0;
frontDetection13 = 0;
mindepth13 = 1.5;         	// Meters
mintemperature13 = 12.45;
maxtemperature13 = 12.55;
GulperNumberFiredBefore13 = 12;
timelockoutpeak13 = 350.0;       // Seconds
timemaxwait13 = 2000.0;       // Seconds
//mindepthmaxwait13 = 5.0;         	// Meters
//maxdepthmaxwait13 = 6.0;         	// Meters

peakDetection14 = 0;
upwellingDetection14 = 0;
frontDetection14 = 0;
mindepth14 = 1.5;         	// Meters
mintemperature14 = 13.95;
maxtemperature14 = 14.05;
GulperNumberFiredBefore14 = 13;
timelockoutpeak14 = 350.0;       // Seconds
timemaxwait14 = 2500.0;       // Seconds
//mindepthmaxwait14 = 5.0;         	// Meters
//maxdepthmaxwait14 = 6.0;         	// Meters

peakDetection15 = 0;
upwellingDetection15 = 0;
frontDetection15 = 0;
mindepth15 = 1.5;         	// Meters
mintemperature15 = 12.45;
maxtemperature15 = 12.55;
GulperNumberFiredBefore15 = 14;
//timelockoutpeak15 = 400.0;       // Seconds
timeLockOutAtStart15 = 60.0;    // Seconds
timemaxwait15 = 800.0;       // Seconds
//mindepthmaxwait15 = 5.0;         	// Meters
//maxdepthmaxwait15 = 6.0;         	// Meters

peakDetection16 = 0;
upwellingDetection16 = 0;
frontDetection16 = 0;
mindepth16 = 1.5;         	// Meters
mintemperature16 = 13.95;
maxtemperature16 = 14.05;
GulperNumberFiredBefore16 = 15;
timelockoutpeak16 = 400.0;       // Seconds
timemaxwait16 = 1600.0;       // Seconds
//mindepthmaxwait16 = 5.0;         	// Meters
//maxdepthmaxwait16 = 6.0;         	// Meters

peakDetection17 = 0;
upwellingDetection17 = 0;
frontDetection17 = 0;
mindepth17 = 1.5;         	// Meters
mintemperature17 = 12.45;
maxtemperature17 = 12.55;
GulperNumberFiredBefore17 = 16;
timelockoutpeak17 = 400.0;       // Seconds
timemaxwait17 = 2400.0;       // Seconds
//mindepthmaxwait17 = 5.0;         	// Meters
//maxdepthmaxwait17 = 6.0;         	// Meters

peakDetection18 = 0;
upwellingDetection18 = 0;
frontDetection18 = 0;
mindepth18 = 1.5;         	// Meters
mintemperature18 = 13.95;
maxtemperature18 = 14.05;
GulperNumberFiredBefore18 = 17;
timelockoutpeak18 = 400.0;       // Seconds
timemaxwait18 = 3200.0;       // Seconds
//mindepthmaxwait18 = 5.0;         	// Meters
//maxdepthmaxwait18 = 6.0;         	// Meters

peakDetection19 = 0;
upwellingDetection19 = 0;
frontDetection19 = 0;
mindepth19 = 1.5;         	// Meters
mintemperature19 = 12.45;
maxtemperature19 = 12.55;
GulperNumberFiredBefore19 = 18;
timelockoutpeak19 = 400.0;       // Seconds
timemaxwait19 = 4000.0;       // Seconds
//mindepthmaxwait19 = 5.0;         	// Meters
//maxdepthmaxwait19 = 6.0;         	// Meters
