Reading the output from simplelinear2dtex_1d_dd.cu

We go from a flattened std::vector (C++, representing 2-dimensional data) to a .csv file.


In [1]:
%matplotlib inline

In [16]:
import matplotlib.pyplot as plt
import csv
import numpy as np

In [3]:
ld = [ 1., 1.]
WIDTH  = 16
HEIGHT = 8
print WIDTH*HEIGHT
hd = [ld[0]/(float(WIDTH)), ld[1]/(float(HEIGHT)) ]


128

In [44]:
# list the csv files we can import
import os
[filename for filename in os.listdir('./') if filename.find('.csv') >= 0 ]


Out[44]:
['ddsinsin2dtex_result.csv',
 'simplelinear2dtex_dx_result.csv',
 'sinsin2dtex_result.csv',
 'simplelinear2dtex_dy_result.csv',
 'simplelinear2dtex_result.csv',
 'simplelinear2dtex_ogref.csv',
 'sinsin2dtex_ogref.csv',
 'simplelinear2dtex_add_l_result.csv',
 'simplelinear2dtex_d_result.csv']

In [45]:
with open('simplelinear2dtex_result.csv','r') as csvfile_result:
    plot_results = csv.reader(csvfile_result, delimiter=',')
    result_list = list(  list(rec) for rec in plot_results ) 
    
with open('simplelinear2dtex_ogref.csv','r') as csvfile_ogref:
    plot_ogref = csv.reader(csvfile_ogref, delimiter=',')
    ogref_list = list(  list(rec) for rec in plot_ogref ) 
    
with open('simplelinear2dtex_d_result.csv','r') as csvfile_d:
    plot_d = csv.reader(csvfile_d, delimiter=',')
    d_list = list(  list(rec) for rec in plot_d ) 

with open('simplelinear2dtex_add_l_result.csv','r') as csvfile_addl:
    plot_addl = csv.reader(csvfile_addl, delimiter=',')
    addl_list = list(  list(rec) for rec in plot_addl )     

with open('simplelinear2dtex_dx_result.csv','r') as csvfile_dx:
    plot_dx = csv.reader(csvfile_dx, delimiter=',')
    dx_list = list(  list(rec) for rec in plot_dx )     

with open('simplelinear2dtex_dy_result.csv','r') as csvfile_dy:
    plot_dy = csv.reader(csvfile_dy, delimiter=',')
    dy_list = list(  list(rec) for rec in plot_dy )

In [46]:
csvfile_result.close()
csvfile_ogref.close()
csvfile_d.close()
csvfile_addl.close()
csvfile_dx.close()
csvfile_dy.close()

In [47]:
# convert the strings in the list of lists into floats
result_list = [[float(ele) for ele in row] for row in result_list]
ogref_list = [[float(ele) for ele in row] for row in ogref_list]
d_list = [[float(ele) for ele in row] for row in d_list]
addl_list = [[float(ele) for ele in row] for row in addl_list]
dx_list = [[float(ele) for ele in row] for row in dx_list]
dy_list = [[float(ele) for ele in row] for row in dy_list]

In [48]:
# convert the list of lists of floats into numpy arrays
result_list = np.array( result_list)
ogref_list = np.array( ogref_list)
d_list = np.array( d_list)
addl_list = np.array( addl_list )
dx_list = np.array( dx_list )
dy_list = np.array( dy_list )

In [20]:
result_list - ogref_list


Out[20]:
array([[ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
         0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
         0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
         0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
         0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
         0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
         0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
         0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
         0.,  0.,  0.]])

In [42]:
print result_list.shape; print ogref_list.shape; print d_list.shape; 
print addl_list.shape; print dx_list.shape


(8, 16)
(8, 16)
(8, 16)
(8, 16)
(8, 16)

In [35]:
# np.array_str from 
# cf. http://stackoverflow.com/questions/2891790/pretty-printing-of-numpy-array
print np.array_str(result_list, precision=3, suppress_small=True)


[[   0.1    1.1    2.1    3.1    4.1    5.1    6.1    7.1    8.1    9.1
    10.1   11.1   12.1   13.1   14.1   15.1]
 [  16.1   17.1   18.1   19.1   20.1   21.1   22.1   23.1   24.1   25.1
    26.1   27.1   28.1   29.1   30.1   31.1]
 [  32.1   33.1   34.1   35.1   36.1   37.1   38.1   39.1   40.1   41.1
    42.1   43.1   44.1   45.1   46.1   47.1]
 [  48.1   49.1   50.1   51.1   52.1   53.1   54.1   55.1   56.1   57.1
    58.1   59.1   60.1   61.1   62.1   63.1]
 [  64.1   65.1   66.1   67.1   68.1   69.1   70.1   71.1   72.1   73.1
    74.1   75.1   76.1   77.1   78.1   79.1]
 [  80.1   81.1   82.1   83.1   84.1   85.1   86.1   87.1   88.1   89.1
    90.1   91.1   92.1   93.1   94.1   95.1]
 [  96.1   97.1   98.1   99.1  100.1  101.1  102.1  103.1  104.1  105.1
   106.1  107.1  108.1  109.1  110.1  111.1]
 [ 112.1  113.1  114.1  115.1  116.1  117.1  118.1  119.1  120.1  121.1
   122.1  123.1  124.1  125.1  126.1  127.1]]

