示例#1
0
    def __init__(self, parent, layer, trend_data, **kwargs):
        PlottingCanvas.__init__(self, parent, trend_data)

        try:
            self.start_date, self.end_date = kwargs["start"], kwargs["end"]
            self.step, self.step_by = kwargs["step"], kwargs["step_by"]

            self.margin_right = 70
            self.margin_left = 100
            self.margin_bottom = 140
            self.enable_axis = False
            self.enable_axis_x = False
            self.enable_axis_y = False

            self.layer_name = layer.name
            self.layer = layer
            self.data = trend_data
            self.n = len(self.data)
            all_values = self.data.values()
            self.t = len(all_values[0])
            self.datetime_intervals, self.interval_labels = GetDateTimeIntervals(
                self.start_date, self.end_date, self.t, self.step,
                self.step_by)

            ttl = "" if "title" not in kwargs else kwargs["title"]
            self.title = "%s %s" % (self.layer_name, ttl)
            self.x_label = ""
            self.y_label = "Number of observations"

            self.x_min = 1
            self.x_max = len(all_values[0])
            self.x_max = self.x_max if self.x_max > self.x_min else self.x_max * 1.5

            all_values = np.array(all_values)
            self.y_min = np.min(all_values)
            self.y_min = self.y_min if self.y_min > 0 else 0
            self.y_max = np.max(all_values)

            self.local_paths = []

            self.extent = (self.x_min, self.y_min, self.x_max, self.y_max)
            self.selected_path_ids = []
            self.status_bar = self.parentFrame.status_bar
            """
            self.sum_data = np.sum(all_values,axis=1)
            factory = ClassifyMapFactory(self.sum_data, k=5)
            classify_results = factory.createClassifyMap(stars.MAP_CLASSIFY_QUANTILES)
            self.id_group, self.label_group, self.color_group = classify_results
            """

        except Exception as err:
            self.ShowMsgBox("Trend graph could not be created. " +
                            str(err.message))
            self.isValidPlot = False
            self.parentFrame.Close(True)
            return None

        # linking-brushing events
        self.Register(stars.EVT_OBJS_SELECT, self.OnPathsSelected)
        self.Register(stars.EVT_OBJS_UNSELECT, self.OnNoPathSelect)
示例#2
0
    def __init__(self,parent, layer, data, **kwargs):
        PlottingCanvas.__init__(self,parent,data)
      
        try:
            self.data          = data[0]
            self.localMorans   = data[1]
            self.timeNeighbors = data[2]
            self.highlight_ids = data[3]
            self.margin_right  = 50
            self.margin_bottom = 60
            self.enable_axis   = False
            self.enable_axis_x = False
            self.enable_axis_y = False
            
            self.selected_path_ids = []
            
            self.layer_name = layer.name 
            self.layer      = layer
            self.n          = len(self.data)
            
            self.title   = "Trend Graph for LISA Space Time: %s[%s]" % (self.layer_name,len(self.timeNeighbors))
            self.x_label = "Time interval"
            self.y_label = "Number of observations"
            
            self.font_size_title    = 8
            if os.name == "posix":
                self.font_size_title= 10
            self.font_size_x_axis   = 8
            self.font_size_y_axis   = 8
            self.font_size_xy_label = 8
            if os.name == "posix":
                self.font_size_xy_label = 10
            
            all_values = self.data.values()
            
            self.x_min = 1
            self.x_max = len(all_values[0]) 
            self.x_max = self.x_max if self.x_max > self.x_min else self.x_max*1.5
            
            all_values = np.array(all_values)
            self.y_min = np.min(all_values)
            self.y_min = self.y_min if self.y_min > 0 else 0
            self.y_max = np.max(all_values)
            
            self.local_paths = []
            
            self.extent = (self.x_min, self.y_min, self.x_max,self.y_max)
            self.status_bar = self.parentFrame.status_bar
            
        except Exception as err:
            self.ShowMsgBox("""LISA trend graph could not be created. Please check the time weights file.
            
Details: """+str(err.message))
            self.isValidPlot = False
            self.parentFrame.Close(True)
            return None
            
        # linking-brushing events
        self.Register(stars.EVT_OBJS_SELECT, self.OnPathsSelected)
        self.Register(stars.EVT_OBJS_UNSELECT, self.OnNoPathSelect)
