def jsonify(self):
        contents = [
            self.dtype.jsonify(),
            self.dims.jsonify(),
            self.attributes.jsonify(),
        ]

        if self.data:
            contents.append(self.data.jsonify())
        elif self.old_data and self.new_data:
            contents += self.old_data.jsonify(), self.new_data.jsonify()

        sec = utils.json_section(self, contents)

        if self.companions:
            sec['contents'].append(self.companions.jsonify())

        sec['type'] = 'variableDiff'
        if len(self.dims) == 1:
            if isinstance(self.dims, TimelineDiff):
                if self.dims[0].old == self.dims[0].new:
                    sec['dims'] = self.dims[0].new
                else:
                    sec['dims'] = 'varying'
            else:
                sec['dims'] = self.dims[0].val
        else:
            sec['dims'] = 'varying'
        return sec
    def jsonify(self):

        columns, tooltips = self.data_type.columns()

        if len(self) == 1:
            sec = {
                'type': 'staticSummary',
                'name': self.name,
                'columns': columns,
                'tooltips': tooltips,
                'val': self[0].val.row()
            }
            if hasattr(self, '_difference'):
                sec['difference'] = self._difference
            return sec

        columns = ['beg', 'end']+columns
        tooltips = ['', '']+tooltips
        csv = [[self.ds.file_timeline[log.beg].beg, self.ds.file_timeline[log.end].end]+log.val.row() for log in self]
        csv = [columns, tooltips]+csv

        return utils.json_section(self, [
            {
                'type': 'plot',
                'data': csv,
                'separate': ['data']
           }
        ])
    def jsonify(self):

        columns, tooltips = self.data_type.columns()

        if len(self.data) == 1:
            val = next(iter(self.data.values())).row()
            sec = {
                'type': 'staticSummary',
                'name': self.name,
                'columns': columns,
                'tooltips': tooltips,
                'val': val
            }
            if hasattr(self, '_difference'):
                sec['difference'] = self._difference
            return sec

        # format data for a csv file
        columns = ['beg', 'end']+columns
        tooltips = ['', '']+tooltips
        csv = [[time, time+self.ds.sample_interval]+summary.row() for time, summary in sorted(self.data.items())]
        csv = [columns, tooltips]+csv

        plot_json = {
                'type': 'plot',
                'data': csv,
                'ds_path': self.ds.path
            }

        if self.ds.use_dq_inspector:
            plot_json['var_name'] = self.var_name

        return utils.json_section(self, [plot_json])
Beispiel #4
0
    def jsonify(self):

        columns, tooltips = self.data_type.columns()

        if len(self) == 1:
            sec = {
                'type': 'staticSummary',
                'name': self.name,
                'columns': columns,
                'tooltips': tooltips,
                'val': self[0].val.row()
            }
            if hasattr(self, '_difference'):
                sec['difference'] = self._difference
            return sec

        columns = ['beg', 'end']+columns
        tooltips = ['', '']+tooltips
        csv = [[self.ds.file_timeline[log.beg].beg, self.ds.file_timeline[log.end].end]+log.val.row() for log in self]
        csv = [columns, tooltips]+csv

        return utils.json_section(self, [
            {
                'type': 'plot',
                'data': csv,
                'separate': ['data']
           }
        ])
Beispiel #5
0
    def jsonify(self):

        columns, tooltips = self.data_type.columns()

        if len(self.data) == 1:
            val = next(iter(self.data.values())).row()
            sec = {
                'type': 'staticSummary',
                'name': self.name,
                'columns': columns,
                'tooltips': tooltips,
                'val': val
            }
            if hasattr(self, '_difference'):
                sec['difference'] = self._difference
            return sec

        # Format data for a csv file...
        columns = ['beg', 'end']+columns
        tooltips = ['', '']+tooltips
        csv = [[time, time+self.ds.sample_interval]+summary.row() for time, summary in sorted(self.data.items())]
        csv = [columns, tooltips]+csv

        plot_json = {
                'type': 'plot',
                'data': csv,
                'ds_path': self.ds.path
            }

        if self.ds.use_dq_inspector:
            plot_json['var_name'] = self.var_name

        return utils.json_section(self, [plot_json])
    def jsonify(self):

        columns, tooltips = self.data_type.columns()

        if len(self.dsd.summary_times) == 1:
            sec = None
            if self.old[0] != self.new[0]:
                sec = {
                    'type': 'staticSummaryDiff',
                    'name': self.name,
                    'columns': columns,
                    'tooltips': tooltips,
                    'old': self.old[0].row(),
                    'new': self.new[0].row()
                }
            else:
                sec = {
                    'type': 'staticSummary',
                    'name': self.name,
                    'val': self.new[0].row()
                }

            sec['difference'] = self.difference()
            return sec

        columns = ['beg', 'end'] + columns
        tooltips = ['', ''] + tooltips
        old_csv = [columns, tooltips] + \
        [
            [t, t+self.dsd.sample_interval]+(x.row() if x is not None else []) \
            for t, x in zip(self.dsd.summary_times, self.old)
        ]
        new_csv = [columns, tooltips] + \
        [
            [t, t+self.dsd.sample_interval]+(x.row() if x is not None else [])
            for t, x in zip(self.dsd.summary_times, self.new)
        ]

        # add nones to complete any empty rows
        for csv in old_csv, new_csv:
            length = max(map(len, csv))
            if length == 2: continue
            for row in csv:
                if len(row) == 2:
                    row += [None] * (length - 2)

        plotDiff_json = {
            'type': 'plotDiff',
            'old_data': old_csv,
            'new_data': new_csv,
            'old_ds_path': self.dsd.old_path,
            'new_ds_path': self.dsd.new_path
        }

        if self.dsd.use_dq_inspector:
            plotDiff_json['var_name'] = self.var_name

        return utils.json_section(self, [plotDiff_json])
    def jsonify(self):
        columns, tooltips = self.data_type.columns()

        if len(self) == 1:
            sec = None
            if self[0].old != self[0].new:
                sec = {
                    'type': 'staticSummaryDiff',
                    'name': self.name,
                    'columns': columns,
                    'tooltips': tooltips,
                    'old': self[0].old.row(),
                    'new': self[0].new.row()
                }
            else:
                sec = {
                    'type': 'staticSummary',
                    'name': self.name,
                    'columns': columns,
                    'tooltips': tooltips,
                    'val': self[0].new.row()
                }

            sec['difference'] = self.difference()
            return sec

        columns = ['beg', 'end'] + columns
        tooltips = ['', ''] + tooltips
        old_csv = [columns, tooltips
                   ] + [[d.beg, d.end] +
                        (d.old.row() if d.old is not None else [])
                        for d in self]
        new_csv = [columns, tooltips
                   ] + [[d.beg, d.end] +
                        (d.new.row() if d.new is not None else [])
                        for d in self]

        # add nones to complete any empty rows
        for csv in old_csv, new_csv:
            length = max(map(len, csv))
            if length == 2: continue
            for row in csv:
                if len(row) == 2:
                    row += [None] * (length - 2)

        return utils.json_section(self, [{
            'type': 'plotDiff',
            'data_type': self.data_type.type_name,
            'old_data': old_csv,
            'new_data': new_csv
        }])
    def jsonify(self):

        n_diffs = {'same': 0, 'changed': 0, 'added': 0, 'removed': 0}

        for val in self.values():
            diff = val.difference() if hasattr(val, 'difference') else \
                   val._difference  if hasattr(val, '_difference') else \
                   'same'

            n_diffs[diff] += 1

        sec = utils.json_section(self, [t.jsonify() for t in self.values()])
        sec['type'] = 'groupDiff'
        sec['n_diffs'] = n_diffs
        return sec
    def jsonify(self):
        sec = utils.json_section(self, [
            self.dtype.jsonify(),
            self.dims.jsonify(),
            self.attributes.jsonify(),
        ])
        if not self.metadata_only:
            sec['contents'].append(self.data.jsonify())

        if self.companions:
            sec['contents'].append(self.companions.jsonify())

        sec['type'] = 'variable'
        sec['dims'] = self.dims[0].val if len(self.dims) == 1 else 'varying'

        return sec
Beispiel #10
0
    def jsonify(self):
        sec = utils.json_section(self, [
            self.dtype.jsonify(),
            self.dims.jsonify(),
            self.attributes.jsonify(),
        ])
        if not self.metadata_only:
            sec['contents'].append(self.data.jsonify())

        if self.companions:
            sec['contents'].append(self.companions.jsonify())

        sec['type'] = 'variable'
        sec['dims'] = self.dims[0].val if len(self.dims) == 1 else 'varying'

        return sec
 def jsonify(self):
     if len(self) == 1:
         sec = {
             'type': 'staticValueDiff',
             'name': self.name,
             'old': self[0].old,
             'new': self[0].new
         }
         if hasattr(self, '_difference'):
             sec['difference'] = self._difference
         return sec
     else:
         return utils.json_section(self, [{
             'type':
             'timelineDiff',
             'data':
             [['old', 'new', 'beg', 'end']] + [[d.old, d.new, d.beg, d.end]
                                               for d in self]
         }])
 def jsonify(self):
     if len(self) == 1:
         sec = {
             'type': 'staticValue',
             'name': self.name,
             'val': self[0].val
         }
         if hasattr(self, '_difference'):
             sec['difference'] = self._difference
         return sec
     else:
         return utils.json_section(self, 
             [
                 {
                     'type': 'timeline',
                     'data': [['beg', 'end', 'val']]+[
                         [
                             self.ds.file_timeline[l.beg].beg,
                             self.ds.file_timeline[l.end].end,
                             l.val
                         ] for l in self
                     ],
                 }
             ])
Beispiel #13
0
 def jsonify(self):
     if len(self) == 1:
         sec = {
             'type': 'staticValue',
             'name': self.name,
             'val': self[0].val
         }
         if hasattr(self, '_difference'):
             sec['difference'] = self._difference
         return sec
     else:
         return utils.json_section(self, 
             [
                 {
                     'type': 'timeline',
                     'data': [['beg', 'end', 'val']]+[
                         [
                             self.ds.file_timeline[l.beg].beg,
                             self.ds.file_timeline[l.end].end,
                             l.val
                         ] for l in self
                     ],
                 }
             ])
 def jsonify(self):
     ''''''
     return utils.json_section(self, [x.jsonify() for x in self.values()])
Beispiel #15
0
 def jsonify(self):
     ''''''
     return utils.json_section(self, [x.jsonify() for x in self.values()])