In [1]:
file = '/Users/schriste/Dropbox/Developer/python/foxsi-optics-sim/src/foxsisim/data/Reflectivity_Nickel_1keV.txt'

In [3]:
res = np.loadtxt(file, skiprows = 2)

In [4]:
res.shape


Out[4]:
(501, 2)

In [6]:
res[1]


Out[6]:
array([ 0.02    ,  0.991481])

In [14]:
np.vstack([r, res[:,1], res[:,1]]).shape


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-14-b2b3250b1cf1> in <module>()
----> 1 np.vstack([r, res[:,1], res[:,1]]).shape

/Users/schriste/anaconda/lib/python2.7/site-packages/numpy/core/shape_base.pyc in vstack(tup)
    226 
    227     """
--> 228     return _nx.concatenate([atleast_2d(_m) for _m in tup], 0)
    229 
    230 def hstack(tup):

ValueError: all the input array dimensions except for the concatenation axis must match exactly

In [15]:
a = [1,2,3]

In [16]:
a[1:]


Out[16]:
[2, 3]

In [17]:
import numpy as np
import glob
import re

In [132]:
class Reflectivity:

    def __init__(self, material='Ni'):
        files = glob.glob("/Users/schriste/Dropbox/Developer/python/foxsi-optics-sim/src/foxsisim/data/*.txt")
        # todo: read the energies from the files
        data = np.loadtxt(files[0], skiprows = 2)
        angles = data[:,1]
        energy = int(re.findall(r"\D(\d{2})\D", files[0])[0])
        points = np.column_stack([np.ones(data.shape[0]) * energy, current_data[:,0]])
        values = current_data[:,1]
        energy = [1,5,10,15,20]
        
        for file in files[1:]:
            data = np.loadtxt(file, skiprows = 2)
            energy = int(re.findall(r"\D(\d{2})\D", files[0])[0])
            new_points = np.column_stack([np.ones(data.shape[0]) * energy, current_data[:,0]])
            points = np.vstack([points, new_points])
            values = np.vstack([values, current_data[:,1]])
        self.points = points
        self.values = values

In [133]:
r = Reflectivity()


---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
<ipython-input-133-77a16b5e14fa> in <module>()
----> 1 r = Reflectivity()

<ipython-input-132-baa6b0099ce6> in __init__(self, material)
      7         angles = data[:,1]
      8         energy = int(re.findall(r"\D(\d{2})\D", files[0])[0])
----> 9         points = np.column_stack([np.ones(data.shape[0]) * energy, current_data[:,0]])
     10         values = current_data[:,1]
     11         energy = [1,5,10,15,20]

UnboundLocalError: local variable 'current_data' referenced before assignment

In [58]:
files = glob.glob("/Users/schriste/Dropbox/Developer/python/foxsi-optics-sim/src/foxsisim/data/*.txt")
data = np.loadtxt(files[0], skiprows = 2)
data.shape


Out[58]:
(501, 2)

In [66]:
data = np.loadtxt(files[0], skiprows = 2)
data.shape


Out[66]:
(501, 2)

In [62]:
points = np.random.rand(1000, 2)

In [126]:
points = np.column_stack([np.ones(data.shape[0]) * 5, data[:,0]])

In [131]:
np.vstack([points, points]).shape


Out[131]:
(1002, 2)

In [81]:
import re

In [119]:
result = re.search('Reflectivity_(\d)keV.txt', files[0])

In [125]:
int(re.findall(r"\D(\d{2})\D", files[0])[0])


Out[125]:
10

In [91]:
files[0]


Out[91]:
'/Users/schriste/Dropbox/Developer/python/foxsi-optics-sim/src/foxsisim/data/Reflectivity_Nickel_10keV.txt'

In [ ]: