How to use the metview.png_output function in metview

To help you get started, we’ve selected a few metview examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github esowc / ecPoint-Calibrate / core / postprocessors / conditional_verification.py View on Github external
def plot_geo(geo, coastline, symbol, legend, title):
    with NamedTemporaryFile(suffix=".png") as png, NamedTemporaryFile(
        delete=False, suffix=".pdf"
    ) as pdf:
        png_obj = mv.png_output(output_name=png.name.replace(".png", ""))
        mv.setoutput(png_obj)
        mv.plot(coastline, symbol, legend, title, geo)

        pdf_obj = mv.pdf_output(output_name=pdf.name.replace(".pdf", ""))
        mv.setoutput(pdf_obj)
        mv.plot(coastline, symbol, legend, title, geo)
        os.chmod(pdf.name, 0o444)

        with open(png.name.replace(".png", ".1.png"), "rb") as img:
            return {"preview": b64encode(img.read()).decode(), "pdf": pdf.name}