def __init__(self, **kwargs): super(ScatterViewerState, self).__init__() self.limits_cache = {} self.x_lim_helper = StateAttributeLimitsHelper( self, attribute='x_att', lower='x_min', upper='x_max', log='x_log', limits_cache=self.limits_cache) self.y_lim_helper = StateAttributeLimitsHelper( self, attribute='y_att', lower='y_min', upper='y_max', log='y_log', limits_cache=self.limits_cache) self.add_callback('layers', self._layers_changed) self.x_att_helper = ComponentIDComboHelper(self, 'x_att') self.y_att_helper = ComponentIDComboHelper(self, 'y_att') self.update_from_dict(kwargs)
def __init__(self, *args, **kwargs): super(TutorialViewerState, self).__init__(*args, **kwargs) self._x_att_helper = ComponentIDComboHelper(self, 'x_att') self._y_att_helper = ComponentIDComboHelper(self, 'y_att') self.add_callback('layers', self._on_layers_change) self.add_callback('x_att', self._on_attribute_change) self.add_callback('y_att', self._on_attribute_change)
def __init__(self, **kwargs): super(OpenSpaceViewerState, self).__init__() OpenSpaceViewerState.mode.set_choices(self, MODES) OpenSpaceViewerState.frame.set_choices(self, CELESTIAL_FRAMES) OpenSpaceViewerState.alt_unit.set_choices(self, [str(x) for x in ALT_UNITS]) OpenSpaceViewerState.alt_type.set_choices(self, ALT_TYPES) self.lon_att_helper = ComponentIDComboHelper(self, 'lon_att', numeric=True, categorical=False, world_coord=True, pixel_coord=False) self.lat_att_helper = ComponentIDComboHelper(self, 'lat_att', numeric=True, categorical=False, world_coord=True, pixel_coord=False) self.alt_att_helper = ComponentIDComboHelper(self, 'alt_att', numeric=True, categorical=False, world_coord=True, pixel_coord=False) self.add_callback('layers', self._on_layers_changed) self._on_layers_changed() self.update_from_dict(kwargs)
def __init__(self, **kwargs): super(WWTDataViewerState, self).__init__() WWTDataViewerState.mode.set_choices(self, ['Sky'] + MODES_3D + MODES_BODIES) WWTDataViewerState.frame.set_choices(self, CELESTIAL_FRAMES) WWTDataViewerState.alt_unit.set_choices(self, [str(x) for x in ALT_UNITS]) WWTDataViewerState.alt_type.set_choices(self, ALT_TYPES) self.add_callback('imagery_layers', self._update_imagery_layers) self.lon_att_helper = ComponentIDComboHelper(self, 'lon_att', numeric=True, categorical=False, world_coord=True, pixel_coord=False) self.lat_att_helper = ComponentIDComboHelper(self, 'lat_att', numeric=True, categorical=False, world_coord=True, pixel_coord=False) self.alt_att_helper = ComponentIDComboHelper(self, 'alt_att', numeric=True, categorical=False, world_coord=True, pixel_coord=False, none='None') self.add_callback('layers', self._on_layers_changed) self._on_layers_changed() self.update_from_dict(kwargs)
def __init__(self, **kwargs): super(ImageViewerState, self).__init__() self.limits_cache = {} # NOTE: we don't need to use StateAttributeLimitsHelper here because # we can simply call reset_limits below when x/y attributes change. # Using StateAttributeLimitsHelper makes things a lot slower. self.ref_data_helper = ManualDataComboHelper(self, 'reference_data') self.xw_att_helper = ComponentIDComboHelper(self, 'x_att_world', numeric=False, categorical=False) self.yw_att_helper = ComponentIDComboHelper(self, 'y_att_world', numeric=False, categorical=False) self.add_callback('reference_data', self._reference_data_changed, priority=1000) self.add_callback('layers', self._layers_changed, priority=1000) self.add_callback('x_att', self._on_xatt_change, priority=500) self.add_callback('y_att', self._on_yatt_change, priority=500) self.add_callback('x_att_world', self._on_xatt_world_change, priority=1000) self.add_callback('y_att_world', self._on_yatt_world_change, priority=1000) aspect_display = {'equal': 'Square Pixels', 'auto': 'Automatic'} ImageViewerState.aspect.set_choices(self, ['equal', 'auto']) ImageViewerState.aspect.set_display_func(self, aspect_display.get) ImageViewerState.color_mode.set_choices(self, ['Colormaps', 'One color per layer']) self.update_from_dict(kwargs)
def __init__(self, *args, **kwargs): super(TutorialViewerState, self).__init__(*args, **kwargs) self._x_att_helper = ComponentIDComboHelper(self, 'x_att') self._y_att_helper = ComponentIDComboHelper(self, 'y_att') self.add_callback('layers', self._on_layers_change) self.add_callback('x_att', self._on_attribute_change) self.add_callback('y_att', self._on_attribute_change) TutorialViewerState.orientation.set_choices( self, ['bottom-up', 'left-right', 'top-down', 'right-left']) self.add_callback('orientation', self._on_attribute_change)
def __init__(self, **kwargs): super(ImageViewerState, self).__init__() self.limits_cache = {} self.x_lim_helper = StateAttributeLimitsHelper( self, attribute='x_att', lower='x_min', upper='x_max', limits_cache=self.limits_cache) self.y_lim_helper = StateAttributeLimitsHelper( self, attribute='y_att', lower='y_min', upper='y_max', limits_cache=self.limits_cache) self.ref_data_helper = ManualDataComboHelper(self, 'reference_data') self.xw_att_helper = ComponentIDComboHelper(self, 'x_att_world', numeric=False, categorical=False, visible=False, world_coord=True) self.yw_att_helper = ComponentIDComboHelper(self, 'y_att_world', numeric=False, categorical=False, visible=False, world_coord=True) self.add_callback('reference_data', self._reference_data_changed, priority=1000) self.add_callback('layers', self._layers_changed, priority=1000) self.add_callback('x_att', self._on_xatt_change, priority=500) self.add_callback('y_att', self._on_yatt_change, priority=500) self.add_callback('x_att_world', self._update_att, priority=500) self.add_callback('y_att_world', self._update_att, priority=500) self.add_callback('x_att_world', self._on_xatt_world_change, priority=1000) self.add_callback('y_att_world', self._on_yatt_world_change, priority=1000) self.update_from_dict(kwargs)
def __init__(self, **kwargs): super(Scatter3DViewerState, self).__init__() self.x_att_helper = ComponentIDComboHelper(self, 'x_att', categorical=True) self.y_att_helper = ComponentIDComboHelper(self, 'y_att', categorical=True) self.z_att_helper = ComponentIDComboHelper(self, 'z_att', categorical=True) self.add_callback('layers', self._on_layers_change) self.update_from_dict(kwargs)
def __init__(self, **kwargs): super(ScatterViewerState, self).__init__() self.limits_cache = {} self.x_lim_helper = StateAttributeLimitsHelper( self, attribute='x_att', lower='x_min', upper='x_max', log='x_log', margin=0.04, limits_cache=self.limits_cache) self.y_lim_helper = StateAttributeLimitsHelper( self, attribute='y_att', lower='y_min', upper='y_max', log='y_log', margin=0.04, limits_cache=self.limits_cache) self.add_callback('layers', self._layers_changed) self.x_att_helper = ComponentIDComboHelper(self, 'x_att', pixel_coord=True, world_coord=True) self.y_att_helper = ComponentIDComboHelper(self, 'y_att', pixel_coord=True, world_coord=True) self.plot_mode_helper = ComboHelper(self, 'plot_mode') self.plot_mode_helper.choices = [ proj for proj in get_projection_names() if proj not in ['3d', 'scatter_density'] ] self.plot_mode_helper.selection = 'rectilinear' self.angle_unit_helper = ComboHelper(self, 'angle_unit') self.angle_unit_helper.choices = ['radians', 'degrees'] self.angle_unit_helper.selection = 'radians' self.update_from_dict(kwargs) self.add_callback('x_log', self._reset_x_limits) self.add_callback('y_log', self._reset_y_limits) if self.using_polar: self.full_circle()
def __init__(self, *args, **kwargs): # provides dropdown, parent, height etc. for plot options super(TutorialViewerState, self).__init__(*args, **kwargs) self._x_att_helper = ComponentIDComboHelper(self, 'x_att') self._y_att_helper = ComponentIDComboHelper(self, 'y_att') self.add_callback('layers', self._on_layers_change) self.add_callback('x_att', self._on_attribute_change) self.add_callback('y_att', self._on_attribute_change) TutorialViewerState.orientation.set_choices( self, ['bottom-up', 'left-right', 'top-down', 'right-left']) self.add_callback('orientation', self._on_attribute_change) TutorialViewerState.sort_by.set_choices(self, ['parent', 'height']) self.add_callback('sort_by', self._on_attribute_change)
def __init__(self, layer=None, **kwargs): self._sync_markersize = None super(WWTTableLayerState, self).__init__(layer=layer) self._sync_color = keep_in_sync(self, 'color', self.layer.style, 'color') self._sync_alpha = keep_in_sync(self, 'alpha', self.layer.style, 'alpha') self._sync_size = keep_in_sync(self, 'size', self.layer.style, 'markersize') self.color = self.layer.style.color self.size = self.layer.style.markersize self.alpha = self.layer.style.alpha self.size_att_helper = ComponentIDComboHelper(self, 'size_att', numeric=True, categorical=False) self.cmap_att_helper = ComponentIDComboHelper(self, 'cmap_att', numeric=True, categorical=False) self.img_data_att_helper = ComponentIDComboHelper(self, 'img_data_att', numeric=True, categorical=False) self.size_lim_helper = StateAttributeLimitsHelper(self, attribute='size_att', lower='size_vmin', upper='size_vmax', cache=self.size_limits_cache) self.cmap_lim_helper = StateAttributeLimitsHelper(self, attribute='cmap_att', lower='cmap_vmin', upper='cmap_vmax', cache=self.cmap_limits_cache) self.add_callback('layer', self._on_layer_change) if layer is not None: self._on_layer_change() self.cmap = colormaps.members[0][1] # Color and size encoding depending on attributes is only available # in PyWWT 0.6 or later. if PYWWT_LT_06: modes = ['Fixed'] else: modes = ['Fixed', 'Linear'] WWTTableLayerState.color_mode.set_choices(self, modes) WWTTableLayerState.size_mode.set_choices(self, modes) self.update_from_dict(kwargs)
def __init__(self, viewer_state=None, layer=None, **kwargs): self.vz_att_helper = ComponentIDComboHelper(self, 'vz_att', numeric=True, categorical=False) super(Scatter3dLayerState, self).__init__(viewer_state=viewer_state, layer=layer)
def __init__(self, layer=None, **kwargs): super(VolumeLayerState, self).__init__(layer=layer) if self.layer is not None: self.color = self.layer.style.color self.alpha = self.layer.style.alpha self.att_helper = ComponentIDComboHelper(self, 'attribute') self.lim_helper = StateAttributeLimitsHelper(self, attribute='attribute', lower='vmin', upper='vmax', cache=self.limits_cache) self.add_callback('layer', self._on_layer_change) if layer is not None: self._on_layer_change() if isinstance(self.layer, Subset): self.vmin = 0 self.lim_helper.lower_frozen = True self.update_from_dict(kwargs)
def test_component(app, dataxz, dataxyz): # setup state = DummyState() helper = ComponentIDComboHelper(state, 'x_att', app.data_collection) helper.append_data(dataxz) state.helper = helper # main object we test dropdown = LinkedDropdown(state, 'x_att', 'x test attribute') # simple sanity tests assert dropdown.description == 'x test attribute' assert [item[0] for item in dropdown.options] == ['x', 'z'] # initial state assert state.x_att is dataxz.id['x'] assert dropdown.value is dataxz.id['x'] # glue state -> ui state.x_att = dataxz.id['z'] assert dropdown.value is dataxz.id['z'] # ui -> glue state dropdown.value = dataxz.id['x'] assert state.x_att is dataxz.id['x'] # same, but now be ok with strings state.x_att = 'z' assert dropdown.value is dataxz.id['z'] state.x_att = 'x' assert dropdown.value is dataxz.id['x']
def __init__(self, layer=None, viewer_state=None, **kwargs): super(ProfileLayerState, self).__init__(layer=layer, viewer_state=viewer_state) self.attribute_att_helper = ComponentIDComboHelper(self, 'attribute', numeric=True, categorical=False) percentile_display = { 100: 'Min/Max', 99.5: '99.5%', 99: '99%', 95: '95%', 90: '90%', 'Custom': 'Custom' } ProfileLayerState.percentile.set_choices( self, [100, 99.5, 99, 95, 90, 'Custom']) ProfileLayerState.percentile.set_display_func(self, percentile_display.get) self.add_callback('layer', self._update_attribute, priority=1000) self.add_callback('layer', self._update_profile, priority=1000) self.add_callback('attribute', self._update_profile, priority=1000) if layer is not None: self._update_attribute() self.update_from_dict(kwargs)
def __init__(self, **kwargs): super(ProfileViewerState, self).__init__() self.ref_data_helper = ManualDataComboHelper(self, 'reference_data') self.x_lim_helper = StateAttributeLimitsHelper(self, 'x_att', lower='x_min', upper='x_max') self.add_callback('layers', self._layers_changed) self.add_callback('reference_data', self._reference_data_changed) self.add_callback('normalize', self._reset_y_limits) self.x_att_helper = ComponentIDComboHelper(self, 'x_att', numeric=False, categorical=False, world_coord=True, pixel_coord=True) ProfileViewerState.function.set_choices(self, list(FUNCTIONS)) ProfileViewerState.function.set_display_func(self, FUNCTIONS.get) self.update_from_dict(kwargs)
def __init__(self, **kwargs): super(HistogramViewerState, self).__init__() self.hist_helper = StateAttributeHistogramHelper( self, 'x_att', lower='hist_x_min', upper='hist_x_max', n_bin='hist_n_bin', common_n_bin='common_n_bin') self.x_lim_helper = StateAttributeLimitsHelper(self, 'x_att', lower='x_min', upper='x_max', log='x_log') self.add_callback('layers', self._layers_changed) self.x_att_helper = ComponentIDComboHelper(self, 'x_att', pixel_coord=True, world_coord=True) self.update_from_dict(kwargs) # This should be added after update_from_dict since we don't want to # influence the restoring of sessions. self.add_callback('hist_x_min', self.update_view_to_bins) self.add_callback('hist_x_max', self.update_view_to_bins) self.add_callback('x_log', self._reset_x_limits, priority=1000)
def __init__(self, *args, **kwargs): super(CustomMatplotlibViewerState, self).__init__(*args) self._cid_helpers = [] for name, property in self.iter_callback_properties(): if isinstance(property, DynamicComponentIDProperty): self._cid_helpers.append(ComponentIDComboHelper(self, name)) self.add_callback('layers', self._on_layer_change) self.update_from_dict(kwargs)
def _enable_viewer_combo(self, viewer, data, index, selection_label): connect_combo_selection(self, selection_label, viewer.combo) helper = ComponentIDComboHelper(self, selection_label) helper.set_multiple_data([data]) viewer.combo.setEnabled(True) viewer.combo.currentIndexChanged.connect( self._get_change_viewer_combo_func(viewer.combo, index)) self._viewer_combo_helpers.append(helper)
def __init__(self, **kwargs): super(DendrogramViewerState, self).__init__() self.add_callback('layers', self._layers_changed) self.height_att_helper = ComponentIDComboHelper(self, 'height_att') self.parent_att_helper = ComponentIDComboHelper(self, 'parent_att') self.order_att_helper = ComponentIDComboHelper(self, 'order_att') self.add_callback('height_att', self._update_layout) self.add_callback('parent_att', self._update_layout) self.add_callback('order_att', self._update_layout) self.add_callback('reference_data', self._on_reference_data_change) self.update_from_dict(kwargs)
def __init__(self, layer=None, viewer_state=None, **kwargs): self.uuid = str(uuid.uuid4()) super(ImageLayerState, self).__init__(layer=layer, viewer_state=viewer_state) self.attribute_lim_helper = StateAttributeLimitsHelper( self, attribute='attribute', percentile='percentile', lower='v_min', upper='v_max') self.attribute_att_helper = ComponentIDComboHelper(self, 'attribute', numeric=True, categorical=False) percentile_display = { 100: 'Min/Max', 99.5: '99.5%', 99: '99%', 95: '95%', 90: '90%', 'Custom': 'Custom' } ImageLayerState.percentile.set_choices( self, [100, 99.5, 99, 95, 90, 'Custom']) ImageLayerState.percentile.set_display_func(self, percentile_display.get) stretch_display = { 'linear': 'Linear', 'sqrt': 'Square Root', 'arcsinh': 'Arcsinh', 'log': 'Logarithmic' } ImageLayerState.stretch.set_choices( self, ['linear', 'sqrt', 'arcsinh', 'log']) ImageLayerState.stretch.set_display_func(self, stretch_display.get) self.add_callback('global_sync', self._update_syncing) self.add_callback('layer', self._update_attribute) self._update_syncing() if layer is not None: self._update_attribute() self.update_from_dict(kwargs) if self.cmap is None: self.cmap = self.layer.style.preferred_cmap or colormaps.members[ 0][1]
def __init__(self, **kwargs): super(ImageViewerState, self).__init__() self.limits_cache = {} # NOTE: we don't need to use StateAttributeLimitsHelper here because # we can simply call reset_limits below when x/y attributes change. # Using StateAttributeLimitsHelper makes things a lot slower. self.ref_data_helper = ManualDataComboHelper(self, 'reference_data') self.xw_att_helper = ComponentIDComboHelper(self, 'x_att_world', numeric=False, categorical=False, world_coord=True) self.yw_att_helper = ComponentIDComboHelper(self, 'y_att_world', numeric=False, categorical=False, world_coord=True) self.add_callback('reference_data', self._reference_data_changed, priority=1000) self.add_callback('layers', self._layers_changed, priority=1000) self.add_callback('x_att', self._on_xatt_change, priority=500) self.add_callback('y_att', self._on_yatt_change, priority=500) self.add_callback('x_att_world', self._update_att, priority=500) self.add_callback('y_att_world', self._update_att, priority=500) self.add_callback('x_att_world', self._on_xatt_world_change, priority=1000) self.add_callback('y_att_world', self._on_yatt_world_change, priority=1000) self.update_from_dict(kwargs)
def __init__(self, viewer_state=None, **kwargs): super(WWTLayerState, self).__init__() self.viewer_state = viewer_state self.ra_att_helper = ComponentIDComboHelper(self, 'ra_att', numeric=True, categorical=False, world_coord=True, pixel_coord=False) self.dec_att_helper = ComponentIDComboHelper(self, 'dec_att', numeric=True, categorical=False, world_coord=True, pixel_coord=False) self.add_callback('layer', self._layer_changed) self.update_from_dict(kwargs) if isinstance(self.layer, Subset): for layer_state in self.viewer_state.layers: if self.layer.data is layer_state.layer: self.viewer_state._sync_attributes_single( layer_state, self) break self.add_callback('ra_att', self._att_changed) self.add_callback('dec_att', self._att_changed) self.color = self.layer.style.color self.alpha = self.layer.style.alpha self.size = self.layer.style.markersize self._sync_color = keep_in_sync(self, 'color', self.layer.style, 'color') self._sync_alpha = keep_in_sync(self, 'alpha', self.layer.style, 'alpha') self._sync_size = keep_in_sync(self, 'size', self.layer.style, 'markersize')
def __init__(self, parent=None, data_viewer=None): super(OptionsWidget, self).__init__(parent=parent) self.ui = load_ui('viewer_options.ui', self, directory=os.path.dirname(__file__)) self.file_helper = ComponentIDComboHelper( self, 'file_att', data_collection=data_viewer._data) connect_combo_selection(self, 'file_att', self.ui.combo_file_attribute)
def __init__(self, data_collection): super(SubsetFacetState, self).__init__() self.data_helper = DataCollectionComboHelper(self, 'data', data_collection) self.att_helper = ComponentIDComboHelper(self, 'att') self.lim_helper = StateAttributeLimitsHelper(self, attribute='att', lower='v_min', upper='v_max', log='log') self.add_callback('data', self._on_data_change) self._on_data_change()
def __init__(self, data_collection=None): super(SaveDataState, self).__init__() self.data_helper = DataCollectionComboHelper(self, 'data', data_collection) self.component_helper = ComponentIDComboHelper(self, 'component', data_collection=data_collection) self.add_callback('data', self._on_data_change) self._on_data_change() self._sync_data_exporters()
def __init__(self, layer=None, **kwargs): self._sync_markersize = None super(ScatterLayerState, self).__init__(layer=layer) if self.layer is not None: self.color = self.layer.style.color self.size = self.layer.style.markersize self.alpha = self.layer.style.alpha self.size_att_helper = ComponentIDComboHelper(self, 'size_attribute') self.cmap_att_helper = ComponentIDComboHelper(self, 'cmap_attribute') self.size_lim_helper = StateAttributeLimitsHelper( self, attribute='size_attribute', lower='size_vmin', upper='size_vmax', cache=self.size_limits_cache) self.cmap_lim_helper = StateAttributeLimitsHelper( self, attribute='cmap_attribute', lower='cmap_vmin', upper='cmap_vmax', cache=self.cmap_limits_cache) self.add_callback('layer', self._on_layer_change) if layer is not None: self._on_layer_change() self.cmap = colormaps.members[0][1] self.update_from_dict(kwargs)
def __init__(self, viewer_state=None, **kwargs): super(SpecvizLayerState, self).__init__(viewer_state=viewer_state, **kwargs) self.color = self.layer.style.color self.alpha = self.layer.style.alpha self._sync_color = keep_in_sync(self, 'color', self.layer.style, 'color') self._sync_alpha = keep_in_sync(self, 'alpha', self.layer.style, 'alpha') self._att_helper = ComponentIDComboHelper(self, 'attribute') self.add_callback('layer', self._on_layer_change) self._on_layer_change() SpecvizLayerState.statistic.set_choices(self, list(FUNCTIONS)) SpecvizLayerState.statistic.set_display_func(self, FUNCTIONS.get)
def test_component_default_index(app, dataxz, dataxyz): # Regression test for a bug that caused the incorrect element to be selected # when default_index is involved. # setup state = DummyState() helper = ComponentIDComboHelper(state, 'y_att', app.data_collection) state.helper = helper dropdown = LinkedDropdown(state, 'y_att', 'y test attribute') assert [item[0] for item in dropdown.options] == [] helper.append_data(dataxz) assert [item[0] for item in dropdown.options] == ['x', 'z'] assert state.y_att is dataxz.id['z'] assert dropdown.value is dataxz.id['z']
def __init__(self, layer=None, **kwargs): super(WWTImageLayerState, self).__init__(layer=layer) self._sync_color = keep_in_sync(self, 'color', self.layer.style, 'color') self._sync_alpha = keep_in_sync(self, 'alpha', self.layer.style, 'alpha') self.color = self.layer.style.color self.img_data_att_helper = ComponentIDComboHelper(self, 'img_data_att', numeric=True, categorical=False) self.add_callback('layer', self._on_layer_change) if layer is not None: self._on_layer_change() self.update_from_dict(kwargs)