示例#3
0
    def __init__(self,parent, layer, trend_data, **kwargs):
        PlottingCanvas.__init__(self,parent,trend_data)

        try:
            self.start_date,self.end_date = kwargs["start"],kwargs["end"]
            self.step, self.step_by = kwargs["step"] ,kwargs["step_by"]

            self.margin_right = 70
            self.margin_left =100
            self.margin_bottom = 140
            self.enable_axis = False
            self.enable_axis_x = False
            self.enable_axis_y = False

            self.layer_name = layer.name
            self.layer = layer
            self.data = trend_data
            self.n = len(self.data)
            all_values = self.data.values()
            self.t = len(all_values[0])
            self.datetime_intervals, self.interval_labels = GetDateTimeIntervals(self.start_date, self.end_date,self.t, self.step, self.step_by)

            ttl = "" if "title" not in kwargs else kwargs["title"]
            self.title = "%s %s" % (self.layer_name,ttl)
            self.x_label = ""
            self.y_label = "Number of observations"

            self.x_min = 1
            self.x_max = len(all_values[0])
            self.x_max = self.x_max if self.x_max > self.x_min else self.x_max*1.5

            all_values = np.array(all_values)
            self.y_min = np.min(all_values)
            self.y_min = self.y_min if self.y_min > 0 else 0
            self.y_max = np.max(all_values)

            self.local_paths = []

            self.extent = (self.x_min, self.y_min, self.x_max,self.y_max)
            self.selected_path_ids = []
            self.status_bar = self.parentFrame.status_bar

            """
            self.sum_data = np.sum(all_values,axis=1)
            factory = ClassifyMapFactory(self.sum_data, k=5)
            classify_results = factory.createClassifyMap(stars.MAP_CLASSIFY_QUANTILES)
            self.id_group, self.label_group, self.color_group = classify_results
            """

        except Exception as err:
            self.ShowMsgBox("Trend graph could not be created. " + str(err.message))
            self.isValidPlot = False
            self.parentFrame.Close(True)
            return None

        # linking-brushing events
        self.Register(stars.EVT_OBJS_SELECT, self.OnPathsSelected)
        self.Register(stars.EVT_OBJS_UNSELECT, self.OnNoPathSelect)
示例#4
0
    def __init__(self,parent,layer, data,**kwargs):
        try:
            PlottingCanvas.__init__(self,parent,data)
          
            self.margin_top  = 70
            self.margin_left = 70
            self.layer_name  = layer.name 
            
            self.data = data
            var_names = data.keys()
            x_label   = var_names[0]
            y_label   = var_names[1] if len(var_names)>1 else x_label
           
            self.parentFrame.SetTitle = 'Scatter plot-%s' % self.layer_name
            self.title   = ''
            self.x_label = x_label 
            self.y_label = y_label
            
            self.x, self.y = data[x_label],data[y_label]
            
            self.n = len(self.x)
            self.x_min, self.x_max = min(self.x), max(self.x)
            self.y_min, self.y_max = min(self.y), max(self.y)
            self.x_min -= 0
            self.y_min -= 0
            self.extent = (self.x_min, self.y_min, self.x_max,self.y_max)
            
            # test data
            float(self.x_min)
            float(self.y_min)
            
            self.selected_pts = []
            self.status_bar = None
            
            
        except Exception as err:
            self.ShowMsgBox("""Scatter plot could not be created. 
            
Detail: """+ str(err.message))
            self.isValidPlot = False
            self.parentFrame.Close(True)
            return None
        
        # linking-brushing events
        self.Register(stars.EVT_OBJS_SELECT, self.OnPointsSelected)
        self.Register(stars.EVT_OBJS_UNSELECT, self.OnNoPointSelect)
示例#5
0
    def __init__(self, parent, layer, data, **kwargs):
        PlottingCanvas.__init__(self, parent, data)

        try:
            self.layer_name = layer.name
            self.title = "Transition probility matrix (%s)" % self.layer_name
            self.x_label = "LISA transition states (1=HH,2=LH,3=LL,4=HL)"
            self.y_label = "LISA transition states"
            self.data = data
            n = len(self.data)
            self.enable_axis_labels = False
            self.enable_axis = True
            self.enable_axis_x = False
            self.enable_axis_y = False

            # a NxN matrix
            self.x_min = 1
            self.x_max = n + 1
            self.y_min = 1
            self.y_max = n + 1

            self.extent = (self.x_min, self.y_min, self.x_max, self.y_max)
            self.selected_polygon_ids = []
            self.status_bar = self.parentFrame.status_bar

            self.gradient_color = GradientColor(gradient_type='rdyibu')
            self.margin_right = 100

            # color schema: from blue to red
            self.color_matrix = []
            for i in range(n):
                color_row = []
                for j in range(n):
                    p = self.data[i][j]
                    color_row.append(self.gradient_color.get_color_at(p))
                self.color_matrix.append(color_row)

        except Exception as err:
            self.ShowMsgBox('Fail to init heat map! ' + str(err.message))
            self.isValidPlot = False
            self.parentFrame.Close(True)
            return None
示例#6
0
 def __init__(self,parent, layer, data,**kwargs):
     PlottingCanvas.__init__(self,parent,data)
     
     try:
         self.layer_name = layer.name
         self.title = "Transition probility matrix (%s)" % self.layer_name
         self.x_label = "LISA transition states (1=HH,2=LH,3=LL,4=HL)"
         self.y_label = "LISA transition states"
         self.data = data
         n = len(self.data)
         self.enable_axis_labels = False
         self.enable_axis = True
         self.enable_axis_x = False
         self.enable_axis_y = False
        
         # a NxN matrix
         self.x_min = 1
         self.x_max = n+1 
         self.y_min = 1
         self.y_max = n+1
         
         self.extent = (self.x_min, self.y_min, self.x_max,self.y_max)
         self.selected_polygon_ids = []
         self.status_bar = self.parentFrame.status_bar
         
         self.gradient_color = GradientColor(gradient_type='rdyibu')
         self.margin_right = 100
         
         # color schema: from blue to red
         self.color_matrix = []
         for i in range(n):
             color_row = []
             for j in range(n):
                 p = self.data[i][j]
                 color_row.append( self.gradient_color.get_color_at(p))
             self.color_matrix.append(color_row)
             
     except Exception as err:
         self.ShowMsgBox('Fail to init heat map! ' + str(err.message))
         self.isValidPlot = False
         self.parentFrame.Close(True)
         return None
