Beispiel #1
0
    def run(self, custom_classfy):
        """
        遍历config文件和音频路径,将其新平台文本格式信息写到output/result.txt文件中
        :param custom_classfy: 自定义分包条数,默认按spk音频数分包
        """
        logger.debug('遍历wav_name,text信息')
        wav_suf = 'wav'
        counter = 0
        wavs_info_map = {}

        for SPK, wav_name, content in self.get_info():  # 遍历说话人id,音频名,音频内容 信息
            logger.debug('[wav_info] %s - %s - %s ' % (SPK, wav_name, content))

            if wav_name not in self.wav_time_map:
                logger.warning('[%s] 未找到音频' % wav_name)
                continue

            wav_time = self.wav_time_map.get(wav_name)
            if not wav_time:
                continue

            wav_info = [  # 填充新平台文本格式
                {
                    "Wav_name": wav_name,
                    "Length_time": wav_time,
                    "Data": [
                        {
                            "text": content,
                            "start_time": 0,
                            "end_time": wav_time
                        }
                    ],
                    "Wav_suf": wav_suf
                }
            ]

            if custom_classfy:  # 指定分包数的模式
                id = f'line_{counter}'
                if id not in wavs_info_map:
                    wavs_info_map[id] = [wav_info]

                else:
                    if len(wavs_info_map[id]) == custom_classfy - 1:
                        counter += 1

                    wavs_info_map[id].append(wav_info)

            else:  # 默认分包模式
                if SPK not in wavs_info_map:
                    wavs_info_map[SPK] = [wav_info]
                else:
                    wavs_info_map[SPK].append(wav_info)

        logger.info(
            '处理完毕! 共 %s 批次 [%s]' % (len(wavs_info_map.keys()), wavs_info_map.keys()) if not custom_classfy else (
                counter, len(reduce(lambda x, y: x + y, wavs_info_map.values()))))

        with open(self._save_path, 'w', encoding='utf-8') as f:
            for key, value in wavs_info_map.items():
                f.write(json.dumps(value, ensure_ascii=False) + '\n')
 def advanced_prompt(self):
     logger.info('Opening advanced search window')
     if (not AdvancedSearchDialog.singleton):
         AdvancedSearchDialog(self, self.__root). \
             wm_iconbitmap(ICO)
     else:
         logger.warning('Found existing advanced search window, canceling')
Beispiel #3
0
    def close_polygon(self, event, plot, fl, fig, fill=False):
        if len(self.__coordinates) > 3:
            index = self.__can_draw()
            if index > -1:
                logger.debug("Creating polygon from points")
                a1 = tuple_to_nparray(self.__coordinates[index])
                a2 = tuple_to_nparray(self.__coordinates[index + 1])
                b1 = tuple_to_nparray(self.__coordinates[-1])
                b2 = tuple_to_nparray(self.__coordinates[-2])
                x = get_intersection(a1, a2, b1, b2)
                pair = nparray_to_tuple(x)
                self.__coordinates[index] = pair

                del self.__coordinates[:index]
                self.__coordinates.pop()
                for line in self.__lines:
                    line.remove()
                self.__drawing_line.remove()
                self.__drawing_line = None
                self.__lines = []
                self.draw(fig, plot, fill)
                self.__plot = plot
                self.__hdf = fl
                return True
        else:
            logger.warning('Not enough points')
Beispiel #4
0
 def close(self):
     """
     Checks if the all the shapes are saved. If a shape is unsaved, the
     program will ask the user whether save or not, and then close the
     program. Also saves the session settings to the config.json file
     """
     logger.info('Writing session settings')
     CONF.opened.change(True)
     CONF.write_config()
     if not self.__shapemanager.is_all_saved():
         logger.warning('Unsaved shapes found')
         answer = tkMessageBox. \
             askyesnocancel('Close Without Saving',
                            'There are unsaved shapes on the plot. Save these shapes?')
         if answer is True:
             logger.info('Saving shapes')
             saved = self.save_json()
             if saved:
                 error_check()
                 self.__root.destroy()
             else:
                 return
         elif answer is False:
             logger.info('Dumping unsaved shapes')
             error_check()
             self.__root.destroy()
         elif answer is None:
             return
     else:
         error_check()
         self.__root.destroy()
