Quakeml remove picks from event

I have a quakeml catalog where the picks in some events have no phase_hint. This causes trouble in eqcorrscan. I would like to check the picks for each event and remove any that are missing the phase_hint. I don’t know how to do this and I see that someone else asked this question a few years ago - but never posted a solution.
So I’m asking again.

You may just need to have some sort input filter with a try/except; something along these lines. That way, if there is an exception thrown (e.g. there is no phase_hint!), your program will just move on to the next pick.

for pick in picks:
    phase = pick.phase_hint

Not a bad idea, but that means I’d skip processing the event and there may be 10 “good” picks and just this one pick with no phase_hint. So removing the pick from the list is best.

This actually should just continue to the next pick and skip the ones that don’t have any information. The ‘continue’ in the loop will start at the next pick and run the try/except check again. I hope that makes sense.

The way I would try to do this is to create a new list of the picks that contain phase_hints:

for event in cat:
    event.picks = [p for p in event.picks if pick.phase_hint]

Ah, that takes care of the problem where the missing phase_hint causes an exception inside of a package (eqcorrscan) that I cannot update. Thanks Calum!