From ab12189247111370f785d6c838e3d76355b3bd91 Mon Sep 17 00:00:00 2001 From: Bas des Tombe Date: Fri, 4 Aug 2023 17:47:31 +0200 Subject: [PATCH] variance_stokes_linear() does not default through zero anymore. --- CHANGELOG.rst | 1 + src/dtscalibration/datastore.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5ad48eb7..569022b7 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -19,6 +19,7 @@ Changed * Standardized parameter names. Reduced the freedom in choosing parameter names and dimension names in favor of simplifying the code. * Requiring netcdf4 >= 1.6.4 * Optional dependencies of xarray that improve performance are now required by default. +* variance_stokes_linear() does not default through zero anymore. * Flox included in requirements to speed up resampling via xarray ([Xarray #5734](https://github.com/pydata/xarray/pull/5734)). Removed diff --git a/src/dtscalibration/datastore.py b/src/dtscalibration/datastore.py index f156461c..bad8c89b 100644 --- a/src/dtscalibration/datastore.py +++ b/src/dtscalibration/datastore.py @@ -1305,7 +1305,7 @@ def variance_stokes_exponential( return var_I, resid_da def variance_stokes_linear( - self, st_label, sections=None, nbin=50, through_zero=True, plot_fit=False + self, st_label, sections=None, nbin=50, through_zero=False, plot_fit=False ): """ Approximate the variance of the noise in Stokes intensity measurements @@ -1457,6 +1457,7 @@ def variance_stokes_linear( # VAR(Stokes) = slope * Stokes offset = 0.0 slope = np.linalg.lstsq(st_sort_mean[:, None], st_sort_var, rcond=None)[0] + else: # VAR(Stokes) = slope * Stokes + offset slope, offset = np.linalg.lstsq( @@ -1472,7 +1473,9 @@ def variance_stokes_linear( f"not possible. Most likely, your {st_label} do " f"not vary enough to fit a linear curve. Either " f"use `through_zero` option or use " - f"`ds.variance_stokes_constant()`" + f"`ds.variance_stokes_constant()`. Another reason " + f"could be that your sections are defined to be " + f"wider than they actually are." ) def var_fun(stokes):