示例#7
0
    def __init__(self,parent, layer, data, **kwargs):
        PlottingCanvas.__init__(self,parent,data)
      
        try:
            #self.weight_file  = kwargs["weight"]
            self.cs_data_dict = kwargs["query_data"]
            self.step, self.step_by             = kwargs["step"] ,kwargs["step_by"]
            self.start_date, self.end_date      = kwargs["start"],kwargs["end"]
            self.lbls = kwargs['lbls']
            self.layer  = layer
            self.data_sel_keys   = sorted(self.cs_data_dict.keys())
            self.data_sel_values = [self.cs_data_dict[i] for i in self.data_sel_keys]
            #self.weight          = pysal.open(self.weight_file).read()
            self.t = len(self.cs_data_dict) # number of data slices
            self.n = len(self.data_sel_values[0]) # number of shape objects
            self.datetime_intervals, self.interval_labels = GetDateTimeIntervals(self.start_date, self.end_date,self.t, self.step, self.step_by)
           
            from stars.core.LISAWrapper import call_lisa
            from stars.visualization.dialogs import TimeWeightsDlg
            # promote for time weights
            tw_dlg  = TimeWeightsDlg(self.main, self.t, self.layer.name)
            tw_path = tw_dlg.Show()
            if tw_path == False:
                raise Exception("no time weights")
            
            timeWeights = pysal.open(tw_path).read()
            self.timeNeighbors = timeWeights.neighbors
            
            # time LISA
            self.tseries_data = {}
            for pid in range(self.n):
                tseries = []
                for tid in range(self.t):
                    tseries.append(self.cs_data_dict[tid][pid])
                self.tseries_data[pid] = tseries
                
            self.time_moran_locals = {}
            for pid in range(self.n):
                tseries = self.tseries_data[pid]
                localMoran, sigLocalMoran, sigFlag, clusterFlag = call_lisa(tseries,str(tw_path),499)
                ml = [localMoran, sigLocalMoran, sigFlag, clusterFlag]
                self.time_moran_locals[pid] = ml
                
            data = [self.tseries_data,self.time_moran_locals, self.timeNeighbors,[]]
            self.data          = data[0]
            self.localMorans   = data[1]
            self.timeNeighbors = data[2]
            self.highlight_ids = data[3]
            self.margin_right  = 50
            self.margin_left = 100
            self.margin_bottom = 140
            self.enable_axis   = False
            self.enable_axis_x = False
            self.enable_axis_y = False
            
            self.selected_path_ids = []
            self.line_marker = []
            self.selected_line = None
            
            self.layer_name = layer.name 
            self.layer      = layer
            self.n          = len(self.data)
            
            self.title   = "LISA Trend Graph: %s[%s]" % (self.layer_name,len(self.timeNeighbors))
            self.parentFrame.SetTitle = self.title
            self.x_label = ""
            self.y_label = "Number of observations"
            
            self.font_size_title    = 8
            if os.name == "posix":
                self.font_size_title= 10
            self.font_size_x_axis   = 8
            self.font_size_y_axis   = 8
            self.font_size_xy_label = 8
            if os.name == "posix":
                self.font_size_xy_label = 10
            
            all_values = self.data.values()
            
            self.x_min = 1
            self.x_max = len(all_values[0]) 
            self.x_max = self.x_max if self.x_max > self.x_min else self.x_max*1.5
            
            all_values = np.array(all_values)
            self.y_min = np.min(all_values)
            self.y_min = self.y_min if self.y_min > 0 else 0
            self.y_max = np.max(all_values)
            
            self.local_paths = []
            
            self.extent = (self.x_min, self.y_min, self.x_max,self.y_max)
            self.status_bar = self.parentFrame.status_bar
            
        except Exception as err:
            self.ShowMsgBox("""LISA trend graph could not be created. Please check the time weights file.
            
Details: """+str(err.message))
            self.isValidPlot = False
            self.parentFrame.Close(True)
            return None
            
        # linking-brushing events
        self.Register(stars.EVT_OBJS_SELECT, self.OnPathsSelected)
        self.Register(stars.EVT_OBJS_UNSELECT, self.OnNoPathSelect)
示例#8
0
    def __init__(self, parent, layer, data, **kwargs):
        PlottingCanvas.__init__(self, parent, data)

        try:
            self.enable_axis = False
            self.enable_axis_x = False
            self.enable_axis_y = False
            self.isAutoScale = False
            self.enable_grid = False

            # setup toolbar for Markov LISA
            self.toolbar = parent.toolbar
            self.txt_from = wx.TextCtrl(self.toolbar,
                                        -1,
                                        "",
                                        size=(80, -1),
                                        style=wx.TE_PROCESS_ENTER)
            self.txt_to = wx.TextCtrl(self.toolbar,
                                      -1,
                                      "",
                                      size=(80, -1),
                                      style=wx.TE_PROCESS_ENTER)
            self.btn_previous = wx.Button(self.toolbar, 101, "<<")
            self.btn_next = wx.Button(self.toolbar, 102, ">>")
            self.toolbar.AddControl(
                wx.StaticText(self.toolbar, -1, "Current display from "))
            self.toolbar.AddControl(self.txt_from)
            self.toolbar.AddControl(wx.StaticText(self.toolbar, -1, "to"))
            self.toolbar.AddControl(self.txt_to)
            self.toolbar.AddControl(self.btn_previous)
            self.toolbar.AddControl(self.btn_next)
            parent.Bind(wx.EVT_BUTTON, self.OnClickPrevious, self.btn_previous)
            parent.Bind(wx.EVT_BUTTON, self.OnClickNext, self.btn_next)
            parent.Bind(wx.EVT_TEXT_ENTER, self.OnUpdateDisplay, self.txt_from)
            parent.Bind(wx.EVT_TEXT_ENTER, self.OnUpdateDisplay, self.txt_to)

            self.layer_name = layer.name
            self.moran_locals, lisa_markov_mt, self.interval_labels = data
            self.t = len(self.moran_locals)
            # convert LISA Markov move_types to {poly_id:seq_data}
            lisa_markov_mt.transpose()
            self.cs_data_dict = {}
            for i, seq in enumerate(lisa_markov_mt):
                self.cs_data_dict[i] = list(seq)

            self.status_bar = None
            self.data = True  # Dummy
            self.title = "LISA Markov Plot"
            self.x_label = "time period"
            self.y_label = "shape id"
            self.tick = 0
            self.num_objects_per_page = 15
            self.n = len(self.cs_data_dict)
            self._y_max, self.x_max = lisa_markov_mt.shape
            self.x_max += 1
            #for setup view with extent, see PlotWidget.py line181
            self.y_max = self.num_objects_per_page
            self.y_min, self.x_min = 0, 0
            self.extent = (self.x_min, 0, self.x_max,
                           self.num_objects_per_page)

            self.selected_obj_ids = []  # objects that currectly selected
            self.highlighted_shape_objects = []  # objects that shown in plot

            # setup values for controls in toolbar
            self.id_start_object = 1
            self.id_end_object = self.num_objects_per_page if self.num_objects_per_page <= self.n else self.n
            self.txt_from.SetValue(str(self.id_start_object))
            self.txt_to.SetValue(str(self.id_end_object))
            self.btn_previous.Disable()
            if self.n <= self.num_objects_per_page:
                self.btn_next.Disable()
            self.toolbar.Realize()

        except Exception as err:
            self.ShowMsgBox("""LISA Markov plot could not be created. 
            
            
Details: """ + str(err.message))
            self.isValidPlot = False
            self.parentFrame.Close(True)
            return None

        # linking-brushing events
        self.Register(stars.EVT_OBJS_SELECT, self.OnObjsSelected)
        self.Register(stars.EVT_OBJS_UNSELECT, self.OnNoObjSelect)
示例#9
0
  def __init__(self,parent, layer, data, **kwargs):
      PlottingCanvas.__init__(self,parent,data)
 
      try:
          self.layer        = layer
          self.layer_name   = layer.name
          
          #self.weight_file  = kwargs["weight"]
          self.cs_data_dict = kwargs["query_data"]
          self.step, self.step_by        = kwargs["step"] ,kwargs["step_by"]
          self.start_date, self.end_date = kwargs["start"],kwargs["end"]
          self.parent = parent
          self.data_sel_keys   = sorted(self.cs_data_dict.keys())
          self.data_sel_values = [self.cs_data_dict[i] for i in self.data_sel_keys]
          #self.weight          = pysal.open(self.weight_file).read()
          self.t = len(self.cs_data_dict) # number of data slices
          self.n = len(self.data_sel_values[0]) # number of shape objects
          
          self.datetime_intervals, self.interval_labels = GetDateTimeIntervals(self.start_date, self.end_date,self.t, self.step, self.step_by)
          
          # promote for time weights
          from stars.visualization.dialogs import TimeWeightsDlg
          tw_dlg  = TimeWeightsDlg(self.main, self.t, self.layer.name)
          tw_path = tw_dlg.Show()
          if tw_path == False:
              raise Exception("no time weights")
          
          tweights = pysal.open(tw_path).read()
         
          # G settings
          from stars.visualization.dialogs import choose_local_g_settings
          b_gstar, b_binary = choose_local_g_settings(self)
          map_type = 'Gi*' if b_gstar else 'Gi'
          add_type = 'binary' if b_binary else 'row-standardized'
          self.title = 'Local G (%s,%s) Trend Graph -%s %s' % (map_type,add_type,layer.name,kwargs["title"])
          self.parentFrame.SetTitle(self.title)
          
          # calculate Gi using time weights
          time_gstar   = dict()
          time_gstar_z = dict()
          tseries_data = []
          for pid in range(self.n):
              tseries = []
              for tid in range(self.t):
                  tseries.append(self.cs_data_dict[tid][pid])
              tseries_data.append(tseries)
          for pid in range(self.n):
              tseries = tseries_data[pid]
              y  = np.array(tseries)
              #lg = pysal.esda.getisord.G_Local(y,tweights,transform='B',star=True)
              if b_binary == False:
                  lg = pysal.esda.getisord.G_Local(y,tweights,star=b_gstar)
              else:
                  lg = pysal.esda.getisord.G_Local(y,tweights,star=b_gstar,transform='B')
              time_gstar[pid]   = lg.p_sim            
              time_gstar_z[pid] = lg.Zs
          
          trendgraph_data = dict()
          for i in range(self.n):
              data = []
              for j in range(self.t):
                  data.append(self.cs_data_dict[j][i])
              trendgraph_data[i] = data
          self.trendgraph_data = trendgraph_data 
          
          self.tweights     = tweights
          self.time_gstar   = time_gstar 
          self.time_gstar_z = time_gstar_z 
          self.t_neighbors  = tweights.neighbors
          
          data              = [self.trendgraph_data, [], self.interval_labels, 0, self.time_gstar,self.time_gstar_z, self.t_neighbors]
          self.data         = data[0]
          self.highlight_ids= data[1]
          self.labels       = data[2]
          self.tick         = data[3]
          self.time_gstar_p = data[4]
          self.time_gstar_z = data[5]
          self.time_neighbors = data[6]
          self.n              = len(self.data)
          
          self.selected_path_ids = []
          self.line_marker = []
          self.selected_line = None
          
          self.margin_right  = 50
          self.margin_bottom = 140
          self.margin_left   = 100
          self.enable_axis   = False
          self.enable_axis_x = False
          self.enable_axis_y = False
         
          
          self.x_label = ""
          self.y_label = "# of observations"
          
          self.font_size_title    = 8
          if os.name == "posix":
              self.font_size_title= 10
          self.font_size_x_axis   = 8
          self.font_size_y_axis   = 8
          self.font_size_xy_label = 8
          if os.name == "posix":
              self.font_size_xy_label = 10
              
          
          all_values = self.data.values()
          
          self.x_min = 1
          self.x_max = len(all_values[0]) 
          self.x_max = self.x_max if self.x_max > self.x_min else self.x_max*1.5
          
          all_values = np.array(all_values)
          self.y_min = np.min(all_values)
          self.y_min = self.y_min if self.y_min > 0 else 0
          self.y_max = np.max(all_values)
          
          self.local_paths = []
          
          self.extent = (self.x_min, self.y_min, self.x_max,self.y_max)
          
      except Exception as err:
          self.ShowMsgBox('Local G Trend Graph could not be created. ' + str(err.message))
          self.isValidPlot = False
          self.parentFrame.Close(True)
          return None
      
      # linking-brushing events
      self.Register(stars.EVT_OBJS_SELECT, self.OnPathsSelected)
      self.Register(stars.EVT_OBJS_UNSELECT, self.OnNoPathSelect)
