forked from open-atmos/PySDM
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspectrum_plotter.py
More file actions
33 lines (28 loc) · 1.08 KB
/
Copy pathspectrum_plotter.py
File metadata and controls
33 lines (28 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from matplotlib import pyplot
from open_atmos_jupyter_utils import show_plot
from PySDM_examples.Shima_et_al_2009.spectrum_plotter import (
SpectrumPlotter as SuperSpectrumPlotter,
)
class SpectrumPlotter(SuperSpectrumPlotter):
def __init__(self, settings, title=None, grid=True, legend=False):
size = 2 * 5.236
pyplot.figure(figsize=(size, size * 0.54))
pyplot.xlabel("particle radius [µm]")
pyplot.ylabel("dm/dlnr [g/m^3/(unit dr/r)]")
super().__init__(settings, title=title, grid=grid, legend=legend, log_base=2)
self.color = None
self.smooth = True
@staticmethod
def ticks():
xticks = [4, 6.25, 12.5, 25, 50, 100, 200]
pyplot.xticks(xticks, xticks)
pyplot.yticks([0.5 * i for i in range(5)], [0, None, 1, None, 2])
def show(self):
self.finish()
self.ticks()
show_plot()
def plot(
self, spectrum, t, label=None, color=None, title=None, add_error_to_label=False
):
settings = self.settings
self.plot_data(settings, t, spectrum, label, color)