[ncl-talk] Can't use exponential_curve_fit

Dennis Shea shea at ucar.edu
Wed Sep 8 17:28:03 MDT 2021


I created  the function. based upon a  Matlab function.  Also, the
documentation .
--------------------------------
As noted, the function follows the approach described by Eric Weisstein:
       *Least Squares Fitting--Exponential*
<http://mathworld.wolfram.com/LeastSquaresFittingExponential.html>:
MathWorld--A Wolfram Web Resource
-------------------------------
There is an error in the documentation. Missing values (_FillValue) are not
allowed ...
and, (of course) values <= to 0.0 Within the next day or two, I will look
at the issue(s) offline.

D





On Wed, Sep 8, 2021 at 4:06 AM Giorgio Graffino via ncl-talk <
ncl-talk at mailman.ucar.edu> wrote:

> Dear NCL folks,
>
>
> I'm using exponential_curve_fit on NCL 6.6.2 to fit vertical density
> profiles all over the global domain. I thought it was an esay task, but
> it's turning out to be harder than expected.
>
>
> First, despite what said in the documentation page (
> https://www.ncl.ucar.edu/Document/Functions/Contributed/exponential_curve_fit.shtml),
> the function doesn't handle missing values. I created a new function exponential_curve_fit_FillValue
> by simply commenting out the relevant part from the original function and
> make it return the y = A*exp(B*x) array.
>
>
> Second, I'm trying to get the exponential fit of each vertical vertical
> density profile over the global domain. So I'm looping over all longitudes,
> latitudes, and time steps to compute the fit of density (ctrl_dens) over
> depth (levs). However, the resulting fit doesn't look like fitting the
> profile very much (see the globally-averaged profiles on the attached
> plot). See below the relevant bit of code.
>
>
> ctrl_densexpfit = new(dimsizes(ctrl_dens),typeof(ctrl_dens),ctrl_dens@
> _FillValue)
>
> do i = 0, nlon-1
>
> do j = 0, nlat-1
>
> do l = 0, ntim-1
>
> ctrl_densexpfit(l,:,j,i) =
> exponential_curve_fit_FillValue(tofloat(levs),ctrl_dens(l,:,j,i),0,False)
>
> end do
>
> end do
>
> end do
>
>
> Can you please help me on this? Is there anything I'm doing wrong or
> missing?
>
>
> Cheers,
>
> Giorgio
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at mailman.ucar.edu
> List instructions, subscriber options, unsubscribe:
> https://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210908/edebb69d/attachment.html>


More information about the ncl-talk mailing list