Skip to content

Commit 1e4046b

Browse files
committed
improve plot_c logic
1 parent 4148e60 commit 1e4046b

1 file changed

Lines changed: 26 additions & 26 deletions

File tree

pyxlma/plot/xlma_plot_feature.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -151,41 +151,41 @@ def plot_2d_network_points(bk_plot, netw_data, actual_height=None, fake_ic_heigh
151151
marker = kwargs.pop('marker', '^')
152152
if actual_height is not None:
153153
netw_data['height'] = actual_height
154+
155+
if plot_c is not None:
156+
netw_data['plot_c'] = plot_c
157+
elif color_by == 'time':
158+
netw_data['plot_c'] = color_by_time(netw_data.datetime, bk_plot.tlim)[2]
159+
elif color_by == 'polarity':
160+
pass
161+
else:
162+
raise ValueError("color_by must be 'time' or 'polarity'")
163+
154164
cgs = netw_data[netw_data['type']=='CG']
155165
ics = netw_data[netw_data['type']=='IC']
166+
156167
if actual_height is None:
157168
cgs['height'] = np.full_like(cgs.longitude, fake_cg_height)
158169
ics['height'] = np.full_like(ics.longitude, fake_ic_height)
159170
art_out = []
160-
if plot_c is None:
161-
if color_by == 'time':
162-
vmin, vmax, plot_c_cg = color_by_time(cgs.datetime, bk_plot.tlim)
163-
art_out.append(plot_points(bk_plot, cgs.longitude, cgs.latitude, cgs.height,
164-
cgs.datetime, c=plot_c_cg, vmin=vmin, vmax=vmax, marker=marker, add_to_histogram=False, **kwargs))
165-
vmin, vmax, plot_c_ic = color_by_time(ics.datetime, bk_plot.tlim)
166-
art_out.append(plot_points(bk_plot, ics.longitude, ics.latitude, ics.height,
167-
ics.datetime, c=plot_c_ic, vmin=vmin, vmax=vmax, marker=marker, add_to_histogram=False, **kwargs))
168-
elif color_by == 'polarity':
169-
cgpos = cgs[cgs.peak_current_kA>0]
170-
cgneg = cgs[cgs.peak_current_kA<0]
171-
icpos = ics[ics.peak_current_kA>0]
172-
icneg = ics[ics.peak_current_kA<0]
173-
art_out.append(plot_points(bk_plot, cgneg.longitude, cgneg.latitude, cgneg.height,
174-
cgneg.datetime, c=neg_color, marker=marker, add_to_histogram=False, **kwargs))
175-
art_out.append(plot_points(bk_plot, cgpos.longitude, cgpos.latitude, cgpos.height,
176-
cgpos.datetime, c=pos_color, marker=marker, add_to_histogram=False, **kwargs))
177-
art_out.append(plot_points(bk_plot, icneg.longitude, icneg.latitude, icneg.height,
178-
icneg.datetime, c=neg_color, marker=marker, add_to_histogram=False, **kwargs))
179-
art_out.append(plot_points(bk_plot, icpos.longitude, icpos.latitude, icpos.height,
180-
icpos.datetime, c=pos_color, marker=marker, add_to_histogram=False, **kwargs))
181-
else:
182-
raise ValueError("color_by must be 'time' or 'polarity'")
171+
if color_by == 'polarity':
172+
cgpos = cgs[cgs.peak_current_kA>0]
173+
cgneg = cgs[cgs.peak_current_kA<0]
174+
icpos = ics[ics.peak_current_kA>0]
175+
icneg = ics[ics.peak_current_kA<0]
176+
art_out.append(plot_points(bk_plot, cgneg.longitude, cgneg.latitude, cgneg.height,
177+
cgneg.datetime, c=neg_color, marker=marker, add_to_histogram=False, **kwargs))
178+
art_out.append(plot_points(bk_plot, cgpos.longitude, cgpos.latitude, cgpos.height,
179+
cgpos.datetime, c=pos_color, marker=marker, add_to_histogram=False, **kwargs))
180+
art_out.append(plot_points(bk_plot, icneg.longitude, icneg.latitude, icneg.height,
181+
icneg.datetime, c=neg_color, marker=marker, add_to_histogram=False, **kwargs))
182+
art_out.append(plot_points(bk_plot, icpos.longitude, icpos.latitude, icpos.height,
183+
icpos.datetime, c=pos_color, marker=marker, add_to_histogram=False, **kwargs))
183184
else:
184185
art_out.append(plot_points(bk_plot, cgs.longitude, cgs.latitude, cgs.height,
185-
cgs.datetime, c=plot_c, vmin=vmin, vmax=vmax, marker=marker, **kwargs))
186+
cgs.datetime, c=cgs.plot_c, vmin=vmin, vmax=vmax, marker=marker, add_to_histogram=False, **kwargs))
186187
art_out.append(plot_points(bk_plot, ics.longitude, ics.latitude, ics.height,
187-
ics.datetime, c=plot_c, vmin=vmin, vmax=vmax, marker=marker, **kwargs))
188-
188+
ics.datetime, c=ics.plot_c, vmin=vmin, vmax=vmax, marker=marker, add_to_histogram=False, **kwargs))
189189
return art_out
190190

191191

0 commit comments

Comments
 (0)