예제 #1
0
 def add_source_from_clipboard_cb(self, w):
     text = self.clipboard.wait_for_text()
     if text != "":
         self.add_source(None, data=load_data(None, datastr=text))
예제 #2
0
 def load_data(self):
     self.data=load_data(self.file)
예제 #3
0
 def add_source_from_file_cb(self, w):
     filename = dialogs.open()
     with open(filename) as f:
         text = f.read()
         self.add_source(None, data=load_data(None, datastr=text))
예제 #4
0
    def __init__(self, id=0, datafile=None, name="", data=None, x_col=0, y_col=1,
                 folder=False,
                 x_expr="x", x_expr_enable=False, y_expr="y",  y_expr_enable=False,
                 norm_enable=False, norm_max_pt=0, norm_max_y=0, norm_min_pt=0, norm_min_y=0,
                 scale_enable=False, scale=1, shift_enable=False, shift=0, comment=""):

        Subject.__init__(self)

        self.folder=folder
        self.transpose=False

        if data is not None:
            self.data=data
        elif datafile:
            try:
                self.data=load_data(datafile)
            except:
                raise SourceError(1)
                return None
        else:
            x_data=array([])
            y_data=array([])
            self.data=array([x_data, y_data])

        # if self.data.shape[0] > self.data.shape[1]:
            # print "Transposing short data"
            # self.transpose=True
            # self.data=transpose(self.data)

        if len(self.data)==1:
            print "One column data; generating X column..."
            self.x_data=arange(len(self.data[0]))
            self.y_data=self.data[0]
        else:
            self.x_data=self.data[x_col]
            self.y_data=self.data[y_col]


        self.id=id

        self.file=datafile
        if name=="":
            if datafile is None:
                self.name="Source"+str(self.id)
            else:
                self.name=datafile.split("/")[-1].split(".")[0].replace("_"," ")
        else:
            self.name=name

    #        self.plots=[]

        if not folder:
            self.x_col=x_col
            self.y_col=y_col

            self.y_expr=y_expr
            self.y_expr_enable=y_expr_enable
            if x_expr is "x":
                if len(self.data) != 1:
                    self.x_expr=x_expr
                    self.x_expr_enable=x_expr_enable
                else:
                    self.x_expr="arange("+str(len(self.data[0]))+")"
                    self.x_expr_enable=True
            else:
                self.x_expr=x_expr
                self.x_expr_enable=x_expr_enable

            self.norm_enable=False
            if len(self.y_data)>0:
                #self.norm_min_pt=self.y_data.argmin()
                #self.norm_max_pt=self.y_data.argmax()
                self.norm_min_pt=0
                self.norm_max_pt=len(self.y_data)-1
            else:
                self.norm_min_pt=0
                self.norm_max_pt=0
            self.norm_min_y=0.0
            self.norm_max_y=1.0

            self.scale_enable=False
            self.scale=1.0
            self.shift_enable=False
            self.shift=0.0

            self.gen_col_id = len(self.data)
            self.gen_cols = []

        self.comment=comment
        self.toggle=False