These functions already exist in https://github.com/gem/oq-engine/blob/master/openquake/calculators/hazard/classical/post_processing.py#L468. As far as I can tell, they are identical.

This looks like something which we could move the oq-commons lib (whenever we get around to creating it).