@@ -130,7 +130,9 @@ def user_api(self):
130
130
'dataset' , 'method' , 'period_at_max_power' , 'adopt_period_at_max_power' ]
131
131
return PluginUserApi (self , expose = expose )
132
132
133
- def _phase_comp_lbl (self , component ):
133
+ def _phase_comp_lbl (self , component = None ):
134
+ if component is None :
135
+ component = self .component_selected
134
136
if self .app ._jdaviz_helper is None :
135
137
# duplicate logic from helper in case this is ever called before the helper
136
138
# is fully intialized
@@ -139,9 +141,11 @@ def _phase_comp_lbl(self, component):
139
141
140
142
@property
141
143
def phase_comp_lbl (self ):
142
- return self ._phase_comp_lbl (self . component_selected )
144
+ return self ._phase_comp_lbl ()
143
145
144
- def _phase_viewer_id (self , component ):
146
+ def _phase_viewer_id (self , component = None ):
147
+ if component is None :
148
+ component = self .component_selected
145
149
return f'flux-vs-phase:{ component } '
146
150
147
151
@property
@@ -152,7 +156,7 @@ def phase_viewer_ids(self):
152
156
153
157
@property
154
158
def phase_viewer_id (self ):
155
- return self ._phase_viewer_id (self . component_selected )
159
+ return self ._phase_viewer_id ()
156
160
157
161
@property
158
162
def default_phase_viewer (self ):
@@ -269,31 +273,34 @@ def _update_all_phase_arrays(self, *args, ephem_component=None):
269
273
dc .add_link (new_links )
270
274
271
275
# update any plugin markers
272
- # TODO: eventually might need to loop over multiple matching viewers
273
- phase_viewer_id = self ._phase_viewer_id (ephem_component )
274
- if phase_viewer_id in self .app .get_viewer_ids ():
275
- phase_viewer = self .app .get_viewer (phase_viewer_id )
276
- for mark in phase_viewer .custom_marks :
276
+ for viewer in self ._get_phase_viewers (ephem_component ):
277
+ for mark in viewer .custom_marks :
277
278
if hasattr (mark , 'update_phase_folding' ):
278
279
mark .update_phase_folding ()
279
280
280
281
return phase_comp_lbl
281
282
282
- def create_phase_viewer (self ):
283
+ def create_phase_viewer (self , ephem_component = None ):
283
284
"""
284
285
Create a new phase viewer corresponding to ``component`` and populate the phase arrays
285
286
with the current ephemeris, if necessary.
287
+
288
+ Parameters
289
+ ----------
290
+ ephem_component : str, optional
291
+ label of the component. If not provided or ``None``, will default to plugin value.
286
292
"""
287
- phase_viewer_id = self .phase_viewer_id
293
+ phase_viewer_id = self ._phase_viewer_id (ephem_component )
294
+ phase_comp_lbl = self ._phase_comp_lbl (ephem_component )
288
295
dc = self .app .data_collection
289
296
290
297
# check to see if this component already has a phase array. We'll just check the first
291
298
# item in the data-collection since the rest of the logic in this plugin /should/ populate
292
299
# the arrays across all entries.
293
- if self . phase_comp_lbl not in [comp .label for comp in dc [0 ].components ]:
300
+ if phase_comp_lbl not in [comp .label for comp in dc [0 ].components ]:
294
301
self .update_ephemeris () # calls _update_all_phase_arrays
295
302
296
- create_phase_viewer = not self .phase_viewer_exists
303
+ create_phase_viewer = len ( self ._get_phase_viewers ( ephem_component )) == 0
297
304
if create_phase_viewer :
298
305
# TODO: stack horizontally by default?
299
306
self .app ._on_new_viewer (NewViewerMessage (PhaseScatterView , data = None , sender = self .app ),
@@ -308,7 +315,7 @@ def create_phase_viewer(self):
308
315
pv = self .app .get_viewer (phase_viewer_id )
309
316
if create_phase_viewer :
310
317
pv .state .x_min , pv .state .x_max = (self .wrap_at - 1 , self .wrap_at )
311
- pv .state .x_att = self .app ._jdaviz_helper ._component_ids [self . phase_comp_lbl ]
318
+ pv .state .x_att = self .app ._jdaviz_helper ._component_ids [phase_comp_lbl ]
312
319
return pv .user_api
313
320
314
321
def vue_create_phase_viewer (self , * args ):
@@ -410,7 +417,7 @@ def update_ephemeris(self, ephem_component=None, t0=None, period=None, dpdt=None
410
417
411
418
Parameters
412
419
----------
413
- component : str, optional
420
+ ephem_component : str, optional
414
421
label of the component. If not provided or ``None``, will default to plugin value.
415
422
t0 : float, optional
416
423
value of t0 to replace
0 commit comments