Skip to content

Commit

Permalink
to keep convergence update in sync with the displayed channel it must…
Browse files Browse the repository at this point in the history
… be updated after the channel has been loaded
  • Loading branch information
schiebel committed Jan 9, 2024
1 parent 56c946e commit a5fe84a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
18 changes: 8 additions & 10 deletions casagui/apps/_interactiveclean.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,18 +908,16 @@ def convergence_handler( msg, self=self ):

if image_channels > 1:
self._control['goto'] = TextInput( title="goto channel", value="", width=90 )
self._fig['slider'] = self._cube.slider( )
self._fig['spectra'] = self._cube.spectra( width=450 )
self._fig['slider'] = self._cube.slider( CustomJS( args=dict( flux_src=self._flux_data,
residual_src=self._residual_data,
threshold_src=self._cyclethreshold_data,
convergence_fig=self._fig['convergence'],
conv_pipe=self._pipe['converge'], convergence_id=self._convergence_id,
img_src=self._fig['image-source'],
stopdescmap=ImagingDict.get_summaryminor_stopdesc( ) ),
code=self._js['update-converge'] + self._js['slider-update'] ) )

self._fig['slider'].js_on_change( 'value',
CustomJS( args=dict( flux_src=self._flux_data,
residual_src=self._residual_data,
threshold_src=self._cyclethreshold_data,
convergence_fig=self._fig['convergence'],
conv_pipe=self._pipe['converge'], convergence_id=self._convergence_id,
img_src=self._fig['image-source'],
stopdescmap=ImagingDict.get_summaryminor_stopdesc( ) ),
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
15 changes: 10 additions & 5 deletions casagui/toolbox/_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def __init__( self, image, mask=None, abort=None ):
self._bitmask_transparency_button = None # select whether the 1s or 0s is transparent
self._mask0 = None # INTERNAL systhesis imaging mask
self._slider = None # slider to move from plane to plane
self._slider_callback = None # called after the channel update for slider movement is complete
self._spectra = None # figure displaying spectra along the frequency axis
self._statistics = None # statistics data table
self._statistics_mask = None # button to switch from channel statistics to mask statistics
Expand Down Expand Up @@ -492,10 +493,12 @@ def __init__( self, image, mask=None, abort=None ):
###
'slider_w_stats': '''if ( casalib.hotkeys.getScope( ) !== 'channel' ) {
source.channel( slider.value, source.cur_chan[0],
msg => { if ( 'stats' in msg ) { source.update_statistics( msg.stats ) } } )
msg => { if ( 'stats' in msg ) { source.update_statistics( msg.stats ) }
if ( cb ) cb.execute( this ) } )
}''',
'slider_wo_stats': '''if ( casalib.hotkeys.getScope( ) !== 'channel' ) {
source.channel( slider.value, source.cur_chan[0] )
source.channel( slider.value, source.cur_chan[0],
msg => { if ( cb ) cb.execute( this ) } )
}''',
### initialize mask state
###
Expand Down Expand Up @@ -1111,7 +1114,7 @@ async def mod_mask( msg, self=self ):

return self._image

def slider( self, **kw ):
def slider( self, callback=None, **kw ):
'''Return slider that is used to change the image plane that is
displayed on the 2D raster display.
Expand All @@ -1126,6 +1129,7 @@ def slider( self, **kw ):
slider_end = shape[-1]-1
self._slider = set_attributes( Slider( start=0, end=1 if slider_end == 0 else slider_end , value=0, step=1,
title="Channel" ), **kw )
self._slider_callback = callback
if slider_end == 0:
# for a cube with one channel, a slider is of no use
self._slider.disabled = True
Expand Down Expand Up @@ -1743,8 +1747,9 @@ def connect( self ):
### ... ALSO statistics would be based upon the SELECTION SET...
###
self._cb['slider'] = CustomJS( args=dict( source=self._image_source, slider=self._slider,
stats_source=self._statistics_source ),
code=self._js['slider_w_stats'] if self._statistics_source else self._js['slider_wo_stats'] )
stats_source=self._statistics_source,
cb=self._slider_callback ),
code=(self._js['slider_w_stats'] if self._statistics_source else self._js['slider_wo_stats']) )
self._slider.js_on_change( 'value', self._cb['slider'] )

if self._statistics_mask:
Expand Down

0 comments on commit a5fe84a

Please sign in to comment.