📚 The CoCalc Library - books, templates and other resources
License: OTHER
1# coding: utf-823# # Table of symbolic variables used in other worksheets4# 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.56# In[1]:78get_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')")91011# In[2]:1213# List all .ipynb files14list_files = os.listdir('.')15for fname in list_files:16if fname[-5:] == 'ipynb':17print fname181920# In[3]:2122# From leaf_enbalance_eqs, E_PM_eqs and stomatal_cond_eqs2324load_session('temp/leaf_enbalance_eqs.sobj')25dict_vars1 = dict_vars.copy()2627load_session('temp/stomatal_cond_eqs.sobj')28dict_vars1.update(dict_vars)2930load_session('temp/E_PM_eqs.sobj')31dict_vars1.update(dict_vars)3233dict_vars = dict_vars1.copy()34fun_loadvars(vardict=dict_vars) # re-loading variable definitions35udict = {}36for key1 in dict_vars.keys():37udict[key1] = dict_vars[key1]['units'] # exporting units information from dict_vars to udict, which will be used below.383940# In[4]:4142# Creating dictionary to substitute names of units with shorter forms43var('m s J Pa K kg mol')44subsdict = {meter: m, second: s, joule: J, pascal: Pa, kelvin: K, kilogram: kg, mole: mol}45var('N_Re_L N_Re_c N_Le N_Nu_L N_Gr_L N_Sh_L')46dict_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}47dict_varold = {v: k for k, v in dict_varnew.iteritems()}48variables = sorted([str(variable.subs(dict_varnew)) for variable in udict.keys()],key=str.lower)49tableheader = [('Variable', 'Description (value)', 'Units')]50tabledata = [('Variable', 'Description (value)', 'Units')]51for variable1 in variables:52variable2 = eval(variable1).subs(dict_varold)53variable = str(variable2)54tabledata.append((eval(variable),docdict[eval(variable)],fun_units_formatted(variable)))5556table(tabledata, header_row=True)575859# In[5]:6061latex(table(tabledata))626364# In[ ]:656667686970