In [1]:
%erp5_url http://10.0.87.104:2150/erp5/Base_executeJupyter
Your erp5_url is http://10.0.87.104:2150/erp5/Base_executeJupyter. 
Please enter reference in next cell. 
In [2]:
%notebook_set_reference wendelin_test_ayush_001
Your notebook_set_reference is wendelin_test_ayush_001. 
Please enter user in next cell. 
In [3]:
%erp5_user zope
Your erp5_user is zope. 
Please enter password in next cell. 
In [4]:
%erp5_password insecure
Your erp5_password is insecure. 
Please proceed
In [5]:
import numpy as np
from matplotlib import pyplot as plt

In [6]:
plt, np
(<module 'matplotlib.pyplot' from '/opt/slapgrid/7fa667833bc0716c6bb7dd8876c55d52/develop-eggs/matplotlib-1.4.3-py2.7-linux-x86_64.egg/matplotlib/pyplot.pyc'>, <module 'numpy' from '/opt/slapgrid/7fa667833bc0716c6bb7dd8876c55d52/develop-eggs/numpy-1.9.2-py2.7-linux-x86_64.egg/numpy/__init__.pyc'>)
In [7]:
t = np.arange(0., 5., 0.2)
t
array([ 0. ,  0.2,  0.4,  0.6,  0.8,  1. ,  1.2,  1.4,  1.6,  1.8,  2. ,
        2.2,  2.4,  2.6,  2.8,  3. ,  3.2,  3.4,  3.6,  3.8,  4. ,  4.2,
        4.4,  4.6,  4.8])
In [9]:
plt.clf()

In [10]:
plt.ylabel('some numbers')
context.Base_displayImage(image_object=plt)
In [11]:
plt.plot(t, t, 'r--', t, t**5, 'bs', t, t**3, 'g^')
context.Base_saveImage(plot=plt, reference='testplot1')
context.Base_displayImage(image_object=plt)
In [12]:
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)

In [13]:
N = 100
data = np.random.random((N, 7))
x = data[:,0]
y = data[:,1]
points = data[:,2:4]
# color is the length of each vector in `points`
color = np.sqrt((points**2).sum(axis = 1))/np.sqrt(2.0)
rgb = plt.get_cmap('jet')(color)

In [14]:
ax.scatter(x, y, color = rgb)
<matplotlib.collections.PathCollection object at 0x7f67446da710>
In [15]:
context.Base_displayImage(image_object=plt)

Now, we'll play with erp5 context objects

In [16]:
portal = context.getPortalObject()

In [17]:
portal
<ERP5Site at /erp5>
In [18]:
image_list = portal.portal_catalog(portal_type='Image', reference='louvre')
image = image_list[0]

In [19]:
print dir(image_list)
['__allow_access_to_unprotected_subobjects__', '__doc__', '__getitem__', '__init__', '__items__', '__len__', '__module__', '_class', '_data', '_data_dictionary', '_index', '_names', '_nv', '_parent', '_row', '_schema', '_searchable_result_columns', 'asRDB', 'data_dictionary', 'dictionaries', 'names', 'tuples']
In [14]:
%my_notebooks
[{'reference': 'erp5_objects_zbigarray', 'title': 'erp5_objects_zbigarray'}, {'reference': 'erp5_objects_zbigarray2', 'title': 'erp5_objects_zbigarray2'}, {'reference': 'foo', 'title': 'foo'}, {'reference': 'wendelin_test_ayush', 'title': 'wendelin_test_ayush'}]
In [20]:
image_list.tuples()
[('/erp5/image_module/1', 1131528L)]
In [21]:
dir(image)
['PATH', 'UID', '__ac_permissions__', '__add__', '__allow_access_to_unprotected_subobjects__', '__class__', '__cmp__', '__delattr__', '__delitem__', '__delslice__', '__dict__', '__doc__', '__format__', '__getattribute__', '__getitem__', '__getslice__', '__getstate__', '__hash__', '__implemented__', '__init__', '__len__', '__module__', '__mul__', '__new__', '__of__', '__providedBy__', '__provides__', '__record_schema__', '__reduce__', '__reduce_ex__', '__repr__', '__rmul__', '__roles__', '__setattr__', '__setitem__', '__setslice__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_aq_dynamic', 'absolute_url', 'activate', 'getObject', 'getPath', 'getProperty', 'getRID', 'getURL', 'getUid', 'getUrl', 'resolve_url', 'security']
In [22]:
print image.getURL()
/erp5/image_module/1

Now play with pandas and ZBigArray objects from Wendelin

In [23]:
data_array = portal.data_array_module.newContent(portal_type = 'Data Array')
data_array.initArray((3, 3), np.uint8)

In [24]:
persistent_data_array = data_array.getArray()

In [25]:
dir(persistent_data_array)
['__array__', '__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__getitem__', '__getstate__', '__hash__', '__init__', '__len__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__setstate__', '__sizeof__', '__slotnames__', '__slots__', '__str__', '__subclasshook__', '__weakref__', '_dtype', '_fileh', '_init0', '_p_activate', '_p_changed', '_p_deactivate', '_p_delattr', '_p_estimated_size', '_p_getattr', '_p_invalidate', '_p_jar', '_p_mtime', '_p_oid', '_p_serial', '_p_setattr', '_p_state', '_shape', '_stridev', '_v_fileh', 'append', 'data', 'dtype', 'itemsize', 'nbytes', 'ndim', 'resize', 'shape', 'size', 'strides', 'view', 'zfile']
In [26]:
import pandas as pd

In [27]:
df = pd.DataFrame(persistent_data_array[:])

In [38]:
df
   0  1  2
0  0  0  0
1  0  0  0
2  0  0  0
In [39]:
df.plot(title='New Array')
<matplotlib.axes._subplots.AxesSubplot object at 0x7f6742117250>
In [30]:
pdplot
<matplotlib.axes._subplots.AxesSubplot object at 0x7f67426362d0>
In [40]:
context.Base_displayImage(image_object=plt)
In [ ]: