GliderToolsCommunity / GliderTools

A toolkit for processing Seaglider base station NetCDF files: despiking, smoothing, outlier detection, backscatter, fluorescence quenching, calibration, gridding, interpolation.
https://glidertools.readthedocs.io
GNU Affero General Public License v3.0
68 stars 28 forks source link

Mixed layer depth algorithm faulty #168

Closed MartinMohrmann closed 1 year ago

MartinMohrmann commented 1 year ago

Describe the bug Mixed layer depth computation currently only works if the stratification is stable and the variable used for computation is monotonically increasing with depth.

To Reproduce Steps to reproduce the behavior:

  1. Use dataset with either unstable stratification or temperature inversions (e.g. from here: https://observations.voiceoftheocean.org/SEA055/M16)
  2. Apply mixed layer algorithm from Glidertools
  3. Pass temperature as input variable, use thresh=0.3, ref_depth=1 (problem is present for any parameters though...)
  4. See error, the mixed layer depth is very noise and not at the same depth as the thermocline for a temperature threshold.

Expected behavior Mixed layer depth computation that takes the shallowest observation below the reference depth that exceeds the given threshold. Currently it takes the value with is the closes to (variable at reference depth - threshold variable), which can be at any depth.

Screenshots mld_bug_report

Additional context Please note that I already implemented a corrected algorithm. I create this Bug report for documentation and motivation for my pull request to come soon. :)