Skip to content

Commit

Permalink
add stokes selection convergence plot update
Browse files Browse the repository at this point in the history
  • Loading branch information
schiebel committed Jan 7, 2024
1 parent 9d3e532 commit 0dc3a39
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
13 changes: 10 additions & 3 deletions casagui/apps/_interactiveclean.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 8 additions & 6 deletions casagui/toolbox/_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <b>image</b> or <b>stokes</b> 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 <b>image</b> or <b>stokes</b> planes to display'),
position='right' ) ) )
return self._channel_ctrl_group

def coord_ctrl( self ):
Expand Down Expand Up @@ -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' ) ) )

Expand Down

0 comments on commit 0dc3a39

Please sign in to comment.