In [1]:
import pandas as pd
import numpy as np

In [3]:
df=pd.read_hdf('./data/tables_of_fgm.h5')
df.columns


Out[3]:
Index(['zeta', 'f', 'pv', 'C2H3', 'C2H6', 'CH2', 'H2CN', 'C2H4', 'H2O2', 'C2H',
       'CN', 'heatRelease', 'NCO', 'NNH', 'N2', 'AR', 'psi', 'CO', 'CH4',
       'HNCO', 'CH2OH', 'HCCO', 'CH2CO', 'CH', 'mu', 'C2H2', 'C2H5', 'H2', 'T',
       'PVs', 'O', 'O2', 'N2O', 'C', 'C3H7', 'CH2(S)', 'NH3', 'HO2', 'NO',
       'HCO', 'NO2', 'OH', 'HCNO', 'CH3CHO', 'CH3', 'NH', 'alpha', 'CH3O',
       'CO2', 'CH3OH', 'CH2CHO', 'CH2O', 'C3H8', 'HNO', 'NH2', 'HCN', 'H', 'N',
       'H2O', 'HCCOH', 'HCNN'],
      dtype='object')

In [4]:
# Plotly
import plotly.offline as pyoff
import plotly.plotly as py
import plotly.tools as tls

In [5]:
# df_s=df.sample(frac=0.02)
df_s=df.loc[df['zeta']==list(set(df['zeta']))[0]].sample(frac=0.1)
sp='alpha'
fig_db = {
    'data': [
         {'x': df_s['f'],
         'y': df_s['pv'],
         'z': df_s[sp],
         'type':'scatter3d', 
        'mode': 'markers',
          'marker':{
              'size':1
          }
         }
        
    ],
    'layout': {
        'scene':{
            'xaxis':{'title':'mixture fraction'},
            'yaxis': {'title': "progress variable"},
            'zaxis': {'title': sp}
                 }
    }
}
pyoff.iplot(fig_db, filename='multiple-scatter')



In [5]:
df_test=pd.read_hdf('sim_check.h5',key='test')
df_pred=pd.read_hdf('sim_check.h5',key='pred')

In [6]:
zeta_level=list(set(df_test['zeta']))
zeta_level.sort()

In [9]:
df_p.head()


Out[9]:
f pv zeta PVs
24487 0.692 0.552 0.11 1.285041
13867 0.256 0.076 0.11 -1.226739
18606 0.118 0.310 0.11 17.413414
2621 0.476 0.836 0.11 7.149955
21759 0.104 0.524 0.11 613.600769

In [8]:
df_t=df_test.loc[df_test['zeta']==zeta_level[1]].sample(frac=0.5)
# df_p=df_pred.loc[df_pred['zeta']==zeta_level[1]].sample(frac=0.1)
df_p=df_pred.loc[df_t.index]
sp='H'
error=df_p[sp]-df_t[sp]
fig_db = {
    'data': [
        
        {'name':'test',
        'x': df_t['f'],
         'y': df_t['pv'],
         'z': df_t[sp],
         'type':'scatter3d', 
        'mode': 'markers',
          'marker':{
              'size':1
          }
        },
        {'name':'predict',
            'x': df_p['f'],
         'y': df_p['pv'],
         'z': df_p[sp],
         'type':'scatter3d', 
        'mode': 'markers',
          'marker':{
              'size':1
          },
        },
        {'name':'error',
            'x': df_p['f'],
         'y': df_p['pv'],
         'z': error,
         'type':'scatter3d', 
        'mode': 'markers',
          'marker':{
              'size':1
          },
         }       
    ],
    'layout': {
        'scene':{
            'xaxis':{'title':'mixture fraction'},
            'yaxis': {'title': "progress variable"},
            'zaxis': {'title': sp}
                 }
    }
}
pyoff.iplot(fig_db, filename='multiple-scatter')


---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~/anaconda3/envs/my_dev/lib/python3.6/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
   3077             try:
-> 3078                 return self._engine.get_loc(key)
   3079             except KeyError:

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'H'

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
<ipython-input-8-cc8ffae1b68b> in <module>
      3 df_p=df_pred.loc[df_t.index]
      4 sp='H'
----> 5 error=df_p[sp]-df_t[sp]
      6 fig_db = {
      7     'data': [

~/anaconda3/envs/my_dev/lib/python3.6/site-packages/pandas/core/frame.py in __getitem__(self, key)
   2686             return self._getitem_multilevel(key)
   2687         else:
-> 2688             return self._getitem_column(key)
   2689 
   2690     def _getitem_column(self, key):

~/anaconda3/envs/my_dev/lib/python3.6/site-packages/pandas/core/frame.py in _getitem_column(self, key)
   2693         # get column
   2694         if self.columns.is_unique:
-> 2695             return self._get_item_cache(key)
   2696 
   2697         # duplicate columns & possible reduce dimensionality

~/anaconda3/envs/my_dev/lib/python3.6/site-packages/pandas/core/generic.py in _get_item_cache(self, item)
   2487         res = cache.get(item)
   2488         if res is None:
-> 2489             values = self._data.get(item)
   2490             res = self._box_item_values(item, values)
   2491             cache[item] = res

~/anaconda3/envs/my_dev/lib/python3.6/site-packages/pandas/core/internals.py in get(self, item, fastpath)
   4113 
   4114             if not isna(item):
-> 4115                 loc = self.items.get_loc(item)
   4116             else:
   4117                 indexer = np.arange(len(self.items))[isna(self.items)]

~/anaconda3/envs/my_dev/lib/python3.6/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
   3078                 return self._engine.get_loc(key)
   3079             except KeyError:
-> 3080                 return self._engine.get_loc(self._maybe_cast_indexer(key))
   3081 
   3082         indexer = self.get_indexer([key], method=method, tolerance=tolerance)

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'H'

In [9]:
import matplotlib.pyplot as plt

In [58]:
plt.scatter(df_pred[sp],df_test[sp])


Out[58]:
<matplotlib.collections.PathCollection at 0x7fdbdbfab630>

In [59]:
from scipy.interpolate import griddata
df_new=df_t
x=df_new['f']
y=df_new['pv']
z=df_new[sp]
resX=200
resY=200
xi = np.linspace(min(x), max(x), resX)
yi = np.linspace(min(y), max(y), resY)
grid_x,grid_y = np.meshgrid(xi,yi)

Z = griddata(df_new[['f','pv']],df_new[sp], (grid_x, grid_y), method='linear')

In [60]:
import plotly.graph_objs as go
data=[
    go.Contour(
    z=np.nan_to_num(Z),
    x=xi,
    y=yi    
    )
]
pyoff.iplot(data)



In [61]:
df_new=df_p
x=df_new['f']
y=df_new['pv']
z=df_new[sp]
resX=200
resY=200
xi = np.linspace(min(x), max(x), resX)
yi = np.linspace(min(y), max(y), resY)
grid_x,grid_y = np.meshgrid(xi,yi)

Z = griddata(df_new[['f','pv']],df_new[sp], (grid_x, grid_y), method='linear')
import plotly.graph_objs as go
data=[
    go.Contour(
    z=np.nan_to_num(Z),
    x=xi,
    y=yi    
    )
]
pyoff.iplot(data)



In [ ]: