From 0dc3a3980b6c1d8fb1e37ceff9a66af55caf4f2d Mon Sep 17 00:00:00 2001 From: Darrell Schiebel Date: Sat, 6 Jan 2024 20:21:03 -0500 Subject: [PATCH] add stokes selection convergence plot update --- casagui/apps/_interactiveclean.py | 13 ++++++++++--- casagui/toolbox/_cube.py | 14 ++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/casagui/apps/_interactiveclean.py b/casagui/apps/_interactiveclean.py index aa3dded..a652e67 100644 --- a/casagui/apps/_interactiveclean.py +++ b/casagui/apps/_interactiveclean.py @@ -522,6 +522,7 @@ def __init__( self, vis, imagename, usemask='user', mask='', initial_mask_pixel= update_convergence( ) } else { // update convergence plot with a request to python + const pos = img_src.cur_chan conv_pipe.send( convergence_id, { action: 'update', value: [ pos[0], cb_obj.value ] }, // stokes-------------^^^^^^ ^^^^^^^^^^^^^^--------chan @@ -911,8 +912,7 @@ def convergence_handler( msg, self=self ): conv_pipe=self._pipe['converge'], convergence_id=self._convergence_id, img_src=self._fig['image-source'], stopdescmap=ImagingDict.get_summaryminor_stopdesc( ) ), - code='''const pos = img_src.cur_chan;''' + - self._js['update-converge'] + self._js['slider-update'] ) ) + code=self._js['update-converge'] + self._js['slider-update'] ) ) self._control['goto'].js_on_change( 'value', CustomJS( args=dict( img=self._cube.js_obj( ), slider=self._fig['slider'], @@ -1061,9 +1061,16 @@ def convergence_handler( msg, self=self ): TabPanel(child=layout([self._fig['spectra']], sizing_mode='stretch_width'), title='Spectrum') ], sizing_mode='stretch_both' ) + self._channel_ctrl = self._cube.channel_ctrl( ) + + ### Stokes 'label' should be updated AFTER the channel update has happened + self._channel_ctrl[1].child.js_on_change( 'label', + CustomJS( args=dict( img_src=self._fig['image-source'], + flux_src=self._flux_data), + code=self._js['update-converge'] ) ) self._fig['layout'] = column( row( - column( row( self._cube.channel_ctrl( ), self._cube.coord_ctrl( ), + column( row( *self._channel_ctrl, self._cube.coord_ctrl( ), Spacer(height=help_button.height, sizing_mode="scale_width"), self._cube.palette( ), mask_clean_notclean_pick, diff --git a/casagui/toolbox/_cube.py b/casagui/toolbox/_cube.py index 25bd723..188c3dc 100644 --- a/casagui/toolbox/_cube.py +++ b/casagui/toolbox/_cube.py @@ -1662,10 +1662,10 @@ def channel_ctrl( self ): raise RuntimeError('cube image not in use') self._channel_ctrl = PreText( text='Channel 0', min_width=100 ) self._channel_ctrl_stokes_dropdown = Dropdown( label='I', button_type='light', margin=(-1, 0, 0, 0), sizing_mode='scale_height', width=25 ) - self._channel_ctrl_group = row( self._channel_ctrl, - Tip( self._channel_ctrl_stokes_dropdown, - tooltip=Tooltip( content=HTML('Select which of the image or stokes planes to display'), - position='right' ) ) ) + self._channel_ctrl_group = ( self._channel_ctrl, + Tip( self._channel_ctrl_stokes_dropdown, + tooltip=Tooltip( content=HTML('Select which of the image or stokes planes to display'), + position='right' ) ) ) return self._channel_ctrl_group def coord_ctrl( self ): @@ -1798,9 +1798,11 @@ def connect( self ): ### self._channel_ctrl_stokes_dropdown.menu = stokes_labels self._channel_ctrl_stokes_dropdown.js_on_click( CustomJS( args=dict( source=self._image_source ), + ### 'label' is updated after the channel has changed to allow for subsequent + ### updates (e.g. convergence plot) to update based upon 'label' after fresh + ### convergence data is available... code='''if ( cb_obj.item != cb_obj.origin.label ) { - cb_obj.origin.label = cb_obj.item - source.channel( source.cur_chan[1], %s ) + source.channel( source.cur_chan[1], %s, msg => { cb_obj.origin.label = cb_obj.item } ) }''' % ( ' : '.join( map( lambda x: f'''cb_obj.item == '{x[1]}' ? {x[0]}''', zip(range(len(stokes_labels)),stokes_labels) ) ) + ' : 0' ) ) )