示例#10
0
    def __init__(self, parent, layer, data, **kwargs):
        PlottingCanvas.__init__(self, parent, data)

        try:
            #self.weight_file  = kwargs["weight"]
            self.cs_data_dict = kwargs["query_data"]
            self.step, self.step_by = kwargs["step"], kwargs["step_by"]
            self.start_date, self.end_date = kwargs["start"], kwargs["end"]
            self.layer = layer
            self.data_sel_keys = sorted(self.cs_data_dict.keys())
            self.data_sel_values = [
                self.cs_data_dict[i] for i in self.data_sel_keys
            ]
            #self.weight          = pysal.open(self.weight_file).read()
            self.t = len(self.cs_data_dict)  # number of data slices
            self.n = len(self.data_sel_values[0])  # number of shape objects

            self.datetime_intervals, self.interval_labels = GetDateTimeIntervals(
                self.start_date, self.end_date, self.t, self.step,
                self.step_by)

            from stars.core.LISAWrapper import call_lisa
            from stars.visualization.dialogs import TimeWeightsDlg
            # promote for time weights
            tw_dlg = TimeWeightsDlg(self.main, self.t, self.layer.name)
            tw_path = tw_dlg.Show()
            if tw_path == False:
                raise Exception("no time weights")

            timeWeights = pysal.open(tw_path).read()
            self.timeNeighbors = timeWeights.neighbors

            # time LISA
            self.tseries_data = {}
            for pid in range(self.n):
                tseries = []
                for tid in range(self.t):
                    tseries.append(self.cs_data_dict[tid][pid])
                self.tseries_data[pid] = tseries

            self.time_moran_locals = {}
            for pid in range(self.n):
                tseries = self.tseries_data[pid]
                localMoran, sigLocalMoran, sigFlag, clusterFlag = call_lisa(
                    tseries, str(tw_path), 499)
                ml = [localMoran, sigLocalMoran, sigFlag, clusterFlag]
                self.time_moran_locals[pid] = ml

            data = [
                self.tseries_data, self.time_moran_locals, self.timeNeighbors,
                []
            ]
            self.data = data[0]
            self.localMorans = data[1]
            self.timeNeighbors = data[2]
            self.highlight_ids = data[3]
            self.margin_right = 50
            self.margin_left = 100
            self.margin_bottom = 140
            self.enable_axis = False
            self.enable_axis_x = False
            self.enable_axis_y = False

            self.selected_path_ids = []
            self.line_marker = []
            self.selected_line = None

            self.layer_name = layer.name
            self.layer = layer
            self.n = len(self.data)

            self.title = "LISA Trend Graph: %s[%s] %s" % (
                self.layer_name, len(self.timeNeighbors), kwargs["title"])
            self.parentFrame.SetTitle = self.title
            self.x_label = ""
            self.y_label = "Number of observations"

            self.font_size_title = 8
            if os.name == "posix":
                self.font_size_title = 10
            self.font_size_x_axis = 8
            self.font_size_y_axis = 8
            self.font_size_xy_label = 8
            if os.name == "posix":
                self.font_size_xy_label = 10

            all_values = self.data.values()

            self.x_min = 1
            self.x_max = len(all_values[0])
            self.x_max = self.x_max if self.x_max > self.x_min else self.x_max * 1.5

            all_values = np.array(all_values)
            self.y_min = np.min(all_values)
            self.y_min = self.y_min if self.y_min > 0 else 0
            self.y_max = np.max(all_values)

            self.local_paths = []

            self.extent = (self.x_min, self.y_min, self.x_max, self.y_max)
            self.status_bar = self.parentFrame.status_bar

        except Exception as err:
            self.ShowMsgBox(
                """LISA trend graph could not be created. Please check the time weights file.
            
Details: """ + str(err.message))
            self.isValidPlot = False
            self.parentFrame.Close(True)
            return None

        # linking-brushing events
        self.Register(stars.EVT_OBJS_SELECT, self.OnPathsSelected)
        self.Register(stars.EVT_OBJS_UNSELECT, self.OnNoPathSelect)
