import funkcje_do_lab1 as f
f.hide()
PURPOSE:
To get acquainted with the Canopy environment – declaring variables, arrays and array operations.
TASKS:
1. Create your directory on the hard drive, eg. ‘D:/Biomed2014_1’. All the scripts, functions and files are to be saved in this directory. 2. Start the Editor of Canopy 3. Change the current working directory of Canopy environment to the directory you created. (In the main command window, type >>cd D:/Biomed2014_1) 4. To double-check what is your current directory type >>pwd
EXPECTED RESULTS:
home = f.ad1()
5.In the Editor of Canopy, declare the following variables (hint: use http://wiki.scipy.org/Tentative_NumPy_Tutorial and go to ‘Array creation’)
f.fig(f.w1)
Check type of each of the defined matrices by entering variable_name.ndim, variable_name.shape, variable_name.size, variable_name.dtype, variable_name.itemsize. Type f=zeros_like(d) to create a new array f of the same size and data type as array d but filled with zeros. Create array b1 with the same size and values as for array b, but of dtype=’uint8’
EXPECTED RESULTS:
f.ad5()
6.Creating vectors:
Type in help(arange)
Type in the commands: g=arange(10); h=arange(10.), i=arange(5,15,3)
Create the following vectors:
f.fig(f.w2)
Hints: check Canopy help for the following functions:zeros, ones
(to print out the help content type >>help(function_name))
EXPECTED RESULTS:
f.ad6()
7.Type in %whos to see the defined variables in Canopy workspace, use %xdel command to delete some of the defined variables. Note that %reset command clears all the variables, imported modules and defined functions.
8.Create vectors by using the array() commands: r=[1 -2 4], s=[7 2 3] and compute: r+s, r*s, r**s, dot(r,s)
EXPECTED RESULTS:
f.ad8()
9.Add, multiply, divide by 2 and compute the power of 2 of vector r by using commands: r+=2, r*=2, r/=2, r**=2
EXPECTED RESULTS:
f.ad9()
10.Define array t:
f.fig(f.m)
and compute: t.min(), t.max(),: t.min(axis=0), t.min(axis=1), t.max(axis=0), t.max(axis=1).
Consult help prod, average, std, var, round, clip, ptp, floor, ceil, flipud, fliplr, rot90 and use these commands for array t.
EXPECTED RESULTS:
f.ad10()