Commit e1840906 authored by Ruxandra Cojocaru's avatar Ruxandra Cojocaru

Changes to setup.py and requirements.txt

parent 960322ca
*.pyc
*.log
swarp/output/*
swarp/output/
......@@ -6,7 +6,11 @@ Speckle Wavefront Reconstruction Package. Based on X-ray Speckle Tracking (XST)
git clone https://gitlab.esrf.fr/cojocaru/swarp
sudo python setup.py install
cd swarp
pip install .
Alternative: sudo python setup.py install
## How to run the code (for now)
......
......@@ -34,8 +34,10 @@ import sys
try:
from setuptools import setup
print('imported setuptools setup')
except ImportError:
from distutils.core import setup
print('imported distutils.core setup')
def get_readme():
......@@ -47,16 +49,23 @@ def get_readme():
long_description += line
return long_description
#~ def install_requires():
#~ with open('requirements.txt') as fp:
#~ install_requires = fp.readlines()
#~ return install_requires
def get_version():
from swarp import version
return version.strictversion
def install_requires():
def get_requirements():
requirements = list()
with open('requirements.txt') as fp:
install_requires = fp.readlines()
return install_requires
for line in fp:
if line.startswith('#') or line == '\n':
continue
line = line.strip('\n')
requirements.append(line)
print(requirements)
return requirements
def main():
......@@ -68,16 +77,16 @@ def main():
kwargs = dict(
name='swarp',
version=get_version(),
version='1.0.0',
description='x-ray Speckle tracking WAveFront Reconstruction Package',
long_description=read('README.md'),
long_description=open('README.md').read(),
license='MIT',
author='Ruxandra Cojocaru, Sebastien Berujon',
author_email='cojocaru@esrf.fr, sebastien.berujon@esrf.fr',
url='https://gitlab.esrf.fr/cojocaru/swarp',
download_url='https://gitlab.esrf.fr/cojocaru/swarp',
keywords='wavefront, speckle, x-ray, synchrotron',
install_requires=install_requires(),
install_requires=get_requirements(),
platforms=[
'MacOS :: MacOS X',
'Microsoft :: Windows',
......@@ -120,10 +129,10 @@ def main():
# The most straight forward workaround is to have a .bat script to run
# swarp on Windows.
if 'win32' in sys.platform:
kwargs['scripts'] = ['scripts/swarp.bat']
else:
kwargs['scripts'] = ['scripts/swarp']
#~ if 'win32' in sys.platform:
#~ kwargs['scripts'] = ['swarp/swarp.bat']
#~ else:
#~ kwargs['scripts'] = ['swarp/']
setup(**kwargs)
......
This diff is collapsed.
......@@ -94,10 +94,38 @@ def main():
maxBytes=(1048576*5), backupCount=7)
fh.setFormatter(format)
log.addHandler(fh)
if(param['subdir_data']):
if(param['prefix_files'] is None):
prefix = param['prefix_files'] + '_'
else:
prefix = ''
file_h1 = os.path.join(param['dir_out'], param['subdir_data'],
prefix + 'sd_hv.dat')
file_h2 = os.path.join(param['dir_out'], param['subdir_data'],
prefix + 'sd_hh.dat')
file_h3 = os.path.join(param['dir_out'], param['subdir_data'],
prefix + 'pix_size_h.dat')
file_h4 = os.path.join(param['dir_out'], param['subdir_data'],
prefix + 'horz-ss_v.dat')
file_h5 = os.path.join(param['dir_out'], param['subdir_data'],
prefix + 'horz-ss_h.dat')
file_h6 = os.path.join(param['dir_out'], param['subdir_data'],
prefix + 'disto_h.dat')
# Save data and/or plots?
save_data = True
save_plots = True
file_v1 = os.path.join(param['dir_out'], param['subdir_data'],
prefix + 'sd_vv.dat')
file_v2 = os.path.join(param['dir_out'], param['subdir_data'],
prefix + 'sd_vh.dat')
file_v3 = os.path.join(param['dir_out'], param['subdir_data'],
prefix + 'pix_size_v.dat')
file_v4 = os.path.join(param['dir_out'], param['subdir_data'],
prefix + 'vert-ss_v.dat')
file_v5 = os.path.join(param['dir_out'], param['subdir_data'],
prefix + 'vert-ss_h.dat')
file_v6 = os.path.join(param['dir_out'], param['subdir_data'],
prefix + 'disto_v.dat')
# Open files for dark and flat field images
# Use EdfFile library to extract header and image data
......@@ -135,9 +163,11 @@ def main():
# Select only file in directory that start with prefix (if given)
if(param['prefix_files']):
file_list = filter(lambda x: x.startswith(
param['prefix_files']),
file_list)
file_list = [x for x in file_list
if x.startswith(param['prefix_files'])]
#~ file_list = filter(lambda x: x.startswith(
#~ param['prefix_files']),
#~ file_list)
logging.info(str(len(file_list)) + ' files')
......@@ -313,28 +343,19 @@ def main():
# Vertical pixel size corrected for misalignment
pix_size_h_corr = np.sqrt(pix_size_h**2.0 + vert_pix_drift**2.0)
if(save_data):
file_h1 = os.path.join(param['dir_out'], param['subdir_data'],
param['prefix_files'] + '_sd_hv.dat')
if(param['subdir_data']):
np.savetxt(file_h1, sd_hv, fmt = '%.18e', delimiter = '\t',
newline = '\n')
file_h2 = os.path.join(param['dir_out'], param['subdir_data'],
param['prefix_files'] + '_sd_hh.dat')
np.savetxt(file_h2, sd_hh, fmt = '%.18e', delimiter = '\t',
newline = '\n')
file_h3 = os.path.join(param['dir_out'], param['subdir_data'],
param['prefix_files'] + '_pix_size_h.dat')
# Uncorrected Pixel Size, Corrected Pixel Size, Misalignment
# Angle in Degrees
np.savetxt(file_h3, np.array([pix_size_h,
pix_size_h_corr, math.degrees(math.acos(
pix_size_h/pix_size_h_corr))]))
file_h4 = os.path.join(param['dir_out'], param['subdir_data'],
param['prefix_files'] + '_horz-ss_v.dat')
np.savetxt(file_h4, ss_v, fmt = '%.18e', delimiter = '\t',
newline = '\n')
file_h5 = os.path.join(param['dir_out'], param['subdir_data'],
param['prefix_files'] + '_horz-ss_h.dat')
np.savetxt(file_h5, ss_h, fmt = '%.18e', delimiter = '\t',
newline = '\n')
......@@ -356,28 +377,18 @@ def main():
pix_size_v_corr = np.sqrt(pix_size_v**2.0 + horz_pix_drift**2.0)
# Save to file
if(save_data):
file_v1 = os.path.join(param['dir_out'], param['subdir_data'],
param['prefix_files'] + '_sd_vv.dat')
if(param['subdir_data']):
np.savetxt(file_v1, sd_vv, fmt = '%.18e', delimiter = '\t',
newline = '\n')
file_v2 = os.path.join(param['dir_out'], param['subdir_data'],
param['prefix_files'] + '_sd_vh.dat')
np.savetxt(file_v2, sd_vh, fmt = '%.18e', delimiter = '\t',
newline = '\n')
file_v3 = os.path.join(param['dir_out'], param['subdir_data'],
param['prefix_files'] + '_pix_size_v.dat')
# Uncorrected Pixel Size, Corrected Pixel Size, Misalignment
# Angle in Degrees
np.savetxt(file_v3, np.array([pix_size_v,
pix_size_v_corr, math.degrees(math.acos(
pix_size_v/pix_size_v_corr))]))
file_v4 = os.path.join(param['dir_out'], param['subdir_data'],
param['prefix_files'] + '_vert-ss_v.dat')
np.savetxt(file_v4, ss_v, fmt = '%.18e', delimiter = '\t',
newline = '\n')
file_v5 = os.path.join(param['dir_out'], param['subdir_data'],
param['prefix_files'] + '_vert-ss_h.dat')
np.savetxt(file_v5, ss_h, fmt = '%.18e', delimiter = '\t',
newline = '\n')
......@@ -408,7 +419,7 @@ def main():
disto_v = (-1) * func.integ_disto_maps(sd_hv, sd_vv, integ_meth = 2)
disto_v = disto_v - np.mean(disto_v)
if (save_plots):
if (param['subdir_fig']):
func.save_plot(disto_h, '2D_disto_h_FC',
param['dir_out'], xlabel='pixels',
ylabel='pixels',
......@@ -428,22 +439,19 @@ def main():
disto_v = func.integ_disto_maps(sd_hv, sd_vv, integ_meth = 1)
disto_v = disto_v - np.mean(disto_v)
if(save_data):
if(param['subdir_data']):
np.savetxt(file_h6, disto_h, fmt = '%.18e',
delimiter = '\t', newline = '\n')
np.savetxt(file_v6, disto_v, fmt = '%.18e',
delimiter = '\t', newline = '\n')
if(save_plots):
file_h6 = os.path.join(param['dir_out'], param['subdir_data'],
param['prefix_files'] + '_disto_h.dat')
if(param['subdir_fig']):
func.save_plot(disto_h, '2D_disto_h_g2s',
param['dir_out'], xlabel='pixels',
ylabel='pixels',
sub_dir=param['subdir_fig'], clabel='pixels')
file_v6 = os.path.join(param['dir_out'], param['subdir_data'],
param['prefix_files'] + '_disto_v.dat')
func.save_plot(disto_v, '2D_disto_v_g2s',
param['dir_out'], xlabel='pixels',
ylabel='pixels',
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment