mireianievas / PySQM

Python client for the Sky Quality Meter
https://guaix.fis.ucm.es/splpr/SQM-REECL
GNU General Public License v3.0
4 stars 12 forks source link

No plot - ephem.AlwaysUpError #8

Closed Tartouffe closed 2 years ago

Tartouffe commented 2 years ago

Got since 9th of June an error and -no- graph files anymore. The datafiles are okay and contain the SQM values, as usual.

The Error at the cronlog:

Plotting photometer data ... Warning: Error plotting data. (<class 'ephem.AlwaysUpError'>, AlwaysUpError("'Sun' is above the horizon at 2022/6/9 23:25:56",), <traceback object at 0xb498dc88>) .........................350 2022-06-11T02:01:14.000;2022-06-11T04:01:14.000;15.34;45188.800;10.213;17.392 .........................355 2022-06-11T02:04:44.000;2022-06-11T04:04:44.000;15.16;28115.000;16.411;16.877 .........................360 2022-06-11T02:08:14.000;2022-06-11T04:08:14.000;15.10;23277.200;19.843;16.674 Plotting photometer data ... Warning: Error plotting data. (<class 'ephem.AlwaysUpError'>, AlwaysUpError("'Sun' is above the horizon at 2022/6/9 23:25:56",), <traceback object at 0xb498dee0>) .........................365 2022-06-11T02:11:45.000;2022-06-11T04:11:45.000;15.10;21047.000;21.848;16.558 .........................370 2022-06-11T02:15:15.000;2022-06-11T04:15:15.000;15.10;13672.000;33.600;16.094 .........................375 2022-06-11T02:18:46.000;2022-06-11T04:18:46.000;15.10;9478.800;48.800;15.695

The files an the pi were untouched since months (yes, rebooted several times), so some file modification can't be an issue.

i think its because there is no night anymore (location coordinates around 51° N).

My knowledge of the code and python itself is very limited ... but it must be somewhere at file plot.py, around line 260 after 'Sun = ephem.Sun(Ephem.Observatory)' .

Can the ephem error(s) being catched by the following construct:

try: [something] except (ephem.AlwaysUpError, ephem.NeverUpError): pass

It should be catched (or the not-set variable filled with standard value), that on those dates without a true night a plot is being created. The Values are complete present, only the graph is missing on these days.

:)

mireianievas commented 2 years ago

That makes sense,

Could you do some tests and make a pull request? I would be happy to merge it.

Mireia

Tartouffe commented 2 years ago

I will try my luck, but as i mentioned i newer programmed python! I understand the logic (Basic / Pascal / Delphi and PHP programmer) and being able to find the main cause or the nearby place at the code. But i think i will not being able to fix this the right way.

Only found this 'try / except' code snipped while searching for the meaning of the error, why i got no plots anymore.

Have no clue which variable i should fill (if needed?) when it happended. I think without a 'try .. except' ephem produces a full exit, instead of continuing, because its more a notification than an error...

jscheidtmann commented 2 years ago

See try/except here: https://github.com/jscheidtmann/PySQM/blob/master/pysqm/plot.py#L125 As I don't have a SQM, this is only half of a merge request, as the plot code will likely not be happy, not having the variables in there set.

jscheidtmann commented 2 years ago

@mireianievas Can put that in a pull request, if you want.

Tartouffe commented 2 years ago

Not yet finally solved, now we got this:

Plotting photometer data ... Warning: Error plotting data. (<type 'exceptions.AttributeError'>, AttributeError("'Ephemerids' object has no attribute 'twilight_prev_set'",), <traceback object at 0xb4a35850>)

jscheidtmann commented 2 years ago

Created pull request #9.

Tartouffe commented 2 years ago

It's being tough, now we got this (or do i have to follow that #9 pull request?):

Warning: Error plotting data. (<type 'exceptions.AttributeError'>, AttributeError("'list' object has no attribute 'ndim'",), <traceback object at 0xb4bc20d0>)