ildm plots


In [1]:
import pandas as pd

import and check data


In [9]:
df = pd.read_hdf('bigDataFrame.H5')
df.head()


Out[9]:
gridCO2 gridH2O gridZ T CH4 CH3 CH3O CH2O HCO CO2 ... sH2O sZ ix n1 n2 n3 n4 n5 n6 n7
0 1 1 1 2142.860000 0.0 1.000000e-30 1.000000e-30 1.000000e-30 1.000000e-30 0.0 ... 0.0 0.0 1 2 51 52 2501 2502 2551 2552
1 2 1 1 2142.860000 0.0 1.000000e-30 1.000000e-30 1.000000e-30 1.000000e-30 0.0 ... 0.0 0.0 2 3 52 53 2502 2503 2552 2553
2 3 1 1 2142.860000 0.0 1.000000e-30 1.000000e-30 1.000000e-30 1.000000e-30 0.0 ... 0.0 0.0 3 4 53 54 2503 2504 2553 2554
3 4 1 1 2142.860000 0.0 1.000000e-30 1.000000e-30 1.000000e-30 1.000000e-30 0.0 ... 0.0 0.0 4 5 54 55 2504 2505 2554 2555
4 5 1 1 2142.860000 0.0 1.000000e-30 1.000000e-30 1.000000e-30 1.000000e-30 0.0 ... 0.0 0.0 5 6 55 56 2505 2506 2555 2556

5 rows × 32 columns

plot the grid


In [4]:
import plotly.offline as pyoff
import plotly.plotly as pyol
import plotly.tools as tls

In [11]:
# df_s=df.loc[df['zeta']==list(set(df['zeta']))[0]].sample(frac=0.1)
df_s=df.sample(frac=0.1)
x='H2O'
y='CO2'
z='N2'
fig_db = {
    'data': [
         {'x': df_s[x],
         'y': df_s[y],
         'z': df_s[z],
         'type':'scatter3d', 
         'mode': 'markers',
         'marker':{
             'size':1
          }
         }
        
    ],
    'layout': {
        'scene':{
            'xaxis':{'title':x},
            'yaxis': {'title': y},
            'zaxis': {'title': z}
                 }
    }
}
pyoff.iplot(fig_db, filename='multiple-scatter')


cut a slice from the total data


In [63]:
z_level=list(set(df['gridZ']))[1]
df_slice=df.loc[df['gridZ']==z_level].sample(frac=1)
df_s=df.sample(frac=1)
x='CO2'
y='H2O'
z='H'
fig_db = {
    'data': [         
         {          
         'name':'all data',   
         'x': df_s[x],
         'y': df_s[y],
         'z': df_s[z],
         'type':'scatter3d', 
         'mode': 'markers',
         'marker':{
             'size':1
          }
         },
         {
         'name':'slice z ='+str(z_level),
         'x': df_slice[x],
         'y': df_slice[y],
         'z': df_slice[z],
         'type':'scatter3d', 
         'mode': 'markers',
         'marker':{
             'size':1
          }
         }
        
        
    ],
    'layout': {
        'scene':{
            'xaxis':{'title':x},
            'yaxis': {'title': y},
            'zaxis': {'title': z}
                 }
    }
}
pyoff.iplot(fig_db, filename='multiple-scatter')


surface plot for the cutted slice

select a slice from some value


In [57]:
df_slice=df_slice.sort_values(['gridCO2','gridH2O'])
surface_z=df_slice['H'].values.reshape(50,50)
df_slice.head()


Out[57]:
gridCO2 gridH2O gridZ T CH4 CH3 CH3O CH2O HCO CO2 ... sZ ix n1 n2 n3 n4 n5 n6 n7 sort
2500 1 1 2 2142.860000 1.550144e-03 1.000000e-30 1.000000e-30 1.000000e-30 1.000000e-30 0.000000e+00 ... 0.0 2501 2502 2551 2552 5001 5002 5051 5052 101
2550 1 2 2 1326.346033 -8.025760e-19 2.701179e-20 9.426614e-20 2.150804e-12 7.152138e-08 -4.034614e-18 ... 0.0 2551 2552 2601 2602 5051 5052 5101 5102 201
2600 1 3 2 1335.502797 3.121804e-18 2.477877e-19 8.930424e-20 2.024859e-12 7.053277e-08 0.000000e+00 ... 0.0 2601 2602 2651 2652 5101 5102 5151 5152 301
2650 1 4 2 1344.006992 9.009963e-19 1.407088e-19 8.661796e-20 1.913787e-12 6.960567e-08 1.019767e-16 ... 0.0 2651 2652 2701 2702 5151 5152 5201 5202 401
2700 1 5 2 1352.308657 8.378185e-19 1.085770e-19 7.616917e-20 1.813924e-12 6.869034e-08 0.000000e+00 ... 0.0 2701 2702 2751 2752 5201 5202 5251 5252 501

5 rows × 33 columns


In [59]:
import plotly.graph_objs as go
data = [
    go.Surface(
        z=surface_z,
        contours=go.surface.Contours(
            z=go.surface.contours.Z(
              show=True,
              usecolormap=True,
              highlightcolor="#42f462",
              project=dict(z=True)
            )
        )
    )
]
layout = go.Layout(
    title='surface plot',
    autosize=False,
    scene=dict(
        camera=dict(eye=dict(x=1.87, y=0.88, z=-0.64)),
        xaxis=dict(title='CO2'),
        yaxis=dict(title='H2O')
    ),
    width=500,
    height=500,
    margin=dict(
        l=65,
        r=50,
        b=65,
        t=90
    )
)
fig = go.Figure(data=data, layout=layout)
pyoff.iplot(fig, filename='elevations-3d-surface-contours')



In [ ]: