Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generalized get_html_draw for LC #125

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions dispatcher_plugin_nb2workflow/products.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,21 +329,38 @@ def __init__(self,
name=name,
extra_metadata=extra_metadata)

def get_html_draw(self):
unit_ID=1 # TODO: it could be optional
du = self.dispatcher_data_prod.data.data_unit[unit_ID]
def get_html_draw(self, unit_id=None):
if unit_id is None:
unit_id=1
du = self.dispatcher_data_prod.data.data_unit[unit_id]
data, header, units = du.data, du.header, du.units_dict
data_col = data.dtype.names[1]

time_col = None
data_col = None
err_col = None
if len(data.dtype.names) == 3 and data.dtype.names[2].startswith('ERR'):
err_col = data.dtype.names[2]
x_label = f"TIME, {units['TIME']}" if units is not None and 'TIME' in units else 'TIME'
xerr_col = None
for i, name in enumerate(data.dtype.names):
if name.startswith('FLUX') or name.startswith('RATE') or name.startswith('COUNTS'):
data_col = name
elif name.startswith('ERR'):
err_col = name
elif name.startswith('XAX_E') or name.startswith('TIMEDEL'):
xerr_col = name
elif name == 'TIME':
time_col = name

if time_col is None or data_col is None:
raise ValueError(f"Time and data columns not found in {data.dtype.names}")

x_units = getattr(units, time_col, None)
x_label = f"{time_col}, {x_units}" if x_units else time_col
y_units = getattr(units, data_col, None)
y_label = f"{data_col}, {y_units}" if y_units else data_col

im_dic = self.dispatcher_data_prod.get_html_draw(x = data['TIME'],
im_dic = self.dispatcher_data_prod.get_html_draw(x = data[time_col],
y=data[data_col],
dy=data[err_col] if err_col else None,
dx=data[xerr_col] if xerr_col else None,
x_label = x_label,
y_label = y_label
)
Expand Down
Loading