示例#11
0
    def __init__(self, parent, layer, data, **kwargs):
        PlottingCanvas.__init__(self, parent, data)

        try:
            self.layer = layer
            self.layer_name = layer.name

            #self.weight_file  = kwargs["weight"]
            self.cs_data_dict = kwargs["query_data"]
            self.step, self.step_by = kwargs["step"], kwargs["step_by"]
            self.start_date, self.end_date = kwargs["start"], kwargs["end"]
            self.parent = parent
            self.data_sel_keys = sorted(self.cs_data_dict.keys())
            self.data_sel_values = [
                self.cs_data_dict[i] for i in self.data_sel_keys
            ]
            #self.weight          = pysal.open(self.weight_file).read()
            self.t = len(self.cs_data_dict)  # number of data slices
            self.n = len(self.data_sel_values[0])  # number of shape objects

            self.datetime_intervals, self.interval_labels = GetDateTimeIntervals(
                self.start_date, self.end_date, self.t, self.step,
                self.step_by)

            # promote for time weights
            from stars.visualization.dialogs import TimeWeightsDlg
            tw_dlg = TimeWeightsDlg(self.main, self.t, self.layer.name)
            tw_path = tw_dlg.Show()
            if tw_path == False:
                raise Exception("no time weights")

            tweights = pysal.open(tw_path).read()

            # G settings
            from stars.visualization.dialogs import choose_local_g_settings
            b_gstar, b_binary = choose_local_g_settings(self)
            map_type = 'Gi*' if b_gstar else 'Gi'
            add_type = 'binary' if b_binary else 'row-standardized'
            self.title = 'Local G (%s,%s) Trend Graph -%s %s' % (
                map_type, add_type, layer.name, kwargs["title"])
            self.parentFrame.SetTitle(self.title)

            # calculate Gi using time weights
            time_gstar = dict()
            time_gstar_z = dict()
            tseries_data = []
            for pid in range(self.n):
                tseries = []
                for tid in range(self.t):
                    tseries.append(self.cs_data_dict[tid][pid])
                tseries_data.append(tseries)
            for pid in range(self.n):
                tseries = tseries_data[pid]
                y = np.array(tseries)
                #lg = pysal.esda.getisord.G_Local(y,tweights,transform='B',star=True)
                if b_binary == False:
                    lg = pysal.esda.getisord.G_Local(y, tweights, star=b_gstar)
                else:
                    lg = pysal.esda.getisord.G_Local(y,
                                                     tweights,
                                                     star=b_gstar,
                                                     transform='B')
                time_gstar[pid] = lg.p_sim
                time_gstar_z[pid] = lg.Zs

            trendgraph_data = dict()
            for i in range(self.n):
                data = []
                for j in range(self.t):
                    data.append(self.cs_data_dict[j][i])
                trendgraph_data[i] = data
            self.trendgraph_data = trendgraph_data

            self.tweights = tweights
            self.time_gstar = time_gstar
            self.time_gstar_z = time_gstar_z
            self.t_neighbors = tweights.neighbors

            data = [
                self.trendgraph_data, [], self.interval_labels, 0,
                self.time_gstar, self.time_gstar_z, self.t_neighbors
            ]
            self.data = data[0]
            self.highlight_ids = data[1]
            self.labels = data[2]
            self.tick = data[3]
            self.time_gstar_p = data[4]
            self.time_gstar_z = data[5]
            self.time_neighbors = data[6]
            self.n = len(self.data)

            self.selected_path_ids = []
            self.line_marker = []
            self.selected_line = None

            self.margin_right = 50
            self.margin_bottom = 140
            self.margin_left = 100
            self.enable_axis = False
            self.enable_axis_x = False
            self.enable_axis_y = False

            self.x_label = ""
            self.y_label = "# of observations"

            self.font_size_title = 8
            if os.name == "posix":
                self.font_size_title = 10
            self.font_size_x_axis = 8
            self.font_size_y_axis = 8
            self.font_size_xy_label = 8
            if os.name == "posix":
                self.font_size_xy_label = 10

            all_values = self.data.values()

            self.x_min = 1
            self.x_max = len(all_values[0])
            self.x_max = self.x_max if self.x_max > self.x_min else self.x_max * 1.5

            all_values = np.array(all_values)
            self.y_min = np.min(all_values)
            self.y_min = self.y_min if self.y_min > 0 else 0
            self.y_max = np.max(all_values)

            self.local_paths = []

            self.extent = (self.x_min, self.y_min, self.x_max, self.y_max)

        except Exception as err:
            self.ShowMsgBox('Local G Trend Graph could not be created. ' +
                            str(err.message))
            self.isValidPlot = False
            self.parentFrame.Close(True)
            return None

        # linking-brushing events
        self.Register(stars.EVT_OBJS_SELECT, self.OnPathsSelected)
        self.Register(stars.EVT_OBJS_UNSELECT, self.OnNoPathSelect)
