-
Notifications
You must be signed in to change notification settings - Fork 0
plotmpl
Bo Chen edited this page Jul 8, 2023
·
4 revisions
This code consists of functions for lidar data analysis and visualization. It includes functionalities for reading lidar data, calculating derived products, and plotting 2D timeseries.
plot_mpl_2d_timeseries(mpl_datetime, mpl_range_edges, mpl_2d_data, fig=None, ax=None, range_max=20, vmin=0, vmax=1, colorbar_bool=True, tick_number=None)
Plots a 2D timeseries of lidar data.
Parameters:
-
mpl_datetime: Array ofnp.datetime64objects representing the timestamps. -
mpl_range_edges: Array of lidar range values. Height of the bottom and top of each bin instead of the average height of the bin. -
mpl_2d_data: 2D array of lidar data. -
fig(optional): Existing figure object for plotting. -
ax(optional): Existing axes object for plotting. -
range_max(optional): Maximum range in km to plot on the y-axis. -
vmin(optional): Minimum value for the colormap normalization. -
vmax(optional): Maximum value for the colormap normalization. -
colorbar_bool(optional): Boolean value to enable/disable the colorbar. -
tick_number(optional): Number of ticks and labels to use on the x-axis.
Returns:
- None (The function directly modifies the provided
figandaxobjects for plotting.)
Utility function to handle the creation of a figure and axes for plotting.
Parameters:
-
fig(optional): Existing figure object. -
ax(optional): Existing axes object.
Returns:
-
fig: Updated figure object. -
ax: Updated axes object.
Helper function to format an array of datetime objects.
Parameters:
-
datetime_arr: Array ofdatetimeobjects representing timestamps.
Returns:
-
formatted_arr: Array of formatted strings representing the formatted dates and times.
Here's an example usage of the plot_mpl_2d_timeseries function:
from pympl import PyMPL
import plotmpl
import matplotlib.pyplot as plt
mpl_file_path = '/path/to/mpl data folder'
ap_file_path = '/path/to/afterpulse file.bin'
ov_file_path = '/path/to/overlap file.bin'
dt_file_path = '/path/to/deadtime file.bin'
mpl_object = PyMPL(mpl_file_path, ap_file_path, ov_file_path, dt_file_path)
fig1, ax1 = plt.subplots(nrows=1, ncols=1, figsize=(12,4))
plotmpl.plot_mpl_2d_timeseries(mpl_object.datetime, mpl_object.range_edges, mpl_object.nrb_copol, fig=fig1, ax=ax1, range_max = 3)