mspass-team / mspass

Massive Parallel Analysis System for Seismologists
https://mspass.org
BSD 3-Clause "New" or "Revised" License
28 stars 11 forks source link

SeismicPlotter does not handle dead data properly #543

Open pavlis opened 1 month ago

pavlis commented 1 month ago

I discovered SeismicPlotter is not as robust as a it needs to be. It does not appear to be handling data marked dead well - at least for ensembles. Haven't looked what it does with atomic data. What it should do with ensembles is not a given. We should probably adopt the reflection processing model where dead data are displayed as a line by setting all the sample values to 0. In any case, when I try to plot an ensemble with a mix of live and dead data it throws an exception with this as the base of the exception chain:

File [/opt/conda/lib/python3.10/site-packages/mspasspy/graphics.py:915](http://127.0.0.1:8888/opt/conda/lib/python3.10/site-packages/mspasspy/graphics.py#line=914), in SeismicPlotter._get_ensemble_size(self, d)
    912 # this is no doubt a faster vector way to do this calculation, but
    913 # this loop is guaranteed by screen limits to never be huge
    914 for i in range(ndata):
--> 915     dt = endtimes[i] - t0[i]
    916     maxdt = max(maxdt, dt)
    917 if maxdt/(tmax - tmin) < self._RANGE_RATIO_TEST:

IndexError: list index out of range

This is not a critical error as it is easily solved with the Undertaker method bring_out_your_dead but it is definitely a blemish.

To be clear to any user who reads this an get this error the solution is:

# ensemble is what needs the repair
undertaker = Undertaker(db)   # db is a Database instance
[ensemble,bodies] = undertaker.bring_out_your_dead(ensemble)

That overwrites ensemble with a clean version with no dead members.