Exemplo n.º 1
0
def makeTrackwayWeightedBoxTrace(trackwayRow, values, uncertainties, **kwargs):
    dd = DensityDistribution.fromValuesAndUncertainties(
        values=values,
        uncertainties=uncertainties)
    values = dd.getDistributionPoints(2048)

    normality = trackwayRow['Normality'].values \
        if trackwayRow is not None \
        else -1

    color = getNormalityColor(normality, 'g', 'r')
    color.opacity = 0.5

    return plotlyGraph.Box(
        boxpoints=False,
        name=trackwayRow['Name'].values,
        y=values,
        fillcolor=color.webRGBA,
        boxmean=False,
        line=plotlyGraph.Line(
            color=color.webRGBA,
            width=1),
        marker=plotlyGraph.Marker(
            size=1,
            color=color.webRGBA) )
Exemplo n.º 2
0
def getDensityDistributionTrace(data, columnName, errorColumnName, **kwargs):
    minVal = (data[columnName] - 3.0*data[errorColumnName]).min()
    maxVal = (data[columnName] + 3.0*data[errorColumnName]).max()

    values = []
    for index, row in data.iterrows():
        values.append(NumericUtils.toValueUncertainty(
            value=row[columnName],
            uncertainty=row[errorColumnName] ))

    dd = DensityDistribution(values=values)
    xValues = np.linspace(minVal, maxVal, 200)
    yValues = dd.createDistribution(xValues)

    return plotlyGraph.Scatter(
        x=xValues,
        y=yValues,
        **kwargs), dd
Exemplo n.º 3
0
def makeHistograms(label, columnName, errorColumnName, tracks):
    index = 0
    histTraces = []
    densityTraces = []
    xStart = tracks[columnName].min()
    xEnd = tracks[columnName].max()
    sites = tracks.site.unique()
    for site in sites:
        index += 1
        color = PlotConfigs.SITE_SPECS[site]['color']
        siteSlice = tracks[tracks.site == site]
        histTraces.append(plotlyGraph.Histogram(
            name=site,
            x=siteSlice[columnName],
            autobinx=False,
            xbins=plotlyGraph.XBins(
                start=xStart,
                end=xEnd,
                size=0.01),
            xaxis='x1',
            yaxis='y%s' % int(index),
            marker=plotlyGraph.Marker(color=color) ))

        distributionValues = []
        for i, row in siteSlice.iterrows():
            distributionValues.append(NumericUtils.toValueUncertainty(
                value=row[columnName],
                uncertainty=row[errorColumnName]))

        dd = DensityDistribution(values=distributionValues)
        xValues = dd.getAdaptiveRange(10)
        yValues = dd.createDistribution(xValues=xValues, scaled=True)

        densityTraces.append(plotlyGraph.Scatter(
            name=site,
            x=xValues,
            y=yValues,
            xaxis='x1',
            yaxis='y%s' % int(index),
            mode='lines',
            fill='tozeroy',
            marker=plotlyGraph.Marker(color=color) ))

    fig = plotlyTools.make_subplots(
        rows=len(sites), cols=1,
        shared_xaxes=True,
        print_grid=False)
    fig['data'] += plotlyGraph.Data(histTraces)
    fig['layout'].update(title='%s Distributions by Tracksite' % label)

    url = plotly.plot(
        filename='A16/%s-Distributions' % label.replace(' ', '-'),
        figure_or_data=fig,
        auto_open=False)
    print('HISTOGRAM[%s]:' % label, PlotlyUtils.toEmbedUrl(url))

    fig = plotlyTools.make_subplots(
        rows=len(sites), cols=1,
        shared_xaxes=True,
        print_grid=False)
    fig['data'] += plotlyGraph.Data(densityTraces)
    fig['layout'].update(
        title='%s Distributions by Tracksite' % label,
        xaxis1=plotlyGraph.XAxis(
            autorange=False,
            range=[xStart, xEnd]))

    url = plotly.plot(
        filename='A16/%s-Kernel-Distributions' % label.replace(' ', '-'),
        figure_or_data=fig,
        auto_open=False)
    print('KERNEL-DENSITY[%s]:' % label, PlotlyUtils.toEmbedUrl(url))