コード例 #1
0
ファイル: TableTimeSeriesFrames.py プロジェクト: rocdat/STLIB
    def __init__(self, parent, identifiers, listOfArrays):
        TableBase.__init__(self, parent)

        self.resize(1, 2 * len(identifiers))
        self.setColumnLabels(statisticsLabels(identifiers))

        mean, stdDev = meanStdDev(listOfArrays)

        row = 0
        self.SetRowLabelValue(row, str(row + 1))
        col = 0
        for i in range(len(mean)):
            self.SetCellValue(row, col, '%g' % mean[i])
            col += 1
            self.SetCellValue(row, col, '%g' % stdDev[i])
            col += 1
コード例 #2
0
ファイル: TableTimeSeriesFrames.py プロジェクト: rocdat/STLIB
    def __init__(self, parent, identifiers, times, listOfArrays):
        TableBase.__init__(self, parent)

        self.resize(len(times), 1 + 2 * len(identifiers))
        self.setColumnLabels(['Time'] + statisticsLabels(identifiers))
            
        mean, stdDev = meanStdDev(listOfArrays)

        row = 0
        for frame in range(len(times)):
            self.SetRowLabelValue(row, str(row + 1))
            col = 0
            # Time.
            self.SetCellValue(row, col, '%g' % times[frame])
            col += 1
            for i in range(len(mean[frame])):
                self.SetCellValue(row, col, '%g' % mean[frame][i])
                col += 1
                self.SetCellValue(row, col, '%g' % stdDev[frame][i])
                col += 1
            row += 1
コード例 #3
0
ファイル: ExportTimeSeries.py プロジェクト: rocdat/STLIB
 def framesBinnedStat(self, model, output, selected, writer):
     # Whether to output the std. dev.
     stdDev = [self.grid.GetCellValue(i, 1) for i in selected]
     # The headers.
     headers = ['Time']
     for i in selected:
         identifier = model.reactions[output.recordedReactions[i]].id
         headers.append('m(%s)' % identifier)
         if stdDev[i]:
             headers.append('s(%s)' % identifier)
     writer.writerow(headers)
     # Write each data row.
     for f in range(len(output.frameTimes) - 1):
         row = [output.frameTimes[f]]
         for s in selected:
             data = [x[f + 1, s] - x[f, s] for x in output.reactionCounts]
             # If the standard deviation box is checked.
             if stdDev[s]:
                 row.extend(list(meanStdDev(data)))
             else:
                 row.append(mean(data))
         writer.writerow(row)
コード例 #4
0
ファイル: TableTimeSeriesFrames.py プロジェクト: rocdat/STLIB
    def __init__(self, parent, identifiers, times, listOfArrays):
        TableBase.__init__(self, parent)

        assert len(times) > 1
        self.resize(len(times) - 1, 1 + 2 * len(identifiers))
        self.setColumnLabels(['Interval'] + statisticsLabels(identifiers))
            
        mean, stdDev = meanStdDev([x[1:] - x[:-1] for x in listOfArrays])

        row = 0
        for frame in range(len(times) - 1):
            self.SetRowLabelValue(row, str(row + 1))
            col = 0
            # Interval.
            self.SetCellValue(row, col, '%g to %g' % 
                              (times[frame], times[frame + 1]))
            col += 1
            for i in range(len(mean[frame])):
                self.SetCellValue(row, col, '%g' % mean[frame][i])
                col += 1
                self.SetCellValue(row, col, '%g' % stdDev[frame][i])
                col += 1
            row += 1
コード例 #5
0
    def plotFrames(self, output):
        # Record the kind of plot to generate.
        isSpeciesSelected = self.species.GetValue()
        isCumulativeReactionsSelected = self.cumulativeReactions.GetValue()
        #isBinnedReactionsSelected = self.binnedReactions.GetValue()
        isTrajectoriesSelected = self.trajectories.GetValue()
        isMeanSelected = self.mean.GetValue()
        #isStdDevSelected = self.stdDev.GetValue()

        # Check that at least one row has been selected.
        if not self.grid.areAnyItemsSelected():
            wx.MessageBox('No rows are selected.', 'Error.')
            return
        # The items to plot.
        indices = self.grid.getCheckedItems()
        if not indices:
            return
        if isTrajectoriesSelected:
            # Plot each trajectory.
            for i in range(len(output.populations)):
                for index in indices:
                    if isSpeciesSelected:
                        p = output.populations[i][:, index]
                        times = output.frameTimes
                    elif isCumulativeReactionsSelected:
                        p = output.reactionCounts[i][:, index]
                        times = output.frameTimes
                    else: # Binned reaction counts.
                        p = output.reactionCounts[i][1:, index] - \
                            output.reactionCounts[i][:-1, index]
                        # Midpoints.
                        times = 0.5 * (output.frameTimes[0:-1] + 
                                       output.frameTimes[1:])
                    if self.grid.useMarkers(index):
                        plot(times, p,
                             **self.grid.getLineAndMarkerStyles(index))
                    else:
                        plot(times, p, **self.grid.getLineStyles(index))
        elif isMeanSelected:
            # Plot the mean and optionally the standard deviation.
            for index in indices:
                if isSpeciesSelected:
                    data = [x[:, index] for x in output.populations]
                    times = output.frameTimes
                elif isCumulativeReactionsSelected:
                    data = [x[:, index] for x in output.reactionCounts]
                    times = output.frameTimes
                else: # Binned reaction counts.
                    data = [x[1:, index] - x[:-1, index] for x in 
                            output.reactionCounts]
                    # Midpoints.
                    times = output.frameTimes
                    times = 0.5 * (times[0:-1] + times[1:])
                # If the standard deviation box is checked.
                if self.grid.GetCellValue(index, 1):
                    y, yerr = meanStdDev(data)
                else:
                    y = mean(data)
                    yerr = None
                if self.grid.useMarkers(index):
                    errorbar(times, y, yerr = yerr, 
                             **self.grid.getLineAndMarkerStyles(index))
                else:
                    errorbar(times, y, yerr=yerr,
                             **self.grid.getLineStyles(index))
        else: # isStdDevSelected
            # Plot the standard deviation.
            for index in indices:
                if isSpeciesSelected:
                    data = [x[:, index] for x in output.populations]
                    times = output.frameTimes
                elif isCumulativeReactionsSelected:
                    data = [x[:, index] for x in output.reactionCounts]
                    times = output.frameTimes
                else: # Binned reaction counts.
                    data = [x[1:, index] - x[:-1, index] for x in 
                            output.reactionCounts]
                    # Midpoints.
                    times = output.frameTimes
                    times = 0.5 * (times[0:-1] + times[1:])
                # If the standard deviation box is checked.
                y, yerr = meanStdDev(data)
                if self.grid.useMarkers(index):
                    plot(times, yerr, **self.grid.getLineAndMarkerStyles(index))
                else:
                    plot(times, yerr, **self.grid.getLineStyles(index))
        self._showLegendAndLabels(indices)
        self.options.setLimits()
        draw()