示例#12
0
  def __init__(self,parent, layer, data, **kwargs):
      PlottingCanvas.__init__(self,parent,data)
 
      try:
          self.layer        = layer
          self.layer_name   = layer.name
          self.data         = data[0]
          self.highlight_ids= data[1]
          self.labels       = data[2]
          self.tick         = data[3]
          self.time_gstar_p = data[4]
          self.time_gstar_z = data[5]
          self.time_neighbors = data[6]
          self.n              = len(self.data)
          
          self.selected_path_ids = []
          
          self.margin_right  = 10
          self.margin_top    = 22
          self.margin_bottom = 80# if os.name == 'posix' else 35
          self.margin_left   = 35 if os.name == 'posix' else 60
          self.enable_axis   = False
          self.enable_axis_x = False
          self.enable_axis_y = False
         
          
          #self.title   = "Trend graph for Gi* Space Time: %s[%s]" % (self.layer_name,len(self.time_neighbors))
          self.title = "Select observations to view trend graph"
          self.x_label = "Time intervals"
          self.y_label = "# of observations"
          
          self.font_size_title    = 8
          if os.name == "posix":
              self.font_size_title= 10
          self.font_size_x_axis   = 8
          self.font_size_y_axis   = 8
          self.font_size_xy_label = 8
          if os.name == "posix":
              self.font_size_xy_label = 10
              
          
          all_values = self.data.values()
          
          self.x_min = 1
          self.x_max = len(all_values[0]) 
          self.x_max = self.x_max if self.x_max > self.x_min else self.x_max*1.5
          
          all_values = np.array(all_values)
          self.y_min = np.min(all_values)
          self.y_min = self.y_min if self.y_min > 0 else 0
          self.y_max = np.max(all_values)
          
          self.local_paths = []
          
          self.extent = (self.x_min, self.y_min, self.x_max,self.y_max)
          
      except Exception as err:
          self.ShowMsgBox('Sub trend graph could not be created. ' + str(err.message))
          self.isValidPlot = False
          self.parentFrame.Close(True)
          return None
      
      # linking-brushing events
      self.Register(stars.EVT_OBJS_SELECT, self.OnPathsSelected)
      self.Register(stars.EVT_OBJS_UNSELECT, self.OnNoPathSelect)
示例#13
0
    def __init__(self, parent, layer, data, **kwargs):
        PlottingCanvas.__init__(self, parent, data)

        try:
            self.layer = layer
            self.layer_name = layer.name
            self.data = data[0]
            self.highlight_ids = data[1]
            self.labels = data[2]
            self.tick = data[3]
            self.time_gstar_p = data[4]
            self.time_gstar_z = data[5]
            self.time_neighbors = data[6]
            self.n = len(self.data)

            self.selected_path_ids = []

            self.margin_right = 10
            self.margin_top = 22
            self.margin_bottom = 80  # if os.name == 'posix' else 35
            self.margin_left = 35 if os.name == 'posix' else 60
            self.enable_axis = False
            self.enable_axis_x = False
            self.enable_axis_y = False

            #self.title   = "Trend graph for Gi* Space Time: %s[%s]" % (self.layer_name,len(self.time_neighbors))
            self.title = "Select observations to view trend graph"
            self.x_label = "Time intervals"
            self.y_label = "# of observations"

            self.font_size_title = 8
            if os.name == "posix":
                self.font_size_title = 10
            self.font_size_x_axis = 8
            self.font_size_y_axis = 8
            self.font_size_xy_label = 8
            if os.name == "posix":
                self.font_size_xy_label = 10

            all_values = self.data.values()

            self.x_min = 1
            self.x_max = len(all_values[0])
            self.x_max = self.x_max if self.x_max > self.x_min else self.x_max * 1.5

            all_values = np.array(all_values)
            self.y_min = np.min(all_values)
            self.y_min = self.y_min if self.y_min > 0 else 0
            self.y_max = np.max(all_values)

            self.local_paths = []

            self.extent = (self.x_min, self.y_min, self.x_max, self.y_max)

        except Exception as err:
            self.ShowMsgBox('Sub trend graph could not be created. ' +
                            str(err.message))
            self.isValidPlot = False
            self.parentFrame.Close(True)
            return None

        # linking-brushing events
        self.Register(stars.EVT_OBJS_SELECT, self.OnPathsSelected)
        self.Register(stars.EVT_OBJS_UNSELECT, self.OnNoPathSelect)
