Top_EMAC_Eyja_Tracer

../../_images/Top_EMAC_Eyja_Tracer-3.0sigmait2012_10_17_12_00_00vt2012_10_18_00_00_00.png

How to use this plot

Make sure you have the required datafields (emac_R12)

You can use it as is by appending this code into your mswms_settings.py:

from mslib.mswms.mpl_hsec_styles import HS_EMAC_TracerStyle_ML_01
register_horizontal_layers = [] if not register_horizontal_layers else register_horizontal_layers
register_horizontal_layers.append((HS_EMAC_TracerStyle_ML_01, [next(iter(data))]))

If you want to modify the plot

  1. Download this file

  2. Put this file into your mswms_settings.py directory, e.g. ~/mss

  3. Append this code into your mswms_settings.py:

from Top_EMAC_Eyja_Tracer import HS_EMAC_TracerStyle_ML_01
register_horizontal_layers = [] if not register_horizontal_layers else register_horizontal_layers
register_horizontal_layers.append((HS_EMAC_TracerStyle_ML_01, [next(iter(data))]))
Plot Code
"""
    This file is part of MSS.

    :copyright: Copyright 2021-2023 by the MSS team, see AUTHORS.
    :license: APACHE-2.0, see LICENSE for details.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
"""

import logging
import warnings
import numpy as np
import matplotlib.pyplot as plt
import mpl_toolkits.axes_grid1.inset_locator
import matplotlib.colors
import mpl_toolkits.basemap
from matplotlib import patheffects
from mslib.mswms.mpl_hsec import MPLBasemapHorizontalSectionStyle
from mslib.mswms.utils import get_cbar_label_format, make_cbar_labels_readable
import mslib.mswms.generics as generics
from mslib.utils import thermolib
from mslib.utils.units import convert_to

class HS_EMAC_TracerStyle_ML_01(MPLBasemapHorizontalSectionStyle):
    """
    Upper Air Field: EMAC Tracer
    """
    name = "EMAC_Eyja_Tracer"
    title = "EMAC Eyjafjallajokull Tracer (Model Level) (relative)"

    # Variables with the highest number of dimensions first (otherwise
    # MFDatasetCommonDims will throw an exception)!
    required_datafields = [
        ("ml", "emac_R12", 'dimensionless')]

    def _plot_style(self):
        """
        """
        bm = self.bm
        ax = self.bm.ax
        data = self.data

        tracer = data["emac_R12"] * 1.e4

        # Shift lat/lon grid for PCOLOR (see comments in HS_EMAC_TracerStyle_SFC_01).
        tc = bm.pcolormesh(self.lonmesh, self.latmesh, tracer,
                           cmap=plt.cm.inferno_r,
                           norm=matplotlib.colors.LogNorm(vmin=1., vmax=100.),
                           shading='nearest', edgecolors='none')

        ac = bm.contour(self.lonmesh, self.latmesh, tracer,
                        np.arange(1, 101, 1)[::2],
                        colors="b", linewidths=1)
        ax.clabel(ac, fontsize=10, fmt='%.0f')

        self.add_colorbar(tc, "Tracer (relative)")

        titlestring = f"EMAC Eyjafjallajokull Tracer (relative) at model level {self.level:.0f}"
        titlestring += f'\nValid: {self.valid_time.strftime("%a %Y-%m-%d %H:%M UTC")}'
        if self.uses_inittime_dimension():
            time_step = self.valid_time - self.init_time
            time_step_hrs = (time_step.days * 86400 + time_step.seconds) // 3600
            titlestring += f' (step {time_step_hrs:d} hrs from {self.init_time.strftime("%a %Y-%m-%d %H:%M UTC")})'

        if not self.noframe:
            ax.set_title(titlestring,
                         horizontalalignment='left', x=0, fontsize=14)
        else:
            ax.text(bm.llcrnrx, bm.llcrnry, titlestring,
                    fontsize=10, bbox=dict(facecolor='white', alpha=0.6))