Ejemplo n.º 1
0
# create the three lines of credit text in the two bottom corners
label_opts1 = dict(x=-84, y=42, x_units='screen', y_units='screen')

label_opts2 = dict(x=-84, y=47, x_units='screen', y_units='screen')

label_opts3 = dict(x=612,
                   y=64,
                   x_units='screen',
                   y_units='screen',
                   text_align='right',
                   text_font_size='9pt')

msg1 = 'By Exoplots'
# when did the data last get updated
modtimestr = get_update_time().strftime('%Y %b %d')
msg3 = 'Data: NASA Exoplanet Archive'

caption1 = Label(text=msg1, **label_opts1)
caption2 = Label(text=modtimestr, **label_opts2)
caption3 = Label(text=msg3, **label_opts3)

fig.add_layout(caption1, 'below')
fig.add_layout(caption2, 'below')
fig.add_layout(caption3, 'below')

plotting.save(fig)

# save the individual pieces so we can just embed the figure without the whole
# html page
script, div = components(fig, theme=theme)
Ejemplo n.º 2
0
        pcdata['base'] = base
        pccumul['base'] = base
    pcleglab.append(imeth + f' ({ntot:,})')

contots = np.array(contots).sum(axis=0)
concumtots = np.array(concumtots).sum(axis=0)
condata['total'] = contots
concumul['total'] = concumtots

pctots = np.array(pctots).sum(axis=0)
pccumtots = np.array(pccumtots).sum(axis=0)
pcdata['total'] = pctots
pccumul['total'] = pccumtots

# get the exponential growth bit
cyear = get_update_time().year
# how many days is this year
fullyear = datetime(cyear + 1, 1, 1) - datetime(cyear, 1, 1)
# extrapolate this year's total through the full year
upscale = fullyear / (get_update_time() - datetime(cyear, 1, 1))
conscaled = concumtots * 1
conscaled[-1] = conscaled[-2] + upscale * (conscaled[-1] - conscaled[-2])
pcscaled = pccumtots * 1
pcscaled[-1] = pcscaled[-2] + upscale * (pcscaled[-1] - pcscaled[-2])
# use a weighted exponential growth fit
# see https://mathworld.wolfram.com/LeastSquaresFittingExponential.html
conexp = np.polyfit(np.arange(conscaled.size),
                    np.log(conscaled),
                    1,
                    w=np.log(conscaled))
conpreds = np.exp(np.polyval(conexp, np.arange(conscaled.size)))