In [103]:
from glob import glob
import pandas as pd
from pandas.parser import CParserError # in order to be able to catch this error
import matplotlib.pyplot as plt
import numpy as np
% matplotlib inline

FoG


In [104]:
files = glob('C:\\Users\\jlandman\\Desktop\FoGs\\*\\*\\*D-*')
files.sort(key=lambda x: int(x.split('\\')[-1].split('-')[2]))

yearlist_fog = []
for i in files:
    yearlist_fog.append(int(i.split('\\')[-1].split('-')[2]))

In [105]:
nlist_fog = []
for f in files:
    try:
        data = pd.read_csv(f, sep=';', encoding='latin-1')
    except CParserError:
        data = pd.read_csv(f, encoding='latin-1')
    
    n = len(~pd.isnull(data['THICKNESS_CHG'].values))
    nlist_fog.append(n)

In [106]:
nlist_fog.pop(1)
yearlist_fog.pop(1)
nlist_fog.pop(0)
yearlist_fog.pop(0)

# add the not yet existent FoG numbers
nlist_fog.extend([6984, 7922])
yearlist_fog.extend([2016, 2017])
yerr = np.array([0.0, 0.0, 0.0, 0.0, 1000.])
nlist_fog = np.array(nlist_fog)
yearlist_fog = np.array(yearlist_fog)

In [107]:
yearlist_fog.shape


Out[107]:
(5,)

In [108]:
nlist_fog


Out[108]:
array([5014, 5229, 5597, 6984, 7922])

In [109]:
yerr


Out[109]:
array([    0.,     0.,     0.,     0.,  1000.])

GlaThiDa


In [110]:
nlist_gtd = [np.nan,1493,np.nan, 1591, np.nan]
yearlist_gtd = [2013, 2014, 2015, 2016, 2017]

In [158]:
fig, ax1 = plt.subplots(1,1,figsize=(4.5,5.))

ax1.plot(nlist_fog)
#ax1.fill_between(range(len(yearlist_fog)), nlist_fog, nlist_fog+yerr,facecolor='r',alpha=0.5)
#ax1.fill_between(range(len(yearlist_fog)), nlist_fog+yerr, nlist_fog+1.75*yerr,facecolor='b',alpha=0.5)
ax1.fill_between(range(len(yearlist_fog)), nlist_fog, nlist_fog+2.5*yerr,facecolor='g',alpha=0.5)
ax1.set_ylim((0,11000))
ax1.set_ylabel('Data entries', size=16)
ax1.tick_params(labelsize=16)
ax1.grid(axis='both')
ax1.text(1.9, 8700, '2017:\n7922+x', fontsize=20)
ax1.text(3.5, 8700, '?', fontsize=36)

ax1.set_xticks(range(len(yearlist_fog)))
ax1.set_xticklabels(range(min(yearlist_fog), max(yearlist_fog)+1), size=16)

ax1.set_xlabel('Year of Issue', size=16)
plt.title('$\Delta$ Thickness in FoG Database', size=16)

plt.tight_layout()
plt.savefig('C:\\users\\jlandman\\Desktop\\Thickn_chg_fog.png', format='png', dpi=500)
plt.show()



In [ ]:


In [ ]: