Exemple #1
0
 def mk_edit(vals):
     if vals.dtype is np.dtype(int):
         return NumberEditor()
     elif vals.dtype is np.dtype(str):
         return StringEditor()
     else:
         return StringEditor()
Exemple #2
0
    def _get_columns(self):
        if self.value is None:
            return []

        indexes = self.indexes
        col_names = list(self.value.columns)
        if not self.hierarchical or len(indexes) == 1:
            col_names = indexes + col_names
        else:
            col_names = indexes[-1:] + col_names
        df = self.value.reset_index() if len(indexes) > 1 else self.value
        columns = []
        for col in col_names:
            if col in df.columns:
                data = df[col]
            else:
                data = df.index

            col_kwargs = {}
            kind = data.dtype.kind
            if kind == 'i':
                formatter = NumberFormatter()
                editor = IntEditor()
            elif kind == 'f':
                formatter = NumberFormatter(format='0,0.0[00000]')
                editor = NumberEditor()
            elif isdatetime(data) or kind == 'M':
                formatter = DateFormatter(format='%Y-%m-%d %H:%M:%S')
                editor = DateEditor()
            else:
                formatter = StringFormatter()
                editor = StringEditor()

            if col in self.editors:
                editor = self.editors[col]

            if col in indexes or editor is None:
                editor = CellEditor()

            if col in self.formatters:
                formatter = self.formatters[col]
            if str(col) != col:
                self._renamed_cols[str(col)] = col
            if isinstance(self.widths, int):
                col_kwargs['width'] = self.widths
            elif str(col) in self.widths:
                col_kwargs['width'] = self.widths.get(str(col))

            title = str(col)
            if col in indexes and len(indexes) > 1 and self.hierarchical:
                title = 'Index: %s' % ' | '.join(indexes)
            column = TableColumn(field=str(col),
                                 title=title,
                                 editor=editor,
                                 formatter=formatter,
                                 **col_kwargs)
            columns.append(column)
        return columns
Exemple #3
0
    def _get_column_definitions(self, col_names, df):
        import pandas as pd
        indexes = self.indexes
        columns = []
        for col in col_names:
            if col in df.columns:
                data = df[col]
            else:
                data = df.index

            if isinstance(data, pd.DataFrame):
                raise ValueError("DataFrame contains duplicate column names.")

            col_kwargs = {}
            kind = data.dtype.kind
            if kind == 'i':
                formatter = NumberFormatter()
                editor = IntEditor()
            elif kind == 'b':
                formatter = StringFormatter()
                editor = CheckboxEditor()
            elif kind == 'f':
                formatter = NumberFormatter(format='0,0.0[00000]')
                editor = NumberEditor()
            elif isdatetime(data) or kind == 'M':
                if len(data) and isinstance(data.values[0], dt.date):
                    date_format = '%Y-%m-%d'
                else:
                    date_format = '%Y-%m-%d %H:%M:%S'
                formatter = DateFormatter(format=date_format)
                editor = DateEditor()
            else:
                formatter = StringFormatter()
                editor = StringEditor()

            if col in self.editors and not isinstance(self.editors[col],
                                                      (dict, str)):
                editor = self.editors[col]

            if col in indexes or editor is None:
                editor = CellEditor()

            if col in self.formatters and not isinstance(
                    self.formatters[col], (dict, str)):
                formatter = self.formatters[col]

            if str(col) != col:
                self._renamed_cols[str(col)] = col

            if isinstance(self.widths, int):
                col_kwargs['width'] = self.widths
            elif str(col) in self.widths:
                col_kwargs['width'] = self.widths.get(str(col))

            title = self.titles.get(col, str(col))
            if col in indexes and len(indexes) > 1 and self.hierarchical:
                title = 'Index: %s' % ' | '.join(indexes)
            column = TableColumn(field=str(col),
                                 title=title,
                                 editor=editor,
                                 formatter=formatter,
                                 **col_kwargs)
            columns.append(column)
        return columns
Exemple #4
0
    def weather_tab(self):
        data = pd.DataFrame(columns = ['time','desc','temp','wind','humidity'])
        self.weather_source = ColumnDataSource(data)

        self.weather_subtitle = Div(text="Weather", css_classes=['subt-style'])

        columns = [TableColumn(field='time', title='Time (local)', width=75),
                   TableColumn(field='desc', title='Description', width=200, editor=StringEditor()),
                   TableColumn(field='temp', title='Temperature (C)', width=100, editor=NumberEditor()),
                   TableColumn(field='wind', title='Wind Speed (mph)', width=120, editor=NumberEditor()),
                   TableColumn(field='humidity', title='Humidity (%)', width=100, editor=PercentEditor())]
        self.weather_inst = Div(text="Every hour include a description of the weather and any other relevant information, as well as fill in all the fields below.  Click the Update Night Log button after every hour's entry. To update a cell: double click in it, record the information, click out of the cell.", width=1000, css_classes=['inst-style'])
        self.weather_time = TextInput(placeholder='17:00', value=None, width=100) #title='Time in Kitt Peak local time', 
        self.weather_desc = TextInput(title='Description', placeholder='description', value=None)
        self.weather_temp = TextInput(title='Temperature (C)', placeholder='50', value=None)
        self.weather_wind = TextInput(title='Wind Speed (mph)', placeholder='10', value=None)
        self.weather_humidity = TextInput(title='Humidity (%)', placeholder='5', value=None)
        self.weather_table = DataTable(source=self.weather_source, columns=columns)
        self.weather_btn = Button(label='Add Weather', css_classes=['add_button'])
Exemple #5
0

fpa_experts = ['Duan', 'Fanning', 'Fagrelius', 'Schubnell', 'Silber',
               'Poppett', 'Kai']
pcm = pm.PosCalManager()
pi = pm.get_positioner_index()
source = ColumnDataSource(data=pcm.table)
source.selected.indices = [pcm.i_selected]  # ['1d']['indices'] = [i_selected]
title = Div(text='''
<font size="4">Positioner Calibrations</font> (some columns editable)''',
            width=500)
columns = [TableColumn(field='UTC', title='UTC', width=160),
           TableColumn(field='expid', title='expid', width=50),
           TableColumn(field='test name', title='test name', width=260),
           TableColumn(field='exptime', title='exptime/s', width=60,
                       editor=NumberEditor()),
           TableColumn(field='dome', title='dome', width=50,
                       editor=SelectEditor(options=['open', 'closed', '?'])),
           TableColumn(field='zenith angle', title='zenith angle', width=69,
                       editor=IntEditor()),
           TableColumn(field='tracking', title='tracking', width=50,
                       editor=SelectEditor(options=['on', 'off', '?'])),
           TableColumn(field='T ambient', title='T ambient/°C', width=75,
                       editor=NumberEditor()),
           TableColumn(field='T mirror', title='T mirror/°C', width=65,
                       editor=NumberEditor()),
           TableColumn(field='PMTC', title='PMTC', width=50,
                       editor=SelectEditor(options=['on', 'off', '?'])),
           TableColumn(field='PCVF', title='PCVF', width=50,
                       editor=SelectEditor(options=['on', 'off', '?'])),
           TableColumn(field='dome louvers', title='dome louvers', width=75,