import datetime
import glob
import os
import astropy.units as u
import matplotlib as mpl
import matplotlib.pyplot as plt
plt.style.use('nbs.mplstyle')
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import numpy as np
import pandas as pd
from scipy.stats import binned_statistic
from scipy.ndimage import gaussian_filter1d
os.makedirs('../plots', exist_ok=True)
dfs = {}
for filename in glob.glob('../cache/*fulltext.csv'):
df = pd.read_csv(filename, index_col='pubdate', parse_dates=True)
name = os.path.basename(filename).split('-fulltext')[0]
dfs[name] = df
prog_languages = ['python', 'idl', 'julia', 'matlab']
for yscale in ['linear', 'log']:
fig, ax = plt.subplots(figsize=(8, 6), constrained_layout=True)
for name in prog_languages:
df = dfs[name]
g = df.groupby(by=[df.index.year]).count()
group_dates = np.array([datetime.date(x, 1, 1) for x in g.index])
mentions = g['pubdate.1'].values
if name == 'julia':
jmask = group_dates > datetime.date(2012, 1, 1)
group_dates = group_dates[jmask]
mentions = mentions[jmask]
ax.plot(group_dates,
mentions,
marker='', drawstyle='steps-mid',
lw=2, label=name)
ax.set_xlim(datetime.date(1991, 8, 1),
datetime.datetime.now() - datetime.timedelta(days=60))
ax.legend(loc='upper left', fontsize=16)
ax.set_xlabel('time')
ax.set_ylabel('Fulltext mentions per year')
ax.set_yscale(yscale)
fig.text(1, 0, 'Source: NASA/ADS', fontsize=16, ha='right')
fig.savefig(f'../plots/prog-lang-fulltext-{yscale}.png', dpi=300)
for yscale in ['linear', 'log']:
fig, ax = plt.subplots(figsize=(8, 6), constrained_layout=True)
for name in prog_languages:
df = dfs[name]
g = df.groupby(by=[df.index.year, df.index.month]).count()
group_dates = np.array([datetime.date(x[0], x[1], 1) for x in g.index])
mentions = g['pubdate.1'].values
if name == 'julia':
jmask = group_dates > datetime.date(2012, 1, 1)
group_dates = group_dates[jmask]
mentions = mentions[jmask]
ax.plot(group_dates,
mentions,
marker='', drawstyle='steps-mid',
lw=1, label=name)
ax.set_xlim(datetime.date(1991, 8, 1),
datetime.datetime.now() - datetime.timedelta(days=60))
ax.legend(loc='upper left', fontsize=16)
ax.set_xlabel('time')
ax.set_ylabel('Fulltext mentions per month')
ax.set_yscale(yscale)
fig.text(1, 0, 'Source: NASA/ADS', fontsize=16, ha='right')
fig.savefig(f'../plots/prog-lang-fulltext-{yscale}-monthly.png', dpi=300)
for yscale in ['linear', 'log']:
fig, ax = plt.subplots(figsize=(8, 6), constrained_layout=True)
bins = np.arange(1980, datetime.datetime.now().year+1, 1) + 0.5
for name in ['astropy', 'iraf']:
df = dfs[name]
years = 0.5 * (bins[:-1] + bins[1:])
H, _ = np.histogram(df.index.year, bins=bins)
ax.plot(years, H,
marker='', drawstyle='steps-mid',
lw=2, label=name)
ax.set_xlim(years.min(), years.max())
ax.legend(loc='upper left', fontsize=16)
ax.set_xlabel('time')
ax.set_ylabel('Fulltext mentions per year')
ax.set_yscale(yscale)
fig.text(1, 0, 'Source: NASA/ADS', fontsize=16, ha='right')
fig.savefig(f'../plots/astropy-iraf-fulltext-{yscale}-yearly.png', dpi=300)