Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
| Download

📚 The CoCalc Library - books, templates and other resources

Views: 96141
License: OTHER
1
2
# coding: utf-8
3
4
# # Table of symbolic variables used in other worksheets
5
# Below, we import variables and their definitions and units from other worksheets and display them in a sorted table. We also generate latex code for inclusion in manuscript.
6
7
# In[1]:
8
9
get_ipython().run_cell_magic(u'capture', u'storage', u"# The above redirects all output of the below commands to the variable 'storage' instead of displaying it.\n# It can be viewed by typing: 'storage()'\n# Setting up worksheet and importing equations for explicit leaf energy balance\nload('temp/Worksheet_setup.sage')")
10
11
12
# In[2]:
13
14
# List all .ipynb files
15
list_files = os.listdir('.')
16
for fname in list_files:
17
if fname[-5:] == 'ipynb':
18
print fname
19
20
21
# In[3]:
22
23
# From leaf_enbalance_eqs, E_PM_eqs and stomatal_cond_eqs
24
25
load_session('temp/leaf_enbalance_eqs.sobj')
26
dict_vars1 = dict_vars.copy()
27
28
load_session('temp/stomatal_cond_eqs.sobj')
29
dict_vars1.update(dict_vars)
30
31
load_session('temp/E_PM_eqs.sobj')
32
dict_vars1.update(dict_vars)
33
34
dict_vars = dict_vars1.copy()
35
fun_loadvars(vardict=dict_vars) # re-loading variable definitions
36
udict = {}
37
for key1 in dict_vars.keys():
38
udict[key1] = dict_vars[key1]['units'] # exporting units information from dict_vars to udict, which will be used below.
39
40
41
# In[4]:
42
43
# Creating dictionary to substitute names of units with shorter forms
44
var('m s J Pa K kg mol')
45
subsdict = {meter: m, second: s, joule: J, pascal: Pa, kelvin: K, kilogram: kg, mole: mol}
46
var('N_Re_L N_Re_c N_Le N_Nu_L N_Gr_L N_Sh_L')
47
dict_varnew = {Re: N_Re_L, Re_c: N_Re_c, Le: N_Le, Nu: N_Nu_L, Gr: N_Gr_L, Sh: N_Sh_L}
48
dict_varold = {v: k for k, v in dict_varnew.iteritems()}
49
variables = sorted([str(variable.subs(dict_varnew)) for variable in udict.keys()],key=str.lower)
50
tableheader = [('Variable', 'Description (value)', 'Units')]
51
tabledata = [('Variable', 'Description (value)', 'Units')]
52
for variable1 in variables:
53
variable2 = eval(variable1).subs(dict_varold)
54
variable = str(variable2)
55
tabledata.append((eval(variable),docdict[eval(variable)],fun_units_formatted(variable)))
56
57
table(tabledata, header_row=True)
58
59
60
# In[5]:
61
62
latex(table(tabledata))
63
64
65
# In[ ]:
66
67
68
69
70