Skip to content

Instantly share code, notes, and snippets.

@everdaniel
Created August 15, 2013 05:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save everdaniel/6238427 to your computer and use it in GitHub Desktop.
Save everdaniel/6238427 to your computer and use it in GitHub Desktop.
// do the comparison between baseline and current dataset here
foreach(array('high_rva', 'mid_rva', 'low_rva') as $type) {
$si = 1;
for($i = 0; $i < count($this->baseline_dataset[$type]); $i++) {
// calculate Hydrologic Alteration Factor
$observed_frequency = $this->comparison_dataset[$type][$i];
$expected_frequency = $this->baseline_dataset[$type][$i] * ($this->years_post / $this->years_pre);
$divisor = ($expected_frequency > $observed_frequency) ? $expected_frequency : $observed_frequency;
if ($divisor == 0)
$hfa = 0;
else
$hfa = ($observed_frequency - $expected_frequency) / $divisor;
$this->saveHAF($i, $hfa);
$hfa_SI = $hfa;
// SI calc
if ($hfa_SI > 0)
$si = $si * $hfa_SI;
if ($hfa_SI < 0)
$si = $si * (-1 * $hfa_SI);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment