mzechmeister / GLS

Generalised Lomb-Scargle periodogram
MIT License
35 stars 5 forks source link

Issue variable definition in Javascript version #24

Open avazquezgit opened 6 months ago

avazquezgit commented 6 months ago

Variables Abest, Bbest and Cbest.

Uncaught ReferenceError: Abest is not defined at GLS (gls.js:104:34) at runGLS (gls.html?run:85:10) at loaddata (gls.html?run:78:4) at FileReader.loadHandler (read-csv.js:55:4)

mzechmeister commented 6 months ago

Hi,

Indeed, Abest is only defined, if it goes through here: https://github.com/mzechmeister/GLS/blob/e6fbf7a0e9e31f00063b8dad0956f3ed7f3c2d0d/javascript/gls.js#L102

I can reproduce the error when passing a file with content

0 1
1 foo

foo is a string and float parsing converts it to a NaN. image

NaN data values will lead to NaN power values p. Thus the if condition will never become true.

@avazquezgit Is such an invalid data format the case for you?

[The error only occurs, when running the code the first the time on invalid data. If a valid data set was processed before, Abest (as yet a global variable) it is already defined, but contains a misleading values.]