In [24]:
d_list


Out[24]:
array([[   0.6,    1.6,    2.6,    3.6,    4.6,    5.6,    6.6,    7.6,
           8.6,    9.6,   10.6,   11.6,   12.6,   13.6,   14.6,   15.1],
       [  16.6,   17.6,   18.6,   19.6,   20.6,   21.6,   22.6,   23.6,
          24.6,   25.6,   26.6,   27.6,   28.6,   29.6,   30.6,   31.1],
       [  32.6,   33.6,   34.6,   35.6,   36.6,   37.6,   38.6,   39.6,
          40.6,   41.6,   42.6,   43.6,   44.6,   45.6,   46.6,   47.1],
       [  48.6,   49.6,   50.6,   51.6,   52.6,   53.6,   54.6,   55.6,
          56.6,   57.6,   58.6,   59.6,   60.6,   61.6,   62.6,   63.1],
       [  64.6,   65.6,   66.6,   67.6,   68.6,   69.6,   70.6,   71.6,
          72.6,   73.6,   74.6,   75.6,   76.6,   77.6,   78.6,   79.1],
       [  80.6,   81.6,   82.6,   83.6,   84.6,   85.6,   86.6,   87.6,
          88.6,   89.6,   90.6,   91.6,   92.6,   93.6,   94.6,   95.1],
       [  96.6,   97.6,   98.6,   99.6,  100.6,  101.6,  102.6,  103.6,
         104.6,  105.6,  106.6,  107.6,  108.6,  109.6,  110.6,  111.1],
       [ 112.6,  113.6,  114.6,  115.6,  116.6,  117.6,  118.6,  119.6,
         120.6,  121.6,  122.6,  123.6,  124.6,  125.6,  126.6,  127.1]])

Take a look at the cudaTextureDesc::addressMode, whether it's cudaAddressModeWrap or cudaAddressModeClamp


In [34]:
print np.array_str( addl_list, precision=3, suppress_small=True )


[[    1.     6.    16.    26.    36.    46.    56.    66.    76.    86.
     96.   106.   116.   126.   136.   146.]
 [  161.   166.   176.   186.   196.   206.   216.   226.   236.   246.
    256.   266.   276.   286.   296.   306.]
 [  321.   326.   336.   346.   356.   366.   376.   386.   396.   406.
    416.   426.   436.   446.   456.   466.]
 [  481.   486.   496.   506.   516.   526.   536.   546.   556.   566.
    576.   586.   596.   606.   616.   626.]
 [  641.   646.   656.   666.   676.   686.   696.   706.   716.   726.
    736.   746.   756.   766.   776.   786.]
 [  801.   806.   816.   826.   836.   846.   856.   866.   876.   886.
    896.   906.   916.   926.   936.   946.]
 [  961.   966.   976.   986.   996.  1006.  1016.  1026.  1036.  1046.
   1056.  1066.  1076.  1086.  1096.  1106.]
 [ 1121.  1126.  1136.  1146.  1156.  1166.  1176.  1186.  1196.  1206.
   1216.  1226.  1236.  1246.  1256.  1266.]]

In [43]:
print np.array_str( dx_list, precision=3, suppress_small=True )


[[  8.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.
   16.   8.]
 [  8.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.
   16.   8.]
 [  8.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.
   16.   8.]
 [  8.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.
   16.   8.]
 [  8.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.
   16.   8.]
 [  8.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.
   16.   8.]
 [  8.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.
   16.   8.]
 [  8.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.  16.
   16.   8.]]

In [49]:
print np.array_str( dy_list, precision=3, suppress_small=True )


[[  64.   64.   64.   64.   64.   64.   64.   64.   64.   64.   64.   64.
    64.   64.   64.   64.]
 [ 128.  128.  128.  128.  128.  128.  128.  128.  128.  128.  128.  128.
   128.  128.  128.  128.]
 [ 128.  128.  128.  128.  128.  128.  128.  128.  128.  128.  128.  128.
   128.  128.  128.  128.]
 [ 128.  128.  128.  128.  128.  128.  128.  128.  128.  128.  128.  128.
   128.  128.  128.  128.]
 [ 128.  128.  128.  128.  128.  128.  128.  128.  128.  128.  128.  128.
   128.  128.  128.  128.]
 [ 128.  128.  128.  128.  128.  128.  128.  128.  128.  128.  128.  128.
   128.  128.  128.  128.]
 [ 128.  128.  128.  128.  128.  128.  128.  128.  128.  128.  128.  128.
   128.  128.  128.  128.]
 [  64.   64.   64.   64.   64.   64.   64.   64.   64.   64.   64.   64.
    64.   64.   64.   64.]]

In [ ]: