<p style="font-size: 12pt; font-family: Arial;">Dear NCL folks,</p><p style="font-size: 12pt; font-family: Arial;"><br></p><p style="font-size: 12pt; font-family: Arial;">I'm using e<span style="color: inherit; font-size: 12pt; font-family: Arial;">xponential_curve_fit on </span><span style="font-family: arial, sans-serif; font-size: 12pt;">NCL 6.6.2 </span><span style="color: inherit; font-size: 12pt; font-family: Arial;">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.</span></p><p style="font-size: 12pt; font-family: Arial;"><span style="color: inherit; font-size: 12pt; font-family: Arial;"><br></span></p><p style="font-size: 12pt; font-family: Arial;"><span style="color: inherit; font-size: 12pt; font-family: Arial;">First, despite what said in the documentation page (</span><span style="font-family: arial, sans-serif; font-size: 12pt;">https://www.ncl.ucar.edu/Document/Functions/Contributed/exponential_curve_fit.shtml</span><span style="color: inherit; font-size: 12pt; font-family: Arial;">), the function doesn't handle missing values. I created a new function </span><span style="font-family: arial, sans-serif; font-size: 12pt;">exponential_curve_fit_FillValue by simply commenting out the relevant part from the original function and make it return the </span><span style="font-family: arial, sans-serif; font-size: 12pt;">y = A*exp(B*x) array.</span></p><p style="font-size: 12pt; font-family: Arial;"><span style="font-family: arial, sans-serif; font-size: 12pt;"><br></span></p><p><span style="font-family: Arial; font-size: 12pt;">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 (</span><span style="font-size: 12pt; font-family: Arial;">ctrl_dens</span><span style="font-family: Arial; font-size: 12pt;">) 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.</span></p><p style="font-size: 12pt; font-family: Arial;"><span style="font-family:Arial; font-size: 12pt;"><br></span></p><p><span style="font-family: Arial; font-size: 12pt;">ctrl_densexpfit = new(dimsizes(ctrl_dens),typeof(ctrl_dens),ctrl_dens@_FillValue)</span></p><p><span style="font-family:Arial; font-size: 12pt;">do i = 0, nlon-1</span></p><p><span style="font-family:Arial; font-size: 12pt;">do j = 0, nlat-1</span></p><p><span style="font-family:Arial; font-size: 12pt;">do l = 0, ntim-1</span></p><p><span style="font-family: Arial; font-size: 12pt;"> ctrl_densexpfit(l,:,j,i) = exponential_curve_fit_FillValue(tofloat(levs),ctrl_dens(l,:,j,i),0,False)</span><br></p><p><span style="font-family:Arial; font-size: 12pt;">end do</span></p><p><span style="font-family:Arial; font-size: 12pt;">end do</span></p><p><span style="font-family:Arial; font-size: 12pt;">end do</span></p><p style="font-size: 12pt; font-family: Arial;"><span style="font-family:Arial; font-size: 12pt;"><br></span></p><p style="font-size: 12pt; font-family: Arial;"><span style="font-family:Arial; font-size: 12pt;">Can you please help me on this? Is there anything I'm doing wrong or missing?</span></p><p style="font-size: 12pt; font-family: Arial;"><span style="font-family:Arial; font-size: 12pt;"><br></span></p><p style="font-size: 12pt; font-family: Arial;"><span style="font-family:Arial; font-size: 12pt;">Cheers,</span></p><p style="font-size: 12pt; font-family: Arial;"><span style="font-family:Arial; font-size: 12pt;">Giorgio</span></p>