Exporting an Image with Butler

Is there a command in butler that I can use to export a plot or save it in anyway? Any information would be extremely helpful. Thank you!

matplotlib Plots are stored as PNG files – you can’t butler.get one because there is no way to reconstruct the matplotlib plot object from the PNG.

What you can do though is call butler.getURI and that would give you a lsst.daf.butler.ButlerURI object which gives you full access to the binary data. You can uri.read() it into memory as a binary PNG and display that using PIL and display(), or target_uri.transfer_from(uri) to retrieve it as a local file.

You can do a “bulk” download to local disk space using Butler.retrieveArtifacts or butler retrieve-artifacts command-line.

And just in case this thread is being read by any new-to-python delegates: matplotlib.pyplot.savefig('mypath/myplotname') is an easy way to save a copy of the figure you made. I just realized that I don’t think we provided any examples of saving figures in our notebooks, only showing them.

2 Likes