예제 #1
0
 def __init__(self, *args,  **kywds):
     if len(args) == 4:
         tri = args[0]            
         args = args[1:]
     else:
         tri = None
     FigImage.__init__(self, *args, **kywds)
     TrianglePlots.__init__(self)
     self._tri = tri
예제 #2
0
 def __init__(self, *args, **kywds):
     if len(args) == 4:
         tri = args[0]
         args = args[1:]
     else:
         tri = None
     FigImage.__init__(self, *args, **kywds)
     TrianglePlots.__init__(self)
     self._tri = tri
예제 #3
0
 def get_crange(self, crange=[None,None], 
                      xrange=[None,None], 
                      yrange=[None,None], 
                      scale='linear'):
     if len(self._artists) == 0:
         return  FigImage.get_crange(self, crange = crange,
                          xrange = xrange, yrange = yrange,
                          scale = scale)
     else:
         zt = self._artists[0].get_array()
         if scale == 'log': zt = mask_negative(zt)
         crange = self._update_range(crange, 
                                    (min(zt), max(zt)))
     return crange
예제 #4
0
 def __new__(self, *args, **kywds):
     if len(args) == 4:
         tri = args[0]
         args = args[1:]
     else:
         tri = None
     kywds['use_tri'] = True
     shading = kywds.pop('shading', "flat")
     mask = kywds.pop('mask', None)
     obj = FigImage.__new__(self, *args, **kywds)
     obj.setp('shading', shading)
     obj.setp('mask', mask)
     obj.setvar('shading', shading)
     obj.setvar('mask', mask)
     obj.setvar("tri", tri)
     return obj
예제 #5
0
 def get_crange(self,
                crange=[None, None],
                xrange=[None, None],
                yrange=[None, None],
                scale='linear'):
     if len(self._artists) == 0:
         return FigImage.get_crange(self,
                                    crange=crange,
                                    xrange=xrange,
                                    yrange=yrange,
                                    scale=scale)
     else:
         zt = self._artists[0].get_array()
         if scale == 'log': zt = mask_negative(zt)
         crange = self._update_range(crange, (min(zt), max(zt)))
     return crange
예제 #6
0
 def __new__(self, *args, **kywds):
     if len(args) == 4:
         tri =  args[0]            
         args = args[1:]
     else:
         tri = None
     kywds['use_tri'] = True
     shading = kywds.pop('shading', "flat")
     mask = kywds.pop('mask', None)
     obj = FigImage.__new__(self, *args, **kywds)
     obj.setp('shading', shading)        
     obj.setp('mask', mask)        
     obj.setvar('shading', shading)        
     obj.setvar('mask', mask)
     obj.setvar("tri", tri) 
     return obj
예제 #7
0
 def property_in_palette(self):
     tab0, list0 = FigImage.property_in_palette()
     return (['fft']+tab0, [["spec_fftp",  "spec_noverlap",
                             "spec_window", "spec_detrend", "spec_sided"]]+list0)
예제 #8
0
    def postprocess_data(
        self,
        ana,
        viewer,
        color_order=['red', 'blue', 'yellow'],
    ):
        def set_auto_color_to_color(kargs, name, col):
            if (not name in kargs) or (kargs[name] == 'auto'):
                kargs[name] = col
            return kargs

        from ifigure.mto.fig_plot import FigPlot, TimeTrace, StepPlot
        from ifigure.mto.fig_contour import FigContour
        from ifigure.mto.fig_image import FigImage
        from ifigure.mto.fig_surface import FigSurface
        from ifigure.mto.fig_axline import FigAxline
        from ifigure.mto.fig_axspan import FigAxspan
        from ifigure.mto.fig_text import FigText

        self._color_order = color_order
        dprint2('process_data', self)
        if ana.skipped:
            if ana.do_title:
                self.process_title(ana)
            return True

        if (self.isempty() and not self.get_figaxes().isempty()
                and not self._suppress):
            self.generate_artist()
#        app = self.get_app()
#        ax = self.get_container()
#        fig_ax = ax.figobj

        ishot = ana.ishot

        self._analysis_flag[ishot] = False
        col = color_order[ishot % len(color_order)]

        for x in range(ishot - self.num_child() + 1):
            plot_options = self.getvar('plot_options')
            if self._plot_type == 'plot':
                kargs = plot_options['plot'][1].copy()
                kargs = set_auto_color_to_color(kargs, 'color', col)
                kargs = set_auto_color_to_color(kargs, 'markerfacecolor', col)
                kargs = set_auto_color_to_color(kargs, 'markeredgecolor', col)
                obj = FigPlot([0], [0], *(plot_options['plot'][0]), **kargs)
            elif self._plot_type == 'timetrace':
                kargs = plot_options['timetrace'][1].copy()
                kargs = set_auto_color_to_color(kargs, 'color', col)
                kargs = set_auto_color_to_color(kargs, 'markerfacecolor', col)
                kargs = set_auto_color_to_color(kargs, 'markeredgecolor', col)
                obj = TimeTrace([0], [0], *(plot_options['timetrace'][0]),
                                **kargs)
            elif self._plot_type == 'stepplot':
                kargs = plot_options['stepplot'][1].copy()
                kargs = set_auto_color_to_color(kargs, 'color', col)
                kargs = set_auto_color_to_color(kargs, 'markerfacecolor', col)
                kargs = set_auto_color_to_color(kargs, 'markeredgecolor', col)
                obj = StepPlot([0], [0], *(plot_options['stepplot'][0]),
                               **kargs)
            elif self._plot_type == 'contour':
                obj = FigContour([0, 1], [0, 1],
                                 np.arange(4).reshape(2, 2),
                                 *(plot_options['contour'][0]))
            elif self._plot_type == 'image':
                obj = FigImage(np.zeros([2, 2]))
            elif self._plot_type == 'surface':
                obj = FigSurface(np.zeros([2, 2]))
            elif self._plot_type == 'axspan':
                obj = FigAxspan([0, 1])
            elif self._plot_type == 'axline':
                obj = FigAxline(np.zeros([1]))
            elif self._plot_type == 'text':
                obj = FigText(0, 0, '')
            name = self._plot_type + str(self.num_child() + 1)
            self.add_child(name, obj)
            obj.set_container_idx(self._container_idx)
            obj.set_suppress(True)
        if self.get_script_local():
            txt = self.make_script(ana.shot, short=True)
            debug_mode = viewer.debug_mode
            if txt is not None:
                try:
                    vars = viewer.get_globals_for_figmds(ana.shot)
                    #                  print vars
                    for key in vars:
                        ana.result[key] = vars[key]
                    for key in viewer.startup_values:
                        ana.result[key] = viewer.startup_values[key]
                    ana.result['shot'] = ana.shot
                    if self.getvar('posvars') is not None:
                        a = {}
                        b = {}
                        exec self.getvar('posvars') in a, b
                        for key in b:
                            ana.result[key] = b[key]
                    filepath = os.path.join(self.owndir(), script_file_name)
                    from ifigure.widgets.debugger_core import get_breakpoint
                    code = compile(txt, filepath, 'exec')
                    if (len(get_breakpoint(filepath)) != 0 and debug_mode):
                        app = wx.GetApp().TopWindow
                        se = app.script_editor
                        import threading
                        if not se.CheckDebuggerStatus():
                            se.QueueSEDRequest(code, viewer.g, ana.result,
                                               filepath)
#                          print threading.current_thread().name
#                          wx.Yield()
#                          time.sleep(3)
                        else:
                            se.RunSED(code, viewer.g, ana.result, filepath)
                    else:
                        exec code in viewer.g, ana.result
                except:
                    dprint1('error occured when processing data by script')
                    print(
                        'error occured when processing data by following script'
                    )
                    print('#####')
                    print(txt)
                    print('#####')
                    print(traceback.format_exc())
                    self.change_suppress(True, self.get_child(ishot))
                    return False

        if ana.do_title:
            self.process_title(ana)
        if self._plot_type == 'plot':
            self._update_plot(ana, ishot)  #, color_order)
        elif self._plot_type == 'timetrace':
            self._update_plot(ana, ishot)  #, color_order)
        elif self._plot_type == 'stepplot':
            self._update_plot(ana, ishot)  #, color_order)
        elif self._plot_type == 'contour':
            self._update_contour(ana, ishot)
        elif self._plot_type == 'image':
            self._update_image(ana, ishot)
        elif self._plot_type == 'surface':
            self._update_surface(ana, ishot)
        elif self._plot_type == 'axspan':
            self._update_axspan(ana, ishot)
        elif self._plot_type == 'axline':
            self._update_axline(ana, ishot)
        elif self._plot_type == 'text':
            self._update_text(ana, ishot)

        obj = self.get_child(idx=ishot)
        if obj.is_suppress():
            return False

        obj._data_extent = None
        try:
            if (self.get_figaxes() is not None):
                self.get_figaxes().adjust_axes_range()
        except:
            dprint1(
                "failed in adjusting axes at postprocess_data, continuing...")
            pass
        return True
예제 #9
0
 def _eval_xyz(self):
     if self._tri is None:
         self._tri = self.getvar('tri')
     return FigImage._eval_xyz(self)
예제 #10
0
 def onScope2Di(self, evt):
     from ifigure.mto.fig_image import FigImage
     z = self._content().nc_eval(self._td)
     obj = FigImage(z)
     self._on_scope(obj, False)
예제 #11
0
 def _eval_xyz(self):
     if self._tri is None:
         self._tri = self.getvar('tri')
     return FigImage._eval_xyz(self)