The MJO phase diagram illustrates its progression through phases, coinciding with locations along the equator around the globe. This can also illustrate its intensity.
Future posts will elaborate on parts of this recipe.
#python #atmosci
import pandas as pd import hvplot.pandas import holoviews as hv from bokeh.models import FixedTicker hv.extension("bokeh") # load data url = "https://ds.data.jma.go.jp/tcc/tcc/products/clisys/mjo/figs/olr0-sst1_1980-2010/rmm8.csv" df = pd.read_csv(url) # clean up columns df.columns = df.columns.str.strip() # add datetime to subset df.index = pd.to_datetime({"year": df["#year"], "month": df["month"], "day": df["day"]}) df["date"] = df.index df = df.loc[df.index > "2023"] # format plots ini = df.iloc[0]["date"].strftime("%b %d, %Y") end = df.iloc[0]["date"].strftime("%b %d, %Y") plot_opts = dict( xlim=(-4, 4), ylim=(-4, 4), frame_width=800, frame_height=800, line_width=1.8, colorbar=True, clabel="Month", cmap="RdYlBu_r", color_levels=len(df["month"].unique()) - 1, title=f"MJO RMM phase space from {ini} to {end}\nData: {url}", colorbar_opts={ "ticker": FixedTicker(ticks=sorted(df["month"].unique())), "major_label_overrides": { 1: "Jan", 2: "Feb", 3: "Mar", 4: "Apr", 5: "May", 6: "Jun", 7: "Jul", 8: "Aug", 9: "Sep", 10: "Oct", 11: "Nov", 12: "Dec", }, }, ) # actually plot rmm_line = df.hvplot.paths( x="RMM1", y="RMM2", color="month" ).opts(**plot_opts) rmm_scatter = df.hvplot.scatter( "RMM1", "RMM2", color="black", groupby="date", size=50 ) rmm_plot = rmm_line * rmm_scatter # add start and end date rmm_plot *= hv.Text(*df.iloc[0][["RMM1", "RMM2"]], text="START", valign="bottom") rmm_plot *= hv.Text(*df.iloc[-1][["RMM1", "RMM2"]], text="END", valign="bottom") # add phase labels rmm_plot *= hv.Text(-3.5, -1.5, text="1") rmm_plot *= hv.Text(-1.5, -3.5, text="2") rmm_plot *= hv.Text(1.5, -3.5, text="3") rmm_plot *= hv.Text(3.5, -1.5, text="4") rmm_plot *= hv.Text(3.5, 1.5, text="5") rmm_plot *= hv.Text(1.5, 3.5, text="6") rmm_plot *= hv.Text(-1.5, 3.5, text="7") rmm_plot *= hv.Text(-3.5, 1.5, text="8") # add region labels rmm_plot *= hv.Text(0, 4, text="Western\nPacific", valign="top") rmm_plot *= hv.Text( 4, 0, text="Maritime\nContinent", valign="top", rotation=270) rmm_plot *= hv.Text(0, -4, text="Indian\nOcean", valign="bottom") rmm_plot *= hv.Text( -4, 0, text="West Hem.\nand Africa", valign="top", rotation=90) # add reference lines ref_opts = dict(color="black", line_width=0.5, alpha=0.5, line_dash="dashed") rmm_plot *= hv.Slope(1, 0).opts(**ref_opts) rmm_plot *= hv.Slope(-1, 0).opts(**ref_opts) rmm_plot *= hv.VLine(0).opts(**ref_opts) rmm_plot *= hv.HLine(0).opts(**ref_opts) rmm_plot *= hv.Ellipse(0, 0, (1, 1)).opts(**ref_opts) hv.save(rmm_plot, "output.html")
Share this post
R5. Want to create a MJO phase diagram?
Share this post
The MJO phase diagram illustrates its progression through phases, coinciding with locations along the equator around the globe. This can also illustrate its intensity.
Future posts will elaborate on parts of this recipe.
#python #atmosci