Beispiel #5
0
    def fill_rectangle(self, event):
        """
        Informs the correct shape list's blank object to draw a rectangle to the screen
        using the provided coordinates

        :param event: A backend passed ``matplotlib.backend_bases.MouseEvent`` object
        """
        if self.__current_plot == Plot.baseplot:
            logger.warning("Cannot draw to BASE_PLOT")
            return
        if event.xdata and event.ydata:
            if len(self.__current_list[-1].get_coordinates()) is 0:
                return
            logger.debug('Filling: %d, %d' % (event.xdata, event.ydata))
            logger.info('Creating rectangle')
            self.__current_list[-1].fill_rectangle(event, self.__current_plot,
                                                   self.__hdf, self.__figure,
                                                   ShapeManager.outline_toggle)
            self.__current_list[-1].set_tag(self.generate_tag())
            self.__current_list.append(Shape(self.__canvas))
            self.__canvas.show()
        else:
            logger.error('Bounds out of plot range, skipping')
            self.__current_list[-1].set_coordinates([])
            self.__canvas._tkcanvas.delete(self.__current_list[-1].lastrect)
Beispiel #6
0
    def plot_point(self, event):
        """
        Plot a single point to the screen for the current shape object,
        if other points exist, a line is drawn between then until a
        polygon is formed

        :param event: A ``matplotlib.backend_bases.MouseEvent`` passed object
        """
        if self.__current_plot == Plot.baseplot:
            logger.warning('Cannot draw to the base plot')
            return
        if event.xdata and event.ydata:
            logger.info('Plotting point at %.5f, %.5f' %
                        (event.xdata, event.ydata))
            check = self.__current_list[-1].plot_point(
                event, self.__current_plot, self.__hdf, self.__figure,
                ShapeManager.outline_toggle)
            self.__drawing = True

            if check:
                self.__current_list[-1].set_tag(self.generate_tag())
                self.__current_list.append(Shape(self.__canvas))
                self.__drawing = False
                self.__canvas.show()

        else:
            logger.error("Point to plot is out or range, skipping")
Beispiel #7
0
def interpolation_search(sorted_list, to_find, variance):
    """
    Interpolation  search algorithm for determining the location of the
    point according to sorted_list, the sorted_list has a constant step
    and can thus give this algorithm the complexity of just ``O(log log(n))``

    :param list sorted_list: The sorted list to search in
    :param float to_find: The point to find
    :param float variance: A constant variance allowed for finding the point

    :rtype: float
    """
    low = 0
    high = len(sorted_list) - 1

    while sorted_list[low] <= to_find <= sorted_list[high]:
        mid = int(low + ((to_find - sorted_list[low]) * (high - low)) /
                  (sorted_list[high] - sorted_list[low]))

        if sorted_list[mid] < to_find:
            low = mid + 1
        elif sorted_list[mid] > to_find:
            high = mid - 1
        else:
            return mid
    t_var = variance
    while abs(sorted_list[low] - to_find) > variance:
        t_var += .001
    if variance != t_var:
        logger.warning(
            "interpolation variance expanded to %f to meet requirements" %
            variance)
    logger.debug("Interpolation low: %s", low)
    return low
Beispiel #8
0
    def set_plot(self, plot):
        """
        Determine which list current_list should alias, also set internal plot
        variable

        :param constants.Plot plot: Acceptable plot constant from ``constants.py``
        """
        if plot == Plot.baseplot:
            logger.warning('set_plot called for BASE_PLOT')
            self.__current_list = self.__shape_list[Plot.baseplot]
            self.__current_plot = Plot.baseplot
        elif plot == Plot.backscattered:
            logger.info('set_plot to BACKSCATTERED')
            self.__current_list = self.__shape_list[Plot.backscattered]
            self.__current_plot = Plot.backscattered
        elif plot == Plot.depolarized:
            logger.info('set_plot to DEPOLARIZED')
            self.__current_list = self.__shape_list[Plot.depolarized]
            self.__current_plot = Plot.depolarized
        elif plot == Plot.vfm:
            logger.info('set_plot to VFM')
            self.__current_list = self.__shape_list[Plot.vfm]
            self.__current_plot = Plot.vfm
        elif plot == Plot.iwp:
            logger.info('set_plot to IWP')
            self.__current_list = self.__shape_list[Plot.iwp]
            self.__current_plot = Plot.iwp
        elif plot == Plot.horiz_avg:
            logger.info('set_plot to HORIZ_AVG')
            self.__current_list = self.__shape_list[Plot.horiz_avg]
            self.__current_plot = Plot.horiz_avg
        elif plot == Plot.horiz_avg:
            logger.info('set_plot to AEROSOL SUBTYPE')
            self.__current_list = self.__shape_list[Plot.aerosol_subtype]
            self.__current_plot = Plot.aerosol_subtype
