SeisComP3 / seiscomp3

SeisComP is a seismological software for data acquisition, processing, distribution and interactive analysis.
Other
111 stars 88 forks source link

Fix scvsmag.cpp #160

Closed FMassin closed 6 years ago

FMassin commented 6 years ago

Without this fix, scvsmag trash when an origin has no quality.azimuthalGap. I can happen: scanloc preliminary origins don't have quality.azimuthalGap.

gempa-jabe commented 6 years ago

How is vsevent->azGap initialized if it is not populated from the origin quality? I can't find anything.

FMassin commented 6 years ago

I though the line https://github.com/SeisComP3/seiscomp3/blob/54a72de6623ebd3bfedc6e7ef691d070ef3bd9f2/src/sed/apps/scvsmag/scvsmag.h#L102

was somehow enough because it does compile and runs in playback and shows the new debug message I set up...

gempa-jabe commented 6 years ago

Yes, it does compile but the compiler has to initialize azGap somehow when you create a new Event object. Since azGap is not initialized explicitely, it depends on the compiler implementation how the initialization is done. Either populating the memory with zeros or just garbage. It is not deterministic.

It would be good to set a default value in the catch block.

gempa-jabe commented 6 years ago

Can you please squash both commits and prepend [scvsmag] to your commit message, e.g.:

[scvsmag] Catch exception if origin.quality.azimuthalGap is not set
FMassin commented 6 years ago

I was still thinking about using NaN as a default value... would that be accepted?

gempa-jabe commented 6 years ago

I was still thinking about using NaN as a default value... would that be accepted?

Accepted by whom? If the application adds test for such cases then yes. I would otherwise recommend an optional double. You can use that in SC3 easily with:

OPT(double) optionalValue;
if ( optionalValue )
  cerr << *optionalValue << endl;
FMassin commented 6 years ago

Thanks for the advice.

FMassin commented 6 years ago

I cleaned my mess. Can it be merged ?

FMassin commented 6 years ago

Thank you Jan!

gempa-jabe commented 6 years ago

Thanks Fred for the fix and the corrections.

gempa-jabe commented 6 years ago

A semicolon was missing, I added that. Neither of us has compiled the changes ;)

FMassin commented 6 years ago

Sorry, I shouldn't use github's online editor... neither copy and paste !