def _pix2coord_factory(geodata, ref_shape):
    """
    Construct the pix2coord transformation function."""
    if geodata is not None:

        def pix2coord(x_input, y_input):
            x = geodata["x1"] + geodata["xpixelsize"] * x_input
            if geodata["yorigin"] == "lower":
                y = geodata["y1"] + geodata["ypixelsize"] * y_input
            else:
                y = geodata["y2"] - geodata["ypixelsize"] * y_input
            return x, y

    else:
        if ref_shape is None:
            raise ValueError("'ref_shape' can't be None when not geodata is available.")

        # Default pix2coord function when no geographical information is present.
        def pix2coord(x_input, y_input):
            # yorigin is "upper" by default
            return x_input, ref_shape[0] - y_input

    return pix2coord
Construct the pix2coord transformation function.
pysteps/visualization/thunderstorms.py