Beispiel #9
0
    def save_json(self, filename=''):
        """
        Save all shapes selected on the screen to a specified JSON object,
        if no file is passed the internal file variable is used. There should **never**
        arise a case where no file is passed either from the internal or external
        parameters, ``Calipso`` has proper error checking.

        :param str filename: custom filename to save JSON objects to
        """
        if filename != '':
            self.__current_file = filename
        if not self.__selected_shapes:
            logger.warning('No shapes selected, saving empty plot')
        today = datetime.utcnow().replace(microsecond=0)
        self.__data['time'] = str(today)
        self.__data['hdffile'] = self.__hdf.rpartition('/')[2]
        shape_dict = {}
        for i in range(len(self.__shape_list)):
            self.__data[constants.PLOTS[i]] = {}
        i = self.__shape_list.index(self.__current_list)
        for j in range(len(self.__selected_shapes)):
            if not self.__selected_shapes[j].get_saved():
                self.__selected_shapes[j].save()
            tag = self.__selected_shapes[j].get_tag()
            coordinates = self.__selected_shapes[j].get_coordinates()
            color = self.__selected_shapes[j].get_color()
            attributes = self.__selected_shapes[j].get_attributes()
            note = self.__selected_shapes[j].get_notes()
            _id = self.__selected_shapes[j].get_id()

            time_cords = [mpl.dates.num2date(x[0]) for x in coordinates]
            alt_cords = [x[1] for x in coordinates]
            blat = self.__selected_shapes[j].get_min_lat()
            elat = self.__selected_shapes[j].get_max_lat()
            btime = min(time_cords).strftime(DATEFORMAT)
            etime = max(time_cords).strftime(DATEFORMAT)
            balt = min(alt_cords)
            ealt = max(alt_cords)

            value = {
                'coordinates': coordinates,
                'blat': blat,
                'elat': elat,
                'btime': btime,
                'etime': etime,
                'balt': balt,
                'ealt': ealt,
                'color': color,
                'attributes': attributes,
                'notes': note,
                'id': _id
            }
            shape_dict[tag] = value
        self.__data[constants.PLOTS[i]] = shape_dict
        logger.info('Encoding to JSON')
        db.encode(self.__current_file, self.__data)
Beispiel #10
0
 def __init__(self, username=None, password=None, project_name=None, token=None, admin=False):
     super().__init__(username, password, project_name, token, admin)
     self.nova = client.Client(2, session=self.sess)
     self.neutron = client_neutron.Client(session=self.sess)
     self.cinder = client_cinder.Client(3, session=self.sess)
     self.glance = Client(2, session=self.sess)
     try:
         self.services = self.nova.services.list()
         self.hypervisors = self.nova.hypervisors.list()
     except Exception as e:
         logger.warning(e)
Beispiel #11
0
    def import_dialog(self):
        """
        Open the database import window allowing the user to import and
        delete entries.
        """

        logger.info('Opening database import window')
        if (not ImportDialog.singleton):
            ImportDialog(self.__root, self). \
                wm_iconbitmap(ICO)
        else:
            logger.warning('Found existing import window, canceling')
Beispiel #12
0
    def settings_dialog(self):
        """
        Opens the settings window allowing the user to manually change the settings in the config
        file
        """

        logger.info('Opening settings window')
        if (not SettingsDialog.singleton):
            SettingsDialog(self.__root, self). \
                wm_iconbitmap(ICO)
        else:
            logger.warning('Found existing settings window, canceling')
Beispiel #13
0
 def anchor_rectangle(self, event):
     """
     Informs the correct shape list's blank object to plot a corner of a rectangle.
     :param event: A backend passed ``matplotlib.backend_bases.MouseEvent`` object
     """
     if self.__current_plot == Plot.baseplot:
         logger.warning("Cannot draw to BASE_PLOT")
         return
     if event.xdata and event.ydata:
         logger.info('Anchoring %d, %d' % (event.xdata, event.ydata))
         self.__current_list[-1].anchor_rectangle(event)
     else:
         logger.error('Anchor selected is out of range, skipping')
