Click here
to download this notebook.
[1]:
from casys import (
AxeParams,
CasysPlot,
DataParams,
DateHandler,
Field,
NadirData,
PlotParams,
RangeEvent,
SimpleEvent,
TextParams,
)
NadirData.enable_loginfo()
How to merge plots
Several graphics can be displayed on the same plot [doc].
The following example illustrates how it can be done.
Merging two along track data, showing passes next to each other
[4]:
plot_par = PlotParams(
fig_width=5.5,
fig_height=6.8,
color_limits=(0, 17),
x_limits=(100, 120),
y_limits=(0, 20),
color_bar=False,
color_map="autumn",
grid=True,
)
pass_77 = (
DateHandler.from_orf("C_J3", 122, 77, pos="first"),
DateHandler.from_orf("C_J3", 122, 77, pos="last"),
)
pass_153 = (
DateHandler.from_orf("C_J3", 122, 153, pos="first"),
DateHandler.from_orf("C_J3", 122, 153, pos="last"),
)
sig0_plot_77 = CasysPlot(
data=ad,
data_name="Sigma 0",
plot="map",
plot_params=plot_par,
data_params=DataParams(time_limits=pass_77),
text_params=TextParams(legend=f"Sigma 0 (P77)"),
)
sig0_plot_153 = CasysPlot(
data=ad,
data_name="Sigma 0",
plot="map",
plot_params=plot_par,
data_params=DataParams(time_limits=pass_153),
text_params=TextParams(legend=f"Sigma 0 (P153)"),
)
# Adding stats for each plot
sig0_plot_77.add_stat_bar()
sig0_plot_153.add_stat_bar()
# Merging plots
sig0_plot_77.add_color_bar()
sig0_plot_77.add_plot(sig0_plot_153)
sig0_plot_77.show()
[4]:

Merging two along track data, showing two fields on the same pass along each other
[5]:
pass_77 = (
DateHandler.from_orf("C_J3", 122, 77, pos="first"),
DateHandler.from_orf("C_J3", 122, 77, pos="last"),
)
sig0_plot_par = PlotParams(
fig_width=5.5,
fig_height=8,
x_limits=(80, 110),
y_limits=(-50, 20),
color_limits=(0, 17),
color_map="autumn",
color_bar=AxeParams(position="right"),
grid=True,
)
sig0_77_plot = CasysPlot(
data=ad,
data_name="Sigma 0",
plot="map",
plot_params=sig0_plot_par,
data_params=DataParams(time_limits=pass_77),
)
sla_plot_par = PlotParams(color_limits=(-4, -1), color_bar=AxeParams(position="right"))
sla_77_plot = CasysPlot(
data=ad,
data_name="SLA",
plot="map",
plot_params=sla_plot_par,
data_params=DataParams(time_limits=pass_77),
)
# Adjusting sla plot longitudes so they do not overlap each other.
sla_77_plot.adjust_coordinates(longitude=1)
# Adding statistics
sla_77_plot.add_stat_bar()
sig0_77_plot.add_stat_bar()
# Merging plots
sig0_77_plot.add_plot(sla_77_plot)
sig0_77_plot.show()
[5]:

Merging along time statistics with binned statistic
[6]:
wtcrad_pass_plot = CasysPlot(
data=ad,
data_name="Rad WTC pass",
stat="mean",
plot_params=PlotParams(
fig_width=10,
fig_height=8,
y_limits=(-0.25, 0.25),
line_style="-",
marker_style=".",
marker_size=6,
),
)
wtcrad_pass_plot.add_stat_bar(position="top")
wtcmod_pass_plot = CasysPlot(data=ad, data_name="Model WTC pass", stat="mean")
wtcmod_pass_plot.add_stat_bar(position="top")
rangestd_fctSWH_plot = CasysPlot(
data=ad,
data_name="Ku-band range std fct swh",
stat="mean",
plot_params=PlotParams(x_limits=(2, 6)),
)
rangestd_fctSWH_plot.add_event(SimpleEvent(start=3.2))
rangestd_fctSWH_plot.add_stat_bar(position="top")
sigday_mean_plot = CasysPlot(
data=ad,
data_name="SIG0 day",
stat="mean",
plot_params=PlotParams(y_limits=(13, 14.5)),
)
sigday_mean_plot.add_event(
RangeEvent(
start=DateHandler("2019/06/04"),
end=DateHandler("2019/06/06"),
params={"alpha": 0.2},
)
)
wtcrad_pass_plot.add_plot(wtcmod_pass_plot)
wtcrad_pass_plot.add_plot(sigday_mean_plot, shared_ax="x")
wtcrad_pass_plot.add_plot(rangestd_fctSWH_plot, shared_ax="y")
wtcrad_pass_plot.set_ticks(fmt="CP")
wtcrad_pass_plot.show()
[6]:
