Skip to content

Commit

Permalink
Added first draft of hosted tutorial.
Browse files Browse the repository at this point in the history
  • Loading branch information
bicarlsen committed Oct 27, 2020
1 parent 1b70008 commit b4aad68
Show file tree
Hide file tree
Showing 19 changed files with 339 additions and 21 deletions.
9 changes: 9 additions & 0 deletions build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Building the Documentation

From the root folder, run ``make html``.

Open `index.html` locally.

## Publishing

Push to GitHub.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# import packages
import pandas as pd
from thot.thot import ThotProject

# initialize thot project
thot = ThotProject()

# get noise data from asset
noise_data = thot.find_asset( { 'type': 'noise-data' } )

# import noise data into a pandas data frame
df = pd.read_csv( noise_data.file, header = 0, index_col = 0, names = ( 'trial', 'volume' ) )

# compute statistics
stats = df.describe()

# create a new asset for the statistics
stats_properties = {
'name': 'Noise Statistics',
'type': 'noise-stats',
'file': 'noise-stats.csv'
}

stats_path = thot.add_asset( stats_properties, 'noise_stats' )

# export the statistics to the new asset
stats.to_csv( stats_path )
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import pandas as pd
from thot.thot import ThotProject

# intialize thot
thot = ThotProject()

# prepare data
recipe_stats = thot.find_assets( { 'type': 'recipe-stats' } )

df = []
for stat in recipe_stats:
# read data for each recipe
tdf = pd.read_pickle( stat.file )
tdf.rename( { 0: stat.metadata[ 'recipe' ] }, axis = 1, inplace = True )

df.append( tdf )

# combine into one dataframe
df = pd.concat( df, axis = 1 )

# export data as csv for reading
comparison_properites = {
'name': 'Recipe Comparison',
'type': 'recipe-comparison',
'file': 'recipe_comparison.csv'
}

comparison_path = thot.add_asset( comparison_properites, 'recipe_comparison' )
df.to_csv( comparison_path )

# create bar char and export
means = df.loc[ 'mean' ]
errs = df.loc[ 'std' ]

ax = means.plot( kind = 'bar', yerr = errs )

bar_properties = {
'name': 'Recipe Comparison',
'type': 'recipe-bar-chart',
'tags': [ 'chart', 'image' ],
'file': 'recipe_comparison.png'
}

bar_path = thot.add_asset( bar_properties, 'recipe_bar' )
ax.get_figure().savefig( bar_path, format = 'png' )
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# include packages
import pandas as pd
from thot.thot import ThotProject

# initialize thot
thot = ThotProject()

# get recipe container
recipe = thot.find_container( { '_id': thot.root } )

# get noise statistics data
noise_stats = thot.find_assets( { 'type': 'noise-stats' } )

# create combined dataframe
df = []
for stat in noise_stats:
# read data for each batch
tdf = pd.read_csv(
stat.file,
names = ( stat.metadata[ 'batch' ], ),
index_col = 0,
header = 0
)

df.append( tdf )

df = pd.concat( df, axis = 1 )

# compute recipe statistics
mean = df.loc[ 'mean' ].mean()
std = df.loc[ 'std' ].pow( 2 ).sum()/ 4

stats = pd.DataFrame( [ mean, std ], index = ( 'mean', 'std' ) )

# export recipe statistics
stat_properties = {
'name': '{} Statistics'.format( recipe.name ),
'type': 'recipe-stats',
'file': 'recipe-stats.pkl'
}

stats_path = thot.add_asset( stat_properties, 'recipe_stats' )
stats.to_pickle( stats_path )
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Trial,Volume [dB]
1,125
2,130
3,127
4,133
5,124
6,131
7,125
8,128
9,125
10,126
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Trial,Volume [dB]
1,122
2,127
3,124
4,121
5,126
6,125
7,122
8,124
9,123
10,122
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Trial,Volume [dB]
1,90
2,95
3,96
4,97
5,92
6,93
7,98
8,101
9,95
10,96
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Trial,Volume [dB]
1,92
2,93
3,97
4,90
5,94
6,95
7,92
8,94
9,95
10,93
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
noise_data = thot.find_asset( { 'type': 'noise-data' } )

# import noise data into a pandas data frame
df = pd.read_csv( noise_data.file, header = 0, index_col = 0, names = ( 'trial', 'volume' ) )
df = pd.read_csv( noise_data.file, header = 0, index_col = 0, names = [ 'trial', 'volume' ] )

# compute statistics
stats = df.describe()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
" # read data for each batch\n",
" tdf = pd.read_csv( \n",
" stat.file, \n",
" names = ( stat.metadata[ 'batch' ] ), \n",
" names = [ stat.metadata[ 'batch' ] ], \n",
" index_col = 0, \n",
" header = 0 \n",
" )\n",
Expand Down Expand Up @@ -176,7 +176,7 @@
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7fd397151be0>"
"<matplotlib.axes._subplots.AxesSubplot at 0x7f7d7d995e10>"
]
},
"execution_count": 6,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
noise_data = thot.find_asset( { 'type': 'noise-data' } )

# import noise data into a pandas data frame
df = pd.read_csv( noise_data.file, header = 0, index_col = 0, names = ( 'trial', 'volume' ) )
df = pd.read_csv( noise_data.file, header = 0, index_col = 0, names = [ 'trial', 'volume' ] )

# compute statistics
stats = df.describe()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# read data for each batch
tdf = pd.read_csv(
stat.file,
names = ( stat.metadata[ 'batch' ] ),
names = [ stat.metadata[ 'batch' ] ],
index_col = 0,
header = 0
)
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
" # read data for each batch\n",
" tdf = pd.read_csv( \n",
" stat.file, \n",
" names = ( stat.metadata[ 'batch' ] ), \n",
" names = [ stat.metadata[ 'batch' ] ], \n",
" index_col = 0, \n",
" header = 0 \n",
" )\n",
Expand Down
12 changes: 10 additions & 2 deletions source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
author = 'Brian Carlsen'

# The short X.Y version
version = ''
version = '0.2'
# The full version, including alpha/beta/rc tags
release = '0.1.0'
release = '0.2.0'


# -- General configuration ---------------------------------------------------
Expand All @@ -43,6 +43,8 @@
'sphinx.ext.autosectionlabel',
'sphinx.ext.mathjax',
'recommonmark',
'sphinx_fontawesome',
'sphinx-bootstrap'
]

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -91,6 +93,12 @@
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_css_files = [
'https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css',
'styles.css'
]

html_js_files = []

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
Expand Down

0 comments on commit b4aad68

Please sign in to comment.