Beispiel #14
0
 def __can_draw(self):
     if not self.__coordinates:
         logger.warning('Attempting to ask to draw empty shape, probably just ' + \
                        'toggling a button after using free draw? See ticket #92')
         return -1
     b1 = tuple_to_nparray(self.__coordinates[-1])
     b2 = tuple_to_nparray(self.__coordinates[-2])
     for i in range(len(self.__coordinates) - 3):
         a1 = tuple_to_nparray(self.__coordinates[i])
         a2 = tuple_to_nparray(self.__coordinates[i + 1])
         if is_intersecting(a1, a2, b1, b2):
             logger.debug("Polygon labeled for draw")
             return i
     return -1
Beispiel #15
0
    def rubberband(self, event):
        """
        Uses a blank shape to draw 'helper rectangles' that outline the final shape of the
        object. wrapper function for calling :py:class:`polygon.Shape` method.

        :param event: A backend passes ``matplotlib.backend_bases.MouseEvent`` object
        """
        if event.button == 1:
            if self.__current_plot == Plot.baseplot:
                logger.warning("Cannot draw to BASE_PLOT")
                return
            if len(self.__current_list[-1].get_coordinates()) is 0:
                return
            self.__current_list[-1].rubberband(event)
Beispiel #16
0
    def properties(self, event):
        """
        Return the properties.rst of the shape clicked on by the user and create a small
        tooltip which displays these properties.rst

        :param event: A passed ``matplotlib.backend_bases.PickEvent`` object
        """
        target = event.artist
        logger.debug("Creating property window")
        for shape in self.__current_list:
            if shape.get_itemhandler() is target:
                # if self.property_window is not None:
                #    self.destroy_property_window()
                PropertyDialog(self.__master.get_root(), shape)
                return
        logger.warning("Shape not found")
Beispiel #17
0
    def pack_shape(self, shape_list, plot_type, canvas, read_from_str=None):
        """
        Stores the data in the JSON into PolygonDrawers

        :param shape_list: a Python list of PolygonDrawers
        :param plot_type: the current plot being displayed
        :param canvas: a Tkinter canvas to initialize the blank PolygonDrawer in the shape_list
        """
        from polygon.manager import ShapeManager
        enum_plot_type = constants.plot_type_enum[plot_type]

        try:
            for shape in self.__data[plot_type]:
                entry = self.__data[plot_type][shape]['id']
                if entry is not None and int(entry) in [x.get_id() for x in shape_list]:
                    continue
                logger.info('Found data in %s, packing polygon with JSON data'
                        % PLOTS[enum_plot_type])
                color = self.__data[plot_type][shape]['color']
                #fl = self.__data['hdffile']
                coordinates = self.__data[plot_type][shape]['coordinates']
                attributes = self.__data[plot_type][shape]['attributes']
                notes = self.__data[plot_type][shape]['notes']
                _id = self.__data[plot_type][shape]['id']
                if db.exists_tag(shape) and not read_from_str:
                    new = ShapeManager.generate_tag()
                    logger.warning(
                        'Shape tag already exists in database, creating new tag % s'
                        % new)
                    shape_list[-1].set_tag(new)
                else:
                    shape_list[-1].set_tag(shape)
                shape_list[-1].set_id(_id)
                shape_list[-1].set_color(color)
                shape_list[-1].set_plot(enum_plot_type)
                #shape_list[-1].set_hdf(fl)
                shape_list[-1].set_attributes(attributes)
                shape_list[-1].set_coordinates(coordinates)
                shape_list[-1].set_notes(notes)
                shape_list[-1].save()
                shape_list.append(Shape(canvas))
        except KeyError:
            logger.error('Bad data in JSON file')
