uwsift.view package

Submodules

uwsift.view.algebraic_config module

class uwsift.view.algebraic_config.AlgebraicLayerConfigPane(ui, parent, model: LayerModel)[source]

Bases: QObject

property algebraic_channels
property algebraic_name_edit
layer_added(layer: LayerItem)[source]
layer_removed(layer_uuid)[source]
property operation_combo
property operations_text
selection_did_change(layers: Tuple[LayerItem])[source]

Change UI elements to reflect the provided recipe

uwsift.view.cameras module

LayerRep.py

PURPOSE Layer representation - the “physical” realization of content to draw on the map. A layer representation can have multiple levels of detail

A factory will convert URIs into LayerReps LayerReps are managed by document, and handed off to the MapWidget as part of a LayerDrawingPlan

REFERENCES

REQUIRES

author:

R.K.Garcia <rayg@ssec.wisc.edu>

copyright:

2014 by University of Wisconsin Regents, see AUTHORS for more details

license:

GPLv3, see LICENSE for more details

class uwsift.view.cameras.PanZoomProbeCamera(*args, **kwargs)[source]

Bases: PanZoomCamera

Camera that maps mouse presses to events for probing.

property rect

The rectangular border of the ViewBox visible area, expressed in the coordinate system of the scene.

Note that the rectangle can have negative width or height, in which case the corresponding dimension is flipped (this flipping is independent from the camera’s flip property).

viewbox_mouse_event(event)[source]

The SubScene received a mouse event; update transform accordingly.

Parameters:

event (instance of Event) – The event.

uwsift.view.colormap module

Colormap objects and utilities.

class uwsift.view.colormap.AWIPSColormap(awips_file, flipped=False, interpolation='linear')[source]

Bases: Colormap

class uwsift.view.colormap.BlockedColormap(colors, controls, **kwargs)[source]

Bases: Colormap

Remove gradients from colormap.

class uwsift.view.colormap.ColormapManager(categories=None)[source]

Bases: OrderedDict

colormap_classes = {'.cmap': <class 'uwsift.view.colormap.AWIPSColormap'>, '.json': <class 'uwsift.view.colormap.PyQtGraphColormap'>}
get(key, default=None)[source]

Return the value for key if key is in the dictionary, else default.

import_colormaps(base_dir_or_files, read_only=False, recursive=True, category='User')[source]
is_writeable_colormap(name)[source]
iter_colormaps(writeable_first=True)[source]
keys() a set-like object providing a view on D's keys[source]
writeable_extensions = ['.json']
class uwsift.view.colormap.FlippedColormap(colors, controls=None, **kwargs)[source]

Bases: Colormap

Simple wrapper to flip the provided colors and colormaps.

class uwsift.view.colormap.LazyColormap(cmap_class, cmap_file, **kwargs)[source]

Bases: object

load()[source]
class uwsift.view.colormap.PyQtGraphColormap(json_file_or_pqg_cmap, **kwargs)[source]

Bases: Colormap

class uwsift.view.colormap.SquareRootColormap(colors=None)[source]

Bases: BaseColormap

colors = [(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)]
glsl_map = '\n    vec4 sqrt_cmap(float t) {\n        return mix($color_0, $color_1, sqrt(t));\n    }\n    '
map(t)[source]

Return a rgba array for the requested items.

This function must be overriden by child classes.

This function doesn’t need to implement argument checking on item. It can always assume that item is a (N, 1) array of values between 0 and 1.

Parameters:

item (ndarray) – An array of values in [0,1].

Returns:

rgba – An array with rgba values, with one color per item. The shape should be item.shape + (4,).

Return type:

ndarray

Notes

Users are expected to use a colormap with __getitem__() rather than map() (which implements a lower-level API).

uwsift.view.colormap_editor module

class uwsift.view.colormap_editor.ColormapEditor(doc, parent=None, **kwargs)[source]

Bases: QDialog

import_colormaps(name, controls, colors, sqrt=False, editable=False)[source]
uwsift.view.colormap_editor.main()[source]

uwsift.view.dataset_statistics_pane module

class uwsift.view.dataset_statistics_pane.DatasetStatisticsPane(*args, **kwargs)[source]

Bases: QWidget

The purpose of this class is to manage the statistic analysis pane.

In the statistical analysis pane, the corresponding statistics of the first active dataset of a selected layer are displayed.

initiate_update()[source]

Refresh the display of name and the statistics from the current active dataset or clear the pane if there is none.

selection_did_change(layers: Tuple[LayerItem])[source]

Process if an update is needed or not. If it is then initiate the update process

If multiple layers are selected then the statistics can not be viewed.

uwsift.view.export_image module

class uwsift.view.export_image.ExportImageDialog(parent)[source]

Bases: QDialog

default_filename = 'sift_screenshot.png'
get_info()[source]
set_total_frames(n)[source]
show(self)[source]
class uwsift.view.export_image.ExportImageHelper(parent, sgm, model: LayerModel)[source]

Bases: QObject

Handle all the logic for creating screenshot images

default_font = '/home/docs/checkouts/readthedocs.org/user_builds/sift/checkouts/latest/uwsift/data/fonts/Andale Mono.ttf'
take_screenshot()[source]
uwsift.view.export_image.get_imageio_format(fn)[source]

Ask imageio if it knows what to do with this filename.

uwsift.view.export_image.is_gif_filename(fn)[source]
uwsift.view.export_image.is_video_filename(fn)[source]

uwsift.view.layer_details module

PURPOSE Manage the layer sets.

REFERENCES

REQUIRES

author:

Eva Schiffer <evas@ssec.wisc.edu>

copyright:

2015 by University of Wisconsin Regents, see AUTHORS for more details

license:

GPLv3, see LICENSE for more details

class uwsift.view.layer_details.SingleLayerInfoPane(*args, **kwargs)[source]

Bases: QWidget

Shows details about one layer that is currently selected.

initiate_update()[source]

Start the update process if a layer is currently selected.

selection_did_change(layers: Tuple[LayerItem])[source]

Update the displayed values only when one layer is selected.

Also reset the display to its initial state at the beginning.

Parameters:

layers – Layers which are currently selected

update_displayed_clims()[source]

Update the corresponding viewed values for the color limits of the layer

Exclude the listed layer types for displaying color limit values even if they have some.

update_displayed_colormap()[source]

Update the currently viewed colormap values of the layer

uwsift.view.layer_tree_view module

class uwsift.view.layer_tree_view.LayerTreeView(*args, **kwargs)[source]

Bases: QTreeView

begin_layers_removal(*args, **kwargs)[source]

Triggers the process that the model removes the current selected Rows out of itself.

currentChanged(self, current: QModelIndex, previous: QModelIndex)[source]
resizeColumnsToContents() None[source]

Resize all columns to their current contents of the model.

rowsInserted(self, parent: QModelIndex, start: int, end: int)[source]

uwsift.view.open_file_wizard module

class uwsift.view.open_file_wizard.Conf(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

SKIP = 1
class uwsift.view.open_file_wizard.GroupingMode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

BY_GROUP_KEYS = 0
KEEP_SEPARATE = 1
MERGE_ALL = 2
class uwsift.view.open_file_wizard.OpenFileWizard(base_dir=None, base_reader=None, parent=None)[source]

Bases: QWizard

collect_selected_ids()[source]
configured_readers = None
property files_to_load

Return files that should be used by the Document/Workspace.

get_directory() str[source]
get_reader() str[source]
initializePage(self, id: int)[source]
validateCurrentPage() bool[source]

Check that the current page will generate the necessary data.

uwsift.view.probes module

probes.py ~~~ This module holds the code which deals with the controller and view for the area probe graphs.

author:

Eva Schiffer <evas@ssec.wisc.edu>

copyright:

2015 by University of Wisconsin Regents, see AUTHORS for more details

license:

GPLv3, see LICENSE for more details

class uwsift.view.probes.CustomNavigationToolbar(*args, **kwargs)[source]

Bases: NavigationToolbar2QT

Custom matplotlib toolbar.

edit_parameters()[source]
class uwsift.view.probes.ProbeGraphDisplay(manager, qt_parent, workspace, layer_model: LayerModel, queue, name_str)[source]

Bases: object

The ProbeGraphDisplay controls one tab of the Area Probe Graphs. The ProbeGraphDisplay handles generating a displaying a single graph.

DEFAULT_NUM_BINS = 100
MAX_SCATTER_PLOT_DATA = 10000000.0
property checked
clearPlot()[source]

Clear our plot

getName()[source]

Accessor method for the graph’s name.

plotDensityScatterplot(dataX, nameX, timeX, dataY, nameY, timeY, pointX, pointY)[source]

Make a density scatter plot for the given data :param timeX: :param timeY:

plotHistogram(data, title, x_point, x_label, y_label, numBins=100)[source]

Make a histogram using the given data and label it with the given title

rebuildPlot()[source]

Given what we currently know about the selection area and selected bands, rebuild our plot

Note: This should be called only when the selections change in some way.

setPoint(coordinates, rebuild=True)[source]
setRegion(polygon_points=None, select_full_data=False)[source]

Set the region for this graph as polygon selection or full data.

set_default_layer_selections(layer_uuids)[source]
set_possible_layers(do_rebuild_plot=False)[source]

Given a list of layer UUIDs, set the names and UUIDs in the drop downs

vsChecked()[source]

The vs check box was checked!

xSelected()[source]

The user selected something in the X layer list.

ySelected()[source]

The user selected something in the Y layer list.

class uwsift.view.probes.ProbeGraphManager(tab_widget, auto_update_checkbox, update_button, workspace, layer_model: LayerModel, queue)[source]

Bases: QObject

The ProbeGraphManager manages the many tabs of the Area Probe Graphs.

current_graph_has_polygon() bool[source]
current_graph_set_region(polygon_points=None, select_full_data=False)[source]

Update the current region in the selected graph and rebuild its plot

Returns:

Name of the current probe graph (‘A’, ‘B’, …)

Probably outdated comment (TODO): FUTURE, once the polygon is a layer, this signal will be unnecessary

current_point_probe_status(probe_name)[source]
handleActiveProductDatasetsChanged()[source]

Used when the layer model signals that something about the layers has changed

on_region_probe_tool_selected()[source]
set_default_layer_selections(layer_uuids)[source]

Set the UUIDs for the current graph if it doesn’t have a polygon

set_up_tab(tab_index, do_increment_tab_letter=True)[source]

Create a new tab at tab_index and add it to the list of graphs

toggle_point_probe(probe_name, state=None)[source]
update_point_probe(probe_name='default_probe_name', xy_pos=None, state=None)[source]

uwsift.view.rgb_config module

UI objects for configuring RGB layers.

class uwsift.view.rgb_config.RGBLayerConfigPane(ui, parent, model: LayerModel)[source]

Bases: QObject

Configures RGB channel selection and ranges on behalf of document. Document in turn generates update signals which cause the SceneGraph to refresh.

property gamma_boxes
layer_added(layer: LayerItem)[source]
layer_removed(layer_uuid)[source]
property line_edits
property rgb
property rgb_name_edit
selection_did_change(layers: Tuple[LayerItem])[source]

Change UI elements to reflect the provided recipe.

set_combos_to_layer_names()[source]

update combo boxes with the list of layer names and then select the right r,g,b,a layers if they’re not None :return:

property sliders

uwsift.view.scene_graph module

Provide a SceneGraphManager to handle display of visuals.

As per http://api.vispy.org/en/latest/scene.html (abridged)

  • Vispy scene graph (SG) prerequisites:
    1. create SceneCanvas -> this object’s scene property is top level node in SG:

      ` vispy_canvas = scene.SceneCanvas sg_root_node = vispy_canvas.scene `

    2. create node instances (from vispy.scene.visuals)

    3. add node instances to scene by making them children of canvas scene, or of nodes already in the scene

REFERENCES http://api.vispy.org/en/latest/scene.html

author:

R.K.Garcia <rayg@ssec.wisc.edu>

copyright:

2014 by University of Wisconsin Regents, see AUTHORS for more details

license:

GPLv3, see LICENSE for more details

class uwsift.view.scene_graph.AnimationController[source]

Bases: object

Basic bookkeeping object for each layer set (A, B, C, D) from the UI.

property animating
property animation_speed

speed in milliseconds

connect_to_model(model: LayerModel)[source]
get_current_frame_index()[source]
get_current_frame_uuid()[source]
get_frame_count()[source]
get_frame_uuids()[source]

Get a list of dataset uuids, one for each frame of the animation as the current timeline manager would play. The uuids are those of the current driving layer, therefore they are unique in the list.

Returns:

list of dataset UUIDs

jump(index)[source]
toggle_animation(*args)[source]
class uwsift.view.scene_graph.MainMap(*args, **kwargs)[source]

Bases: Node

Scene node for holding all of the information for the main map area.

uwsift.view.scene_graph.Markers

alias of Markers2

class uwsift.view.scene_graph.Markers2(*args, **kwargs)[source]

Bases: Markers

class uwsift.view.scene_graph.PendingPolygon(point_parent)[source]

Bases: object

Temporary information holder for Probe Polygons.

add_point(canvas_pos, xy_pos, z=100)[source]
reset()[source]
class uwsift.view.scene_graph.SIFTMainMapCanvas(title='VisPy canvas', size=(800, 600), position=None, show=False, autoswap=True, app=None, create_native=True, vsync=False, resizable=True, decorate=True, fullscreen=False, config=None, shared=None, keys=None, parent=None, dpi=None, always_on_top=False, px_scale=1, bgcolor='black')[source]

Bases: SceneCanvas

High level map canvas node.

class uwsift.view.scene_graph.SceneGraphManager(doc, workspace, queue, borders_shapefiles: list | None = None, states_shapefile=None, parent=None, texture_shape=(4, 16), center=None)[source]

Bases: QObject

SceneGraphManager represents a document as a vispy scenegraph. When document changes, it updates to correspond. Handles animation by cycling visibility. Provides means of highlighting areas. Decides what sampling to bring data in from the workspace, in order to feed the display optimally.

add_node_for_composite_dataset(layer: LayerItem, product_dataset: ProductDataset)[source]
add_node_for_image_dataset(layer: LayerItem, product_dataset: ProductDataset)[source]
add_node_for_layer(layer: LayerItem)[source]
add_node_for_lines_dataset(layer: LayerItem, product_dataset: ProductDataset) VisualNode[source]
add_node_for_mc_image_dataset(layer: LayerItem, product_dataset: ProductDataset) None[source]

Create and add a new node for a multichannel images to the SceneGraphManager.

Depending on the system configuration either a node with or without tiling is created from the product_dataset and inserted as a child of the layer’s node in the scene graph.

Parameters:
  • layer – LayerItem which owns the ProductDataset

  • product_dataset – ProductDataset to create the multichannel image for

add_node_for_points_dataset(layer: LayerItem, product_dataset: ProductDataset) VisualNode[source]
add_node_for_system_generated_data(layer: LayerItem)[source]
apply_presentation_to_image_node(image: Image, presentation: Presentation, visible: bool | None = None)[source]

Apply all relevant and set properties (not None) of the given presentation to the given image.

Visibility can be explicitly overridden, because this is (at least for now) the only property where a dataset may deviate from the layer presentation; it depends on whether the dataset is active in the layer’s timeline.

Parameters:
  • image – the image node which should get the new presentation

  • presentation – to apply, usually the presentation of the owning layer

  • visible

change_dataset_nodes_color_limits(change_dict)[source]
change_dataset_nodes_colormap(change_dict)[source]
change_dataset_nodes_gamma(change_dict)[source]
change_dataset_visible(dataset_uuid: UUID, visible: bool)[source]
change_layer_opacity(layer_uuid: UUID, opacity: float)[source]
change_layer_visible(layer_uuid: UUID, visible: bool)[source]
change_node_for_composite_dataset(layer: LayerItem, product_dataset: ProductDataset)[source]
change_tool(name: Tool)[source]
clear_pending_polygon()[source]
colormaps = None
copy_polygon(old_name, new_name)[source]
cycle_borders_color()[source]
cycle_latlon_grid_color()[source]
datasets = None
get_screenshot_array(frame_range=None)[source]

Get numpy arrays representing the current canvas.

has_pending_polygon()[source]
map_to_colors_autoscaled(colormap, values, m=2)[source]

Get a list of colors by mapping each entry in values by the given colormap.

The mapping range is adjusted automatically to m times the standard deviation from the mean. This ignores outliers in the calculation of the mapping range.

Caution: this is an expensive operation and must not be called in tight loops.

Parameters:
  • colormap – the colormap to apply

  • values – the values to map to colors

  • m – factor to stretch the standard deviation around the mean to define the mapping range

Returns:

list of mapped colors in the same order as the input values

next_tool()[source]
on_mouse_press_point(event)[source]

Handle mouse events that mean we are using the point probe.

on_mouse_press_region(event)[source]

Handle mouse events that mean we are using the point probe.

on_new_polygon(probe_name, points, **kwargs)[source]
on_point_probe_set(probe_name, state, xy_pos, **kwargs)[source]
on_view_change(scheduler)[source]

Simple event handler for when we need to reassess image datasets.

purge_dataset(uuid_removed: UUID)[source]

Dataset has been purged from document (no longer used anywhere) - flush it all out :param uuid_removed: UUID of the dataset that is to be removed :return:

queue = None
remove_layer_node(uuid_removed: UUID)[source]

Layer will be removed, but before it can be removed correctly the scene graph node has to be removed. :param uuid_removed: UUID of the layer that will be removed

remove_polygon(name=None)[source]

Remove a polygon from the SGM or clear the pending polygon if it exists.

set_projection(area_display_name: str, center=None)[source]
show_only_polygons(polygon_names_to_show)[source]
texture_shape = None
update_basic_dataset(uuid: UUID, kind: Kind)[source]

Push the data (content) of a basic dataset again to the associated scene graph node.

This method shall be called whenever the data of a basic dataset changes. :param uuid: identifier of the dataset :param kind: kind of the dataset / data content.

update_layers_z(uuids: list)[source]
uwsift.view.scene_graph.get_configured_latlon_grid_resolution() float[source]

uwsift.view.test_visuals module

Tests for the MultiChannelImageVisual.

uwsift.view.test_visuals.test_multiband_visual()[source]

uwsift.view.texture_atlas module

.py

PURPOSE gloo.Program wrappers for different purposes such as tile drawing

REFERENCES

REQUIRES

author:

R.K.Garcia <rayg@ssec.wisc.edu>

copyright:

2015 by University of Wisconsin Regents, see AUTHORS for more details

license:

GPLv3, see LICENSE for more details

class uwsift.view.texture_atlas.MultiChannelGPUScaledTexture2D(data, **texture_kwargs)[source]

Bases: object

Wrapper class around individual textures.

This helper class allows for easier handling of multiple textures that represent individual R, G, and B channels of an image.

check_data_format(data_arrays)[source]
property clim

Get color limits used when rendering the image (cmin, cmax).

property clim_normalized
property internalformat
property interpolation
scale_and_set_data(data, offset=None, copy=False)[source]

Scale and set data for one or all sub-textures.

Parameters:
  • data (list | ndarray) – Texture data in the form of a numpy array or as a list of numpy arrays. If a list is provided then it must be the same length as num_channels for this texture. If a numpy array is provided then offset should also be provided with the first value representing which sub-texture to update. For example, offset=(1, 0, 0) would update the entire the second (index 1) sub-texture with an offset of (0, 0). The list can also contain None to not update the sub-texture at that index.

  • offset (tuple | None) – Offset into the texture where to write the provided data. If None then data will be written with no offset (0). If provided as a 2-element tuple then that offset will be used for all sub-textures. If a 3-element tuple then the first offset index represents the sub-texture to update.

set_clim(clim)[source]
property textures
class uwsift.view.texture_atlas.MultiChannelTextureAtlas2D(data, **texture_kwargs)[source]

Bases: MultiChannelGPUScaledTexture2D

Helper texture for working with RGB images in SIFT.

set_tile_data(tile_idx, data_arrays, copy=False)[source]
class uwsift.view.texture_atlas.TextureAtlas2D(texture_shape, tile_shape=(512, 512), **texture_kwargs)[source]

Bases: GPUScaledTexture2D

A 2D Texture Array structure implemented as a 2D Texture Atlas.

set_tile_data(tile_idx, data, copy=False)[source]

Write a single tile of data into the texture.

uwsift.view.tile_calculator module

Supports calculations used throughout the library and application.

class uwsift.view.tile_calculator.TileCalculator(name, image_shape, ul_origin, pixel_rez, tile_shape=(512, 512), texture_shape=(2, 16), projection='+proj=merc +datum=WGS84 +ellps=WGS84 +over', wrap_lon=False)[source]

Bases: object

Common calculations for geographic image tile groups in an array or file

Tiles are identified by (iy,ix) zero-based indicators.

OVERSAMPLED = 'oversampled'
UNDERSAMPLED = 'undersampled'
WELLSAMPLED = 'wellsampled'
calc_stride(visible, texture=None)[source]

given world geometry and sampling as a ViewBox or Resolution tuple calculate a conservative stride value for rendering a set of tiles :param visible: ViewBox or Resolution with world pixels per screen pixel :param texture: ViewBox or Resolution with texture resolution as world pixels per screen pixel

calc_texture_coordinates(ttile_idx, factor_rez, offset_rez, tessellation_level=1)[source]

Get texture coordinates for one tile as a quad.

Parameters:

ttile_idx – int, texture 1D index that maps to some internal texture tile location

calc_tile_fraction(tiy, tix, stride)[source]

Calculate the fractional components of the specified tile

Returns:

Two Resolution objects stating the relative size

of the tile compared to a whole tile and the offset from the origin of a whole tile.

Return type:

(factor, offset)

calc_tile_slice(tiy, tix, stride)[source]

Calculate the slice needed to get data.

The returned slice assumes the original image data has already been reduced by the provided stride.

Parameters:
  • tiy (int) – Tile Y index (down is positive)

  • tix (int) – Tile X index (right is positive)

  • stride (tuple) – (Original data Y-stride, Original data X-stride)

calc_vertex_coordinates(tiy, tix, stridey, stridex, factor_rez, offset_rez, tessellation_level=1)[source]
calc_view_extents(canvas_point, image_point, canvas_size, dx, dy)[source]
visible_tiles(visible_geom, stride=None, extra_tiles_box=None) IndexBox[source]

Get box of tile indexes for visible tiles that should be drawn.

Box indexes should be iterated with typical Python start:stop style (inclusive start index, exclusive stop index). Tiles are expected to be indexed (iy, ix) integer pairs. The extra_tiles_box value specifies how many extra tiles to include around each edge.

uwsift.view.tile_calculator.calc_overview_stride(image_shape_y, image_shape_x, tile_shape)[source]
uwsift.view.tile_calculator.calc_pixel_size(canvas_point, image_point, canvas_size)[source]
uwsift.view.tile_calculator.calc_stride(v_dx, v_dy, t_dx, t_dy, overview_stride_y, overview_stride_x)[source]
uwsift.view.tile_calculator.calc_texture_coordinates(tiy, tix, factor_rez_dy, factor_rez_dx, tessellation_level, texture_size_y, texture_size_x, tile_shape_y, tile_shape_x, quads)[source]
uwsift.view.tile_calculator.calc_tile_fraction(tiy, tix, stride_y, stride_x, image_y, image_x, tile_y, tile_x)[source]
uwsift.view.tile_calculator.calc_tile_slice(tiy, tix, stride_y, stride_x, image_shape, tile_shape)[source]
uwsift.view.tile_calculator.calc_vertex_coordinates(tiy, tix, stridey, stridex, factor_rez_dy, factor_rez_dx, offset_rez_dy, offset_rez_dx, tessellation_level, p_dx, p_dy, tile_shape_y, tile_shape_x, image_center_y, image_center_x, quads)[source]
uwsift.view.tile_calculator.calc_view_extents(image_extents_box: Box, canvas_point, image_point, canvas_size, dx, dy) Box[source]
uwsift.view.tile_calculator.clip(v, n, x)[source]
uwsift.view.tile_calculator.get_reference_points(img_cmesh, img_vbox)[source]

Get two image reference point indexes.

This function will return the two nearest reference points to the center of the viewed canvas. The first argument img_cmesh is all valid image mesh points that were successfully transformed to the view projection. The second argument img_vbox is these same mesh points, but in the original image projection units.

Parameters:
  • img_cmesh – (N, 2) array of valid points across the image space

  • img_vbox – (N, 2) array of valid points across the image space

Returns:

(reference array index 1, reference array index 2)

Raises:

ValueError if not enough valid points to create two reference points

uwsift.view.tile_calculator.isclose(a, b)[source]

Implementation of numpy.isclose() since it is currently not supported by numba.

uwsift.view.tile_calculator.max_tiles_available(image_shape_y, image_shape_x, tile_shape_y, tile_shape_x, stride_y, stride_x)[source]
uwsift.view.tile_calculator.visible_tiles(z_dy, z_dx, tile_size_dy, tile_size_dx, image_center_y, image_center_x, image_shape_y, image_shape_x, tile_shape_y, tile_shape_x, v_bottom, v_left, v_top, v_right, v_dy, v_dx, stride_y, stride_x, x_bottom, x_left, x_top, x_right)[source]

uwsift.view.transform module

VisPy Transform objects to handle some of the more complex projections.

SIFT uses PROJ.4 to define geographic projections and these are rarely possible to implement in Matrix transforms that come with VisPy.

class uwsift.view.transform.GLSL_Adapter(text: str)[source]

Bases: TextExpression

TextExpression subclass for parsing Macro definitions from .glsl header files and exposing them to vispy.

This class makes macro definitions accessible to vispy’s shader code processing. Assumes .glsl code to be parsed is accessible as python string. For reading .glsl header code from a file see GLSL_FileAdapter subclass.

Parameters:

text (str) – Actual .glsl code string.

property expr_list: List[VariableDeclaration]
class uwsift.view.transform.GLSL_FileAdapter(file_path: str)[source]

Bases: GLSL_Adapter

GLSL_Adapter subclass adding the functionality to read .glsl header code from files.

Parameters:

file_path (str) – Path to .glsl header file.

class uwsift.view.transform.PROJ4Transform(proj4_str, inverse=False)[source]

Bases: BaseTransform

Isometric = False
Linear = False
NonScaling = False
Orthogonal = False
glsl_imap = None
glsl_map = None
imap(coords)[source]

Inverse map coordinates

Parameters:

coords (array-like) – Coordinates to inverse map.

property is_geographic
map(coords)[source]

Map coordinates

Parameters:

coords (array-like) – Coordinates to map.

class uwsift.view.transform.VariableDeclaration(name: str, text: str)[source]

Bases: TextExpression

TextExpression subclass for exposing GLSL variables to vispy glsl interface.

Parameters:
  • name (str) – Name of the variable.

  • text (str) – Rvalue to be assigned to the variable.

definition(names, version=None, shader=None) str[source]

Return the GLSL definition for this object. Use obj_names to determine the names of dependencies, and version (number, qualifier) to adjust code output.

property name: str

The name of this shader object.

uwsift.view.transform.eqc_init(proj_dict)[source]
uwsift.view.transform.geos_init(proj_dict)[source]
uwsift.view.transform.latlong_init(proj_dict)[source]
uwsift.view.transform.lcc_init(proj_dict)[source]
uwsift.view.transform.merc_init(proj_dict)[source]
uwsift.view.transform.pj_msfn_py(sinphi, cosphi, es)[source]
uwsift.view.transform.pj_tsfn_py(phi, sinphi, e)[source]
uwsift.view.transform.stere_init(proj_dict)[source]

uwsift.view.visuals module

visuals.py

PURPOSE Dataset representation - the “physical” realization of content to draw on the map. A dataset representation can have multiple levels of detail.

REFERENCES

REQUIRES

author:

R.K.Garcia <rayg@ssec.wisc.edu>

copyright:

2014 by University of Wisconsin Regents, see AUTHORS for more details

license:

GPLv3, see LICENSE for more details

class uwsift.view.visuals.ArrayProxy(ndim, shape)[source]

Bases: object

class uwsift.view.visuals.GradientLineVisual(pos=None, color=(0.5, 0.5, 0.5, 1), width=1, arrow_size=None, connect='strip', method='gl', antialias=False)[source]

Bases: LineVisual

Gradient line visual

Parameters:
  • pos (array) – Array of shape (…, 2) or (…, 3) specifying vertex coordinates.

  • color (Color, tuple, or array) – The color to use when drawing the line. If an array is given, it must be of shape (…, 4) and provide one rgba color per vertex. Can also be a colormap name, or appropriate Function.

  • width – The width of the line in px. Line widths > 1px are only guaranteed to work when using ‘agg’ method.

  • connect (str or array) –

    Determines which vertices are connected by lines.

    • ”strip” causes the line to be drawn with each vertex connected to the next.

    • ”segments” causes each pair of vertices to draw an independent line segment

    • numpy arrays specify the exact set of segment pairs to connect.

  • method (str) –

    Mode to use for drawing.

    • ”agg” uses anti-grain geometry to draw nicely antialiased lines with proper joins and endcaps.

    • ”gl” uses OpenGL’s built-in line rendering. This is much faster, but produces much lower-quality results and is not guaranteed to obey the requested line width or join/endcap styles.

  • antialias (bool) – Enables or disables antialiasing. For method=’gl’, this specifies whether to use GL’s line smoothing, which may be unavailable or inconsistent on some platforms.

method(method)[source]

The current drawing method

class uwsift.view.visuals.LinesVisual(arrows: ndarray, colors: ndarray | None = None)[source]

Bases: TipAlignedArrowVisual

default_colors = {'green': (0.0, 1.0, 0.0, 1.0), 'red': (1.0, 0.0, 0.0, 1.0)}
class uwsift.view.visuals.MultiChannelImageVisual(data_arrays, clim='auto', gamma=1.0, **kwargs)[source]

Bases: ImageVisual

Visual subclass displaying an image from three separate arrays.

Note this Visual uses only GPU scaling, unlike the ImageVisual base class which allows for CPU or GPU scaling.

Parameters:
  • data (list) – A 3-element list of numpy arrays with 2 dimensons where the arrays are sorted by (R, G, B) order. These will be put together to make an RGB image. The list can contain None meaning there is no value for this channel currently, but it may be filled in later. In this case the underlying GPU storage is still allocated, but pre-filled with NaNs. Note that each channel may have different shapes.

  • cmap (str | Colormap) – Unused by this Visual, but is still provided to the ImageVisual base class.

  • clim (str | tuple | list | None) – Limits of each RGB data array. If provided as a string it must be “auto” and the limits will be computed on the fly. If a 2-element tuple then it will be considered the color limits for all channel arrays. If provided as a 3-element list of 2-element tuples then they represent the color limits of each channel array.

  • gamma (float | list) – Gamma to use during colormap lookup. Final value will be computed val**gamma for each RGB channel array. If provided as a float then it will be used for each channel. If provided as a 3-element tuple then each value is used for the separate channel arrays. Default is 1.0 for each channel.

  • **kwargs (dict) – Keyword arguments to pass to ImageVisual. Note that this Visual does not allow for texture_format to be specified and is hardcoded to r32f internal texture format.

property clim

Get color limits used when rendering the image (cmin, cmax).

property cmap

Get the colormap object applied to luminance (single band) data.

property gamma

Get the gamma used when rendering the image.

set_data(data_arrays)[source]

Set the data

Parameters:

image (array-like) – The image data.

property size

Get size of the image (width, height).

class uwsift.view.visuals.NEShapefileLinesVisual(filepath, double=False, **kwargs)[source]

Bases: ShapefileLinesVisual

Visual class for handling shapefiles from Natural Earth.

http://www.naturalearthdata.com/

There should be no difference in the format of the file, but some assumptions can be made with data from Natural Earth about filenaming, data resolution, fields and other record information that is normally included in most Natural Earth files.

class uwsift.view.visuals.PrecomputedIsocurveVisual(verts, connects, level_indexes, levels, **kwargs)[source]

Bases: IsocurveVisual

IsocurveVisual that can use precomputed paths.

property clim
property zoom_level
class uwsift.view.visuals.RGBCompositeImageVisual(data, origin_x, origin_y, cell_width, cell_height, **image_kwargs)[source]

Bases: SIFTMultiChannelTiledGeolocatedMixin, TiledGeolocatedImageVisual, MultiChannelImageVisual

class uwsift.view.visuals.SIFTMultiChannelTiledGeolocatedMixin(data, *area_params, tile_shape=(512, 512), texture_shape=(2, 16), wrap_lon=False, projection='+proj=merc +datum=WGS84 +ellps=WGS84 +over', **visual_kwargs)[source]

Bases: SIFTTiledGeolocatedMixin

set_channels(data_arrays, shape=None, cell_width=None, cell_height=None, origin_x=None, origin_y=None)[source]
class uwsift.view.visuals.SIFTTiledGeolocatedMixin(data, *area_params, tile_shape=(512, 512), texture_shape=(2, 16), wrap_lon=False, projection='+proj=merc +datum=WGS84 +ellps=WGS84 +over', **visual_kwargs)[source]

Bases: object

assess()[source]

Determine if a retile is needed.

Tell workspace we will be needed

determine_reference_points()[source]
get_view_box()[source]

Calculate shown portion of image and image units per pixel

This method utilizes a precomputed “mesh” of relatively evenly spaced points over the entire image space. This mesh is transformed to the canvas space (-1 to 1 user-viewed space) to figure out which portions of the image are currently being viewed and which portions can actually be projected on the viewed projection.

While the result of the chosen method may not always be completely accurate, it should work for all possible viewing cases.

retile(data, preferred_stride, tile_box)[source]

Get data from workspace and retile/retexture as needed.

set_retiled(preferred_stride, tile_box, tiles_info, vertices, tex_coords)[source]
class uwsift.view.visuals.ShapefileLinesVisual(filepath, double=False, **kwargs)[source]

Bases: LineVisual

class uwsift.view.visuals.TextureTileState(num_tiles)[source]

Bases: object

Object to hold the state of the current tile texture.

Terms:

  • itile: Image Tile, Tile in the image being shown. Coordinates are (Y, X)

  • lod: Level of Detail, Level of detail for the image tiles (1 highest - 5 lower)

  • ttile: Texture Tile, Tile in the actual GPU texture storage (0 to num_tiles)

This class is meant to be used as a bookkeeper/consultant right before taking action on the Texture Atlas.

add_tile(itile_idx, expires=True)[source]

Get texture index for new tile. If tile is already known return its current location.

Note, this should be called even when the caller knows the tile exists to refresh the “age”.

reset()[source]
class uwsift.view.visuals.TiledGeolocatedImageVisual(data, origin_x, origin_y, cell_width, cell_height, **image_kwargs)[source]

Bases: SIFTTiledGeolocatedMixin, ImageVisual

set_data(image)[source]

Set the data

Parameters:

image (array-like) – The image data.

class uwsift.view.visuals.TipAlignedArrowVisual(pos=None, color=(0.5, 0.5, 0.5, 1), width=1, connect='strip', method='gl', antialias=False, arrows=None, arrow_type='stealth', arrow_size=None, arrow_color=(0.5, 0.5, 0.5, 1))[source]

Bases: ArrowVisual

Almost exactly the same as vispy’s ArrowVisual except for the arrow’s head not being centered at the end of the arrow’s line but the arrows tip pointing to the coordinate of the arrow’s line.

Parameters:
  • pos (array) – Array of shape (…, 2) or (…, 3) specifying vertex coordinates.

  • color (Color, tuple, or array) – The color to use when drawing the line. If an array is given, it must be of shape (…, 4) and provide one rgba color per vertex. Can also be a colormap name, or appropriate Function.

  • width – The width of the line in px. Line widths > 1px are only guaranteed to work when using ‘agg’ method.

  • connect (str or array) –

    Determines which vertices are connected by lines.

    • ”strip” causes the line to be drawn with each vertex connected to the next.

    • ”segments” causes each pair of vertices to draw an independent line segment

    • numpy arrays specify the exact set of segment pairs to connect.

  • method (str) –

    Mode to use for drawing.

    • ”agg” uses anti-grain geometry to draw nicely antialiased lines with proper joins and endcaps.

    • ”gl” uses OpenGL’s built-in line rendering. This is much faster, but produces much lower-quality results and is not guaranteed to obey the requested line width or join/endcap styles.

  • antialias (bool) – Enables or disables antialiasing. For method=’gl’, this specifies whether to use GL’s line smoothing, which may be unavailable or inconsistent on some platforms.

  • arrows (array) – A (N, 4) or (N, 6) matrix where each row contains the (x, y) or the (x, y, z) coordinate of the first and second vertex of the arrow body. Remember that the second vertex is used as center point for the arrow head, and the first vertex is only used for determining the arrow head orientation.

  • arrow_type (string) –

    Specify the arrow head type, the currently available arrow head types are:

    • stealth

    • curved

    • triangle_30

    • triangle_60

    • triangle_90

    • angle_30

    • angle_60

    • angle_90

    • inhibitor_round

  • arrow_size (float) – Specify the arrow size

  • arrow_color (Color, tuple, or array) – The arrow head color. If an array is given, it must be of shape (…, 4) and provide one rgba color per arrow head. Can also be a colormap name, or appropriate Function.

Module contents

View owns the GPU and the user interface. Delegates from the Model and elsewhere provide it information it needs to react rapidly.