How to use the uwsift.common.Info.DISPLAY_NAME function in uwsift

To help you get started, we’ve selected a few uwsift examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ssec / sift / uwsift / workspace / workspace.py View on Github external
def recently_used_products(self, n=32) -> Dict[UUID, str]:
        with self._inventory as s:
            return OrderedDict((p.uuid, p.info[Info.DISPLAY_NAME])
                               for p in s.query(Product).order_by(Product.atime.desc()).limit(n).all())
github ssec / sift / uwsift / model / document.py View on Github external
def frame_info_for_product(self, prod: Product = None, uuid: UUID = None,
                               when_overlaps: Span = None) -> typ.Optional[FrameInfo]:
        """Generate info struct needed for timeline representation, optionally returning None if outside timespan of interest
        """
        if prod is None:
            with self.mdb as S:  # this is a potential performance toilet, but OK to use sparsely
                prod = S.query(Product).filter_by(uuid_str=str(uuid)).first()
                return self.frame_info_for_product(prod=prod, when_overlaps=when_overlaps)
        prod_e = prod.obs_time + prod.obs_duration
        if (when_overlaps is not None) and ((prod_e <= when_overlaps.s) or (prod.obs_time >= when_overlaps.e)):
            # does not intersect our desired Span, skip it
            return None
        nfo = prod.info
        # DISPLAY_NAME has DISPLAY_TIME as part of it, FIXME: stop that
        dt = nfo[Info.DISPLAY_TIME]
        dn = nfo[Info.DISPLAY_NAME].replace(dt, '').strip()
        fin = FrameInfo(
            uuid=prod.uuid,
            ident=prod.ident,
            when=Span(prod.obs_time, prod.obs_duration),
            # FIXME: new model old model
            state=self.product_state(prod.uuid),
            primary=dn,
            secondary=dt,  # prod.obs_time.strftime("%Y-%m-%d %H:%M:%S")
            # thumb=
        )
        return fin
github ssec / sift / uwsift / view / layer_details.py View on Github external
return

        # otherwise display information on the selected layer(s)
        # figure out the info shared between all the layers currently selected
        presentation_info = self.document.current_layer_set
        for layer_uuid in selected_uuid_list:
            layer_info = self.document.get_info(uuid=layer_uuid)

            this_prez = None
            for prez_tuple in presentation_info:
                if prez_tuple.uuid == layer_uuid:
                    this_prez = prez_tuple
                    break

            # compare our various values
            self._update_if_different(shared_info, layer_info, Info.DISPLAY_NAME)
            self._update_if_different(shared_info, layer_info, Info.DISPLAY_TIME)
            self._update_if_different(shared_info, layer_info, Info.INSTRUMENT)
            self._update_if_different(shared_info, this_prez, attr='colormap')
            self._get_shared_color_limits(shared_info, layer_info, this_prez)
            self._get_code_block(shared_info, layer_uuid)

            # wavelength
            wl = layer_info.get(Info.CENTRAL_WAVELENGTH)
            fmt = "{:0.2f} µm"
            if isinstance(wl, (tuple, list)):
                wl = [fmt.format(x) if x is not None else '---' for x in wl]
                wl = "(" + ", ".join(wl) + ")"
            else:
                wl = fmt.format(wl) if wl is not None else '---'
            if Info.CENTRAL_WAVELENGTH not in shared_info:
                shared_info[Info.CENTRAL_WAVELENGTH] = wl
github ssec / sift / uwsift / view / export_image.py View on Github external
not self._overwrite_dialog()):
            return

        # get canvas screenshot arrays (numpy arrays of canvas pixels)
        img_arrays = self.sgm.get_screenshot_array(info['frame_range'])
        if not img_arrays or len(uuids) != len(img_arrays):
            LOG.error("Number of frames does not equal number of UUIDs")
            return

        images = [(u, Image.fromarray(x)) for u, x in img_arrays]

        if info['colorbar'] is not None:
            images = [(u, self._append_colorbar(info['colorbar'], im, u)) for (u, im) in images]

        if info['include_footer']:
            banner_text = [self.doc[u][Info.DISPLAY_NAME] if u else "" for u, im in images]
            images = [(u, self._add_screenshot_footer(im, bt, font_size=info['font_size'])) for (u, im), bt in
                      zip(images, banner_text)]

        imageio_format = get_imageio_format(filenames[0])
        if imageio_format:
            format_name = imageio_format.name
        elif filenames[0].upper().endswith('.M4V'):
            format_name = 'MP4'
        else:
            raise ValueError("Not sure how to handle file with format: {}".format(filenames[0]))

        if is_video_filename(filenames[0]) and len(images) > 1:
            params = self._get_animation_parameters(info, images)
            if not info['loop'] and is_gif_filename(filenames[0]):
                # rocking animation
                # we want frames 0, 1, 2, 3, 2, 1
github ssec / sift / uwsift / view / layer_details.py View on Github external
def _display_shared_info(self, shared_info: defaultdict):
        self.name_text.setText("Name: " + shared_info[Info.DISPLAY_NAME])
        self.time_text.setText("Time: " + shared_info[Info.DISPLAY_TIME])
        self.instrument_text.setText("Instrument: " + shared_info[Info.INSTRUMENT])
        self.wavelength_text.setText("Wavelength: " + shared_info[Info.CENTRAL_WAVELENGTH])
        self.colormap_text.setText("Colormap: " + (shared_info["colormap"] or ""))
        self.clims_text.setText("Color Limits: " + shared_info["climits"])
        self.composite_codeblock.setText(shared_info['codeblock'])

        # format colormap
        if not shared_info["colormap"]:
            self.cmap_vis.setHtml("")
        else:
            cmap_html = COLORMAP_MANAGER[shared_info["colormap"]]._repr_html_()
            cmap_html = cmap_html.replace("height", "border-collapse: collapse;\nheight")
            self.cmap_vis.setHtml(
                """<div>%s</div>""" % (cmap_html,))
github ssec / sift / uwsift / view / probes.py View on Github external
def set_possible_layers(self, uuid_list, do_rebuild_plot=False):
        """Given a list of layer UUIDs, set the names and UUIDs in the drop downs
        """

        # make a uuid map because the mapping in a combo box doesn't work with objects
        self.uuidMap = {}

        # clear out the current lists
        self.xDropDown.clear()
        self.yDropDown.clear()

        # fill up our lists of layers
        for uuid in uuid_list:
            layer = self.document[uuid]
            layer_name = layer.get(Info.DISPLAY_NAME, "??unknown layer??")
            if layer.get(Info.KIND, None) == Kind.RGB:  # skip RGB layers
                continue
            uuid_string = str(uuid)
            self.xDropDown.addItem(layer_name, uuid_string)
            self.yDropDown.addItem(layer_name, uuid_string)

            self.uuidMap[uuid_string] = uuid

        # if possible, set the selections back to the way they were
        need_rebuild = False
        xIndex = self.xDropDown.findData(str(self.xSelectedUUID))
        if xIndex >= 0:
            # Selection didn't change
            self.xDropDown.setCurrentIndex(xIndex)
        elif self.xDropDown.count() > 0:
            # Setting to a new layer
github ssec / sift / uwsift / view / probes.py View on Github external
def _rebuild_plot_task(self, x_uuid, y_uuid, polygon, point_xy, plot_versus=False):

        # if we are plotting only x and we have a selected x and a polygon
        if not plot_versus and x_uuid is not None and polygon is not None:
            yield {TASK_DOING: 'Probe Plot: Collecting polygon data...', TASK_PROGRESS: 0.0}

            # get the data and info we need for this plot
            data_polygon = self.workspace.get_content_polygon(x_uuid, polygon)
            unit_info = self.document[x_uuid][Info.UNIT_CONVERSION]
            data_polygon = unit_info[1](data_polygon)
            title = self.document[x_uuid][Info.DISPLAY_NAME]

            # get point probe value
            if point_xy:
                x_point = self.workspace.get_content_point(x_uuid, point_xy)
                x_point = unit_info[1](x_point)
            else:
                x_point = None

            # plot a histogram
            yield {TASK_DOING: 'Probe Plot: Creating histogram plot', TASK_PROGRESS: 0.25}
            self.plotHistogram(data_polygon, title, x_point)

        # if we are plotting x vs y and have x, y, and a polygon
        elif plot_versus and x_uuid is not None and y_uuid is not None and polygon is not None:
            yield {TASK_DOING: 'Probe Plot: Collecting polygon data (layer 1)...', TASK_PROGRESS: 0.0}
github ssec / sift / uwsift / workspace / importer.py View on Github external
def generate_guidebook_metadata(layer_info) -> Mapping:
    guidebook = get_guidebook_class(layer_info)
    # also get info for this layer from the guidebook
    gbinfo = guidebook.collect_info(layer_info)
    layer_info.update(gbinfo)  # FUTURE: should guidebook be integrated into DocBasicLayer?

    # add as visible to the front of the current set, and invisible to the rest of the available sets
    layer_info[Info.COLORMAP] = guidebook.default_colormap(layer_info)
    layer_info[Info.CLIM] = guidebook.climits(layer_info)
    layer_info[Info.VALID_RANGE] = guidebook.valid_range(layer_info)
    if Info.DISPLAY_TIME not in layer_info:
        layer_info[Info.DISPLAY_TIME] = guidebook._default_display_time(layer_info)
    if Info.DISPLAY_NAME not in layer_info:
        layer_info[Info.DISPLAY_NAME] = guidebook._default_display_name(layer_info)

    if 'level' in layer_info:
        # calculate contour_levels and zoom levels
        increments = get_contour_increments(layer_info)
        vmin, vmax = layer_info[Info.VALID_RANGE]
        contour_levels = get_contour_levels(vmin, vmax, increments)
        layer_info['contour_levels'] = contour_levels

    return layer_info