示例#14
0
    def __init__(self,parent, layer, data, **kwargs):
        PlottingCanvas.__init__(self, parent, data)
       
        try:
            self.enable_axis = False
            self.enable_axis_x = False
            self.enable_axis_y = False
            self.isAutoScale = False
            self.enable_grid = False
          
            # setup toolbar for Markov LISA
            self.toolbar = parent.toolbar
            self.txt_from = wx.TextCtrl(self.toolbar, -1, "", size=(80,-1),style=wx.TE_PROCESS_ENTER)
            self.txt_to = wx.TextCtrl(self.toolbar, -1, "", size=(80,-1),style=wx.TE_PROCESS_ENTER)
            self.btn_previous = wx.Button(self.toolbar, 101, "<<")
            self.btn_next = wx.Button(self.toolbar, 102, ">>")
            self.toolbar.AddControl(wx.StaticText(self.toolbar,-1,"Current display from "))
            self.toolbar.AddControl(self.txt_from)
            self.toolbar.AddControl(wx.StaticText(self.toolbar,-1,"to"))
            self.toolbar.AddControl(self.txt_to)
            self.toolbar.AddControl(self.btn_previous)
            self.toolbar.AddControl(self.btn_next)
            parent.Bind(wx.EVT_BUTTON, self.OnClickPrevious, self.btn_previous)
            parent.Bind(wx.EVT_BUTTON, self.OnClickNext, self.btn_next)
            parent.Bind(wx.EVT_TEXT_ENTER, self.OnUpdateDisplay, self.txt_from)
            parent.Bind(wx.EVT_TEXT_ENTER, self.OnUpdateDisplay, self.txt_to)
            
            self.layer_name = layer.name
            self.moran_locals, lisa_markov_mt, self.interval_labels = data
            self.t = len(self.moran_locals)
            # convert LISA Markov move_types to {poly_id:seq_data}
            lisa_markov_mt.transpose()
            self.cs_data_dict = {}
            for i,seq in enumerate(lisa_markov_mt):
                self.cs_data_dict[i] = list(seq)
                
            self.status_bar = None
            self.data = True # Dummy
            self.title = "LISA Markov Plot"
            self.x_label = "time period"
            self.y_label = "shape id"
            self.tick = 0
            self.num_objects_per_page = 15
            self.n = len(self.cs_data_dict)
            self._y_max, self.x_max = lisa_markov_mt.shape
            self.x_max += 1
            #for setup view with extent, see PlotWidget.py line181
            self.y_max = self.num_objects_per_page 
            self.y_min, self.x_min = 0, 0
            self.extent = (self.x_min, 0, self.x_max, self.num_objects_per_page)
            
            self.selected_obj_ids = [] # objects that currectly selected
            self.highlighted_shape_objects = [] # objects that shown in plot

            # setup values for controls in toolbar
            self.id_start_object = 1
            self.id_end_object = self.num_objects_per_page if self.num_objects_per_page <= self.n else self.n
            self.txt_from.SetValue(str(self.id_start_object))
            self.txt_to.SetValue(str(self.id_end_object))
            self.btn_previous.Disable()
            if self.n <= self.num_objects_per_page:
                self.btn_next.Disable()
            self.toolbar.Realize()
            
        except Exception as err:
            self.ShowMsgBox("""LISA Markov plot could not be created. 
            
            
Details: """ + str(err.message))
            self.isValidPlot = False
            self.parentFrame.Close(True)
            return None
            
        # linking-brushing events
        self.Register(stars.EVT_OBJS_SELECT, self.OnObjsSelected)
        self.Register(stars.EVT_OBJS_UNSELECT, self.OnNoObjSelect)
示例#15
0
    def __init__(self, parent, layer, data, **kwargs):
        PlottingCanvas.__init__(self, parent, data)

        try:
            self.data = data[0]
            self.localMorans = data[1]
            self.timeNeighbors = data[2]
            self.highlight_ids = data[3]
            self.margin_right = 50
            self.margin_bottom = 60
            self.enable_axis = False
            self.enable_axis_x = False
            self.enable_axis_y = False

            self.selected_path_ids = []

            self.layer_name = layer.name
            self.layer = layer
            self.n = len(self.data)

            self.title = "Trend Graph for LISA Space Time: %s[%s]" % (
                self.layer_name, len(self.timeNeighbors))
            self.x_label = "Time interval"
            self.y_label = "Number of observations"

            self.font_size_title = 8
            if os.name == "posix":
                self.font_size_title = 10
            self.font_size_x_axis = 8
            self.font_size_y_axis = 8
            self.font_size_xy_label = 8
            if os.name == "posix":
                self.font_size_xy_label = 10

            all_values = self.data.values()

            self.x_min = 1
            self.x_max = len(all_values[0])
            self.x_max = self.x_max if self.x_max > self.x_min else self.x_max * 1.5

            all_values = np.array(all_values)
            self.y_min = np.min(all_values)
            self.y_min = self.y_min if self.y_min > 0 else 0
            self.y_max = np.max(all_values)

            self.local_paths = []

            self.extent = (self.x_min, self.y_min, self.x_max, self.y_max)
            self.status_bar = self.parentFrame.status_bar

        except Exception as err:
            self.ShowMsgBox(
                """LISA trend graph could not be created. Please check the time weights file.
            
Details: """ + str(err.message))
            self.isValidPlot = False
            self.parentFrame.Close(True)
            return None

        # linking-brushing events
        self.Register(stars.EVT_OBJS_SELECT, self.OnPathsSelected)
        self.Register(stars.EVT_OBJS_UNSELECT, self.OnNoPathSelect)