def test_get_available_styles(self): """Check matplotlib stylesheet paths. This test checks the consinstency of the in and outputs of styles() and get_available_styles(). """ style_paths = [plots.styles(s) for s in plots.get_available_styles()] assert all(os.path.isfile(s) for s in style_paths)
def main(): # Define parameters species = "N2O" temperature = 300 pressure = 800e2 # Call ARTS to calculate absorption cross sections freq, abs_xsec = calculate_absxsec(species, pressure, temperature) # Plot the results. plt.style.use(styles("typhon")) fig, ax = plt.subplots() ax.plot(freq / 1e9, abs_xsec) ax.set_xlim(freq.min() / 1e9, freq.max() / 1e9) ax.set_ylim(bottom=0) ax.set_xlabel("Frequency [GHz]") ax.set_ylabel(r"Abs. cross section [$\sf m^2$]") ax.set_title( f"{tag2tex(species)} p:{pressure/100} hPa T:{temperature:0.0f} K") fig.savefig( # Save figure. f"plots/plot_xsec_{species}_{pressure:.0f}Pa_{temperature:.0f}K.pdf") plt.show() # Open an interactive figure
os.environ["ARTS_BUILD_PATH"] = "/scratch/uni/u237/users/jmrziglod/arts_general/arts/build" # noqa import numpy as np import matplotlib.pyplot as plt import pandas as pd from sklearn.model_selection import train_test_split from typhon.files import CloudSat, FileSet, NetCDF4 from typhon.plots import binned_statistic, heatmap, styles from typhon.retrieval import SPAREICE from typhon.utils import Timer, to_array from scipy.stats import binned_statistic from typhon.collocations import Collocations from typhon.geographical import gridded_mean import xarray as xr plt.style.use(styles('typhon')) experiment = "no_sea_mask" processes = 10 plot_all = False train = False zonal_mean = False balance_scnpos = False start = "2008" end = "2009" # We need to train two retrievals: an ice cloud classifier and an IWP regressor ice_cloud_fields = [ 'mhs_channel2', 'mhs_channel3', 'mhs_channel4',
# -*- coding: utf-8 -*- """Evluate the influence of the elevation angle when simulating incoming longwave radiation. """ import numpy as np import matplotlib.pyplot as plt import clb from typhon.arts import xml from typhon.plots import styles f = xml.load('../arts/results/angle_integration/f_grid.xml') y_los = xml.load('../arts/results/angle_integration/y.xml') los = xml.load('../arts/results/angle_integration/sensor_los.xml') plt.style.use(styles('typhon')) lwr_new = clb.math.integrate_angles(f, y_los, los, dtheta=15) fig, ax = plt.subplots() for y, a in zip(np.split(y_los, los.size), los): ax.plot(f/1e12, y, label='${}^\circ$'.format(int(a)), linewidth=3, linestyle='-') ax.set_xlim(f.min()/1e12, f.max()/1e12) ax.set_xlabel('Frequenz [THz]') ax.set_ylabel(r'Radianz [$W\,m^{-2}\,sr^{-1}\,Hz^{-1}$]') ax.legend(ncol=2) fig.savefig('plots/lwr_spectrum_elevation.pdf')
def simple_plot(stylename): """Generate a simple plot using a given matplotlib style.""" if stylename == 'typhon-dark': # TODO: Sphinx build is broken for non-white figure facecolor. return x = np.linspace(0, np.pi, 20) fig, ax = plt.subplots() for s in np.linspace(0, np.pi / 2, 12): ax.plot(x, np.sin(x+s), label=r'$\Delta\omega = {:.2f}$'.format(s), marker='.', ) ax.set_ylabel('y-axis') ax.set_xlabel('x-axis') ax.set_title(stylename) ax.grid() ax.legend() # Create plot using default styles. simple_plot('matplotlib 2.0') # Create a plot for each available typhon style. for style_name in styles.available: with plt.style.context(styles(style_name)): simple_plot(style_name) plt.show()
def test_available_styles(self): style_paths = plots.styles.available assert isinstance(style_paths, list) assert len(style_paths) > 0 assert all(os.path.isfile(plots.styles(s)) for s in style_paths)
def test_get_style_path_default(self): assert os.path.isfile(plots.styles())
def test_get_style_path_call(self): assert os.path.isfile(plots.styles('typhon'))