Coastal-Imaging-Research-Network / cBathy-Toolbox

Routines needed to run cBathy + demos
https://github.com/Coastal-Imaging-Research-Network/cBathy-toolbox/wiki/cBathy-User-Manual
GNU General Public License v3.0
25 stars 23 forks source link

LMFnlsq.m fails #47

Open RobHolman opened 6 years ago

RobHolman commented 6 years ago

Diana Di Leonardo struggled with run times (and some other problems) using the new LMFnlsq routine. In fact, she found an infinite loop when supplied with bad inputs. This would not be caught in the try-catch. She also implies that other changes were needed. She sent the following to me by email: @mpalmsten,@katebrodie, @SRHarrison

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% As we discussed, I found an infinite while loop in the non-linfit version of cBathy.

I had to make a few changes to the supporting codes to make it all work without the statistics toolbox.

csmInverstKAlpha comment out line 44 and line 112 bathyFromKAlpha comment out line 14

These are all references to statset.

bathyCI line 40 changes from ~isempty to isempty à this seems like it might be a typo

For xm 590 and ym 450, there is an infinite while loop inside LMFnlsq.m The while loop starts at line 324 and seems to be caused by having a kAlphaInit input of [NaN NaN NaN]. When I reset this input to values form a successful point, the while loop terminated correctly.

I’m happy to try more things and might continue to poke around.

Best, Diana

RobHolman commented 6 years ago

@jstanleyx @mpalmsten @KateBrodie @SRHarrison. Diana sent me this issue only because I was sitting next to her at the boot camp as she struggled with what eventually turns out to be an infinite loop in the new LMFnlsq.m code. I looked quickly at the routine in the area of the while loop starting at line 324 and it seems like ugly coding to me (lots of "while 1" then break out of loops) and obviously it isn't robust to odd inputs, the stuff that matlab handles carefully. It feels like the best choice is to put QC somewhere earlier. This isn't an area of strength or interest to me. Any volunteers?