[ncl-talk] Can't use exponential_curve_fit

Giorgio Graffino g.graffino at tim.it
Wed Sep 8 04:06:12 MDT 2021


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 at _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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210908/fb045105/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: HadCM3_plot_pycnoclinedepth_uni4co2.000001.png
Type: image/png
Size: 73226 bytes
Desc: not available
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210908/fb045105/attachment.png>


More information about the ncl-talk mailing list