Moment Magnitude (Mw) Calculating

I have sac data and XML files for my broadband seismic stations. I tried to write a script to calculate the moment magnitude (Mw) using Obspy, but I could not. I reviewed the tutorial, but I did not find anything that could help me.
Can anyone help me with that, please?

I think in the ObsPy tutorial we have only material on how to calculate the local magnitude.

There are a multitude of different methods for calculating the moment magnitude. Moment tensor inversion (e.g. Grond), spectral analysis, using the envelope, etc.

Here you can find some code comparing the three mentioned methods.