Beispiel #18
0
    def get_current_file_shapes(self):
        """
        Return a list of all shapes contained in the current file, queries the
        database looking for all entries with the column *tag* that match the
        file returned by the rpartitioned ``Calipso.get_file()`` function

        :rtype: list
        """
        fn = self.__master.get_file().rpartition('/')[2]
        lst = list()
        for obj in self.session.query(DatabasePolygon).filter_by(hdf=fn):
            time_range = '%s - %s' % (obj.begin_time.strftime(DATEFORMAT),
                                      obj.end_time.strftime('%H:%M:%S'))
            altitude_range = '%.3f - %.3f' % (obj.begin_alt, obj.end_alt)
            lat_range = '%.3f - %.3f' % (obj.begin_lat, obj.end_lat)
            lst.append((obj.tag, obj.plot, time_range, lat_range,
                        altitude_range, obj.attributes[1:-1], obj.notes,
                        obj.time_.strftime(DATEFORMAT), obj.hdf))
        if not lst:
            logger.warning('Query returned None, no shapes found')
        return lst
Beispiel #19
0
    def render_pan(self, event):
        """
        Saves ending coordinates of mouse press and proceeds to find the distance
        between the two points, scrolls the map accordingly

        :param event: Tkinter passed event object
        """
        logger.info('Pan point 2, finding distance and panning...')
        # Find distance and add an amplifier of 1.5
        dst = int(distance(self.panx, self.pany, event.x, event.y) * 1.5)
        # If the user is scrolling backwards
        if self.panx < event.x:
            # Already at beginning
            if self.xrange[0] == 0:
                logger.warning(
                    'Attempting to pan backwards, already at beginning nothing to be done'
                )
                return
            # The end position would be negative
            if self.xrange[0] - dst < 0:
                logger.warning(
                    'Attempting to pan past beginning, setting to beginning')
                # Set both xrange and dst to zero and simply reload beginning range
                self.xrange = (0, self.xrange[1])
                dst = 0
            self.set_plot(self.plot,
                          (self.xrange[0] - dst, self.xrange[1] - dst))
            logger.info('Panning backwards')
        else:
            logger.info('Panning forwards')
            self.set_plot(self.plot,
                          xrange_=(self.xrange[0] + dst, self.xrange[1] + dst),
                          yrange=(int(
                              self.__child.begin_alt_range_entry.get()),
                                  int(self.__child.end_alt_range_entry.get())))
        self.__child.begin_range_entry.delete(0, END)
        self.__child.end_range_entry.delete(0, END)
        self.__child.begin_range_entry.insert(END, str(self.xrange[0]))
        self.__child.end_range_entry.insert(END, str(self.xrange[1]))
Beispiel #20
0
def acquire_time(wav_path):
    """
    获取音频时长
    :param wav_path: 音频路径
    :return: 音频时长
    """
    # if re.match('.*?sox.*', os.getenv('PATH')):                     # 判断环境变量里是否有sox
    cmd = 'sox --i -D %s' % wav_path
    logger.debug('[cmd]%s' % cmd)
    p = subprocess.Popen(
        cmd,  # 使用sox计算音频时长
        stdout=subprocess.PIPE,
        shell=True,
        stdin=subprocess.PIPE,
        stderr=subprocess.PIPE)
    out = p.stdout.read().decode()
    err = p.stderr.read().decode()

    if out and re.match('[0-9.]+', out) and not err:  # 判断sox是否成功
        logger.debug('[out] %s' % out)
        wav_time = float(out)
        return wav_time
    else:
        logger.debug('[err] %s' % err)

    logger.warning('[%s] 文件未能通过sox统计时长 ' % wav_path)
    try:
        with contextlib.closing(wave.open(wav_path, 'r')) as f:
            frames = f.getnframes()
            rate = f.getframerate()
            duration = frames / float(rate)
            return duration
    except Exception:
        pass
        # raise CustomError('[%s] 未能获取音频时长,请检查音频格式') from None
    return None
Beispiel #21
0
    def set_plot(self, plot_type, xrange_=(0, 1000), yrange=(0, 20)):
        """
        Draws to the canvas according to the *plot_type* specified in the arguments. Accepts one of
        the attributes below

        .. py:attribute:: BASE_PLOT
        .. py:attribute:: BACKSCATTERED
        .. py:attribute:: DEPOLARIZED
        .. py:attribute:: VFM
        .. py:attribute:: IWP
        .. py:attribute:: HORIZ_AVG
        .. py:attribute:: AEROSOL_SUBTYPE

        :param int plot_type: accepts ``BASE_PLOT, BACKSCATTERED, DEPOLARIZED, VFM, IWP, HORIZ_AVG
        :param list xrange\_: accepts a range of time to plot
        :param list yrange: accepts a range of altitude to plot
        """
        self.xrange = xrange_
        self.yrange = yrange
        if plot_type == Plot.baseplot:
            # Hide the axis and print an image
            self.__shapemanager.set_plot(Plot.baseplot)

            im = mpimg.imread(PATH + '/dat/CALIPSO.jpg')
            self.__fig.get_yaxis().set_visible(False)
            self.__fig.get_xaxis().set_visible(False)
            self.__fig.imshow(im)
        elif plot_type == Plot.backscattered:
            try:
                # Clear any references to the current figure, construct a new figure
                # and render the backscattered plot to it
                logger.info('Setting plot to backscattered xrange: ' +
                            str(xrange_) + ' yrange: ' + str(yrange))
                self.__file = self.__data_block.get_file_name(1)
                logger.info('Using file ' + self.__file)
                # Reset if the file is not empty AND we are using granules from different time/place
                if self.__shapemanager.get_hdf() != '' and \
                                self.__file[-25:-4] != self.__shapemanager.get_hdf()[-25:-4]:
                    self.__shapemanager.reset(all_=True)
                else:
                    self.__shapemanager.clear_refs()
                self.__shapemanager.set_hdf(self.__file)
                self.__parent_fig.clear()
                self.__fig = self.__parent_fig.add_subplot(1, 1, 1)
                self.__fig = render_backscattered(self.__file, xrange_, yrange,
                                                  self.__fig,
                                                  self.__parent_fig)
                self.__shapemanager.set_current(Plot.backscattered, self.__fig)
                self.__drawplot_canvas.show()
                self.__toolbar.update()
                self.plot = Plot.backscattered
            except IOError:
                logger.error('IOError, no file exists')
                tkMessageBox.showerror('File Not Found', 'No File Exists')
            except IndexError:
                tkMessageBox.showerror('Backscattered Plot',
                                       'Index out of bounds')

        elif plot_type == Plot.depolarized:
            try:
                # Clear any references to the current figure, construct a new figure
                # and render the depolarized plot to it
                logger.info('Setting plot to depolarized xrange: ' +
                            str(xrange_) + ' yrange: ' + str(yrange))
                self.__file = self.__data_block.get_file_name(1)
                logger.info('Using file ' + self.__file)
                # Reset if the file is not empty AND we are using granules from different time/place
                if self.__shapemanager.get_hdf() != '' and \
                                self.__file[-25:-4] != self.__shapemanager.get_hdf()[-25:-4]:
                    self.__shapemanager.reset(all_=True)
                else:
                    self.__shapemanager.clear_refs()
                self.__shapemanager.set_hdf(self.__file)
                self.__parent_fig.clear()
                self.__fig = self.__parent_fig.add_subplot(1, 1, 1)
                self.__fig = render_depolarized(self.__file, xrange_, yrange,
                                                self.__fig, self.__parent_fig)
                self.__shapemanager.set_current(Plot.depolarized, self.__fig)
                self.__drawplot_canvas.show()
                self.__toolbar.update()
                self.plot = Plot.depolarized
            except IOError:
                logger.error('IOError, no file exists')
                tkMessageBox.showerror('File Not Found', "No File Exists")

        elif plot_type == Plot.vfm:
            try:
                # Clear any references to the current figure, construct a new figure
                # and render the depolarized plot to it
                logger.info('Setting plot to vfm xrange: ' + str(xrange_) +
                            ' yrange: ' + str(yrange))
                self.__file = self.__data_block.get_file_name(2)
                logger.info('Using file ' + self.__file)
                # Reset if the file is not empty AND we are using granules from different time/place
                if self.__shapemanager.get_hdf() != '' and \
                                self.__file[-25:-4] != self.__shapemanager.get_hdf()[-25:-4]:
                    self.__shapemanager.reset(all_=True)
                else:
                    self.__shapemanager.clear_refs()
                self.__shapemanager.set_hdf(self.__file)
                self.__parent_fig.clear()
                self.__fig = self.__parent_fig.add_subplot(1, 1, 1)
                self.__fig = render_vfm(self.__file, xrange_, yrange,
                                        self.__fig, self.__parent_fig)
                self.__shapemanager.set_current(Plot.vfm, self.__fig)
                self.__drawplot_canvas.show()
                self.__toolbar.update()
                self.plot = Plot.vfm
            except IOError:
                logger.error('IOError, no file exists')
                tkMessageBox.showerror('File Not Found', "No File Exists")

        elif plot_type == Plot.iwp:
            try:
                # Clear any references to the current figure, construct a new figure
                # and render the depolarized plot to it
                logger.info('Setting plot to iwp xrange: ' + str(xrange_) +
                            ' yrange: ' + str(yrange))
                self.__file = self.__data_block.get_file_name(2)
                logger.info('Using file ' + self.__file)
                # Reset if the file is not empty AND we are using granules from different time/place
                if self.__shapemanager.get_hdf() != '' and \
                                self.__file[-25:-4] != self.__shapemanager.get_hdf()[-25:-4]:
                    self.__shapemanager.reset(all_=True)
                else:
                    self.__shapemanager.clear_refs()
                self.__shapemanager.set_hdf(self.__file)
                self.__parent_fig.clear()
                self.__fig = self.__parent_fig.add_subplot(1, 1, 1)
                self.__fig = render_iwp(self.__file, xrange_, yrange,
                                        self.__fig, self.__parent_fig)
                self.__shapemanager.set_current(Plot.iwp, self.__fig)
                self.__drawplot_canvas.show()
                self.__toolbar.update()
                self.plot = Plot.iwp
            except IOError:
                logger.error('IOError, no file exists')
                tkMessageBox.showerror('File Not Found', "No File Exists")

        elif plot_type == Plot.horiz_avg:
            try:
                # Clear any references to the current figure, construct a new figure
                # and render the depolarized plot to it
                logger.info('Setting plot to horiz_avg xrange: ' +
                            str(xrange_) + ' yrange: ' + str(yrange))
                self.__file = self.__data_block.get_file_name(2)
                logger.info('Using file ' + self.__file)
                # Reset if the file is not empty AND we are using granules from different time/place
                if self.__shapemanager.get_hdf() != '' and \
                                self.__file[-25:-4] != self.__shapemanager.get_hdf()[-25:-4]:
                    self.__shapemanager.reset(all_=True)
                else:
                    self.__shapemanager.clear_refs()
                self.__shapemanager.set_hdf(self.__file)
                self.__parent_fig.clear()
                self.__fig = self.__parent_fig.add_subplot(1, 1, 1)
                self.__fig = render_horiz_avg(self.__file, xrange_, yrange,
                                              self.__fig, self.__parent_fig)
                self.__shapemanager.set_current(Plot.horiz_avg, self.__fig)
                self.__drawplot_canvas.show()
                self.__toolbar.update()
                self.plot = Plot.horiz_avg
            except IOError:
                logger.error('IOError, no file exists')
                tkMessageBox.showerror('File Not Found', "No File Exists")

        elif plot_type == Plot.aerosol_subtype:
            try:
                # Clear any references to the current figure, construct a new figure
                # and render the depolarized plot to it
                logger.info('Setting plot to aerosol_subtype xrange: ' +
                            str(xrange_) + ' yrange: ' + str(yrange))
                self.__file = self.__data_block.get_file_name(2)
                logger.info('Using file ' + self.__file)
                # Reset if the file is not empty AND we are using granules from different time/place
                if self.__shapemanager.get_hdf() != '' and \
                                self.__file[-25:-4] != self.__shapemanager.get_hdf()[-25:-4]:
                    self.__shapemanager.reset(all_=True)
                else:
                    self.__shapemanager.clear_refs()
                self.__shapemanager.set_hdf(self.__file)
                self.__parent_fig.clear()
                self.__fig = self.__parent_fig.add_subplot(1, 1, 1)
                self.__fig = render_aerosol_subtype(self.__file, xrange_,
                                                    yrange, self.__fig,
                                                    self.__parent_fig)
                self.__shapemanager.set_current(Plot.aerosol_subtype,
                                                self.__fig)
                self.__drawplot_canvas.show()
                self.__toolbar.update()
                self.plot = Plot.aerosol_subtype
            except IOError:
                logger.error('IOError, no file exists')
                tkMessageBox.showerror('File Not Found', "No File Exists")

        else:
            logger.warning('Plot Type not yet supported')