Commit 5139dc09 authored by Ruxandra Cojocaru's avatar Ruxandra Cojocaru

Modified README. Small fixes in func.py.

parent 05a2d8b4
......@@ -2,16 +2,28 @@
Speckle Wavefront Reconstruction Package. Based on X-ray Speckle Tracking (XST) principle.
## How to install the package in Linux
git clone https://gitlab.esrf.fr/cojocaru/swarp
sudo python setup.py install
## How to run the code (for now)
python waveFront.py image1 image2 file.ini
e.g. python waveFront.py ./testdata/image1.edf ./testdata/image2.edf ./testdata/test_wf.ini
e.g. python waveFront.py ./resources/image1.edf ./resources/image2.edf ./resources/test_wf.ini
python detectorDistortion.py path_to_files file.ini
e.g. python detectorDistortion.py ./resources/det-dist/ ./resources/test_wf.ini
## Code manual:
https://www.eucall.eu/sites/sites_custom/site_eucall/content/e21597/e25317/e79563/EUCALL_WP7_PUCCA_Deliverable_7_8_D37_30_09_2018.pdf?preview=preview
## Authors
* **Ruxandra Cojocaru**
* **Sebastien Berujon**
* **Ruxandra Cojocaru**, cojocaru@esrf.fr
* **Sebastien Berujon**, sebastien.berujon@esrf.fr
## License
......
......@@ -262,7 +262,7 @@ def check_input(section, path_ini, dt):
error_msg = ('The provided INI file does not contain the ' + str(section)
+ ' section. All relevant user parameters must be present '
+ 'in the INI file under that section.')
test_err(section in config.sections(), error_msg)
test_err(section in config.sections(), 'check_input', error_msg)
section_out = section + '_checked'
......@@ -512,7 +512,7 @@ def check_input_dd(section, section_out, path_ini, dt):
error_msg = ('The provided INI file does not contain the ' + str(section)
+ ' section. All relevant user parameters must be present '
+ 'in the INI file under that section')
test_err(section in config.sections(), error_msg)
test_err(section in config.sections(), 'check_input_dd', error_msg)
# Prepare list of [key, data_type, default_val, use_default, positive, acc_value]
key_list = [['path_dark', 'path', None, True, False, None],
......@@ -683,7 +683,7 @@ def check_input_xsvt(section, section_out, path_ini, dt):
error_msg = ('The provided INI file does not contain the ' + str(section)
+ ' section. All relevant user parameters must be present '
+ 'in the INI file under that section')
test_err(section in config.sections(), error_msg)
test_err(section in config.sections(), 'check_input_xsvt', error_msg)
# Prepare list of [key, data_type, default_val, use_default, positive, acc_value]
key_list = [['energy', 'float', None, False, True, None],
......@@ -922,7 +922,8 @@ def compute_corr_field(path_corr, prefix_files, file_type, string,
empty_err = ('The list of files for ' + str(string) + ' Field '
+ 'correction from folder ' + str(path_corr)
+ ' is EMPTY. Double-check the path.')
test_err(bool(len(file_list_corr)), compute_corr_field, empty_err)
test_err(bool(len(file_list_corr)), 'compute_corr_field',
empty_err)
# Filter files in folder starting with prefix if given
if (prefix_files):
......@@ -934,7 +935,7 @@ def compute_corr_field(path_corr, prefix_files, file_type, string,
+ ' after filtering by prefix '
+ str(prefix_files)
+ ' is EMPTY. Double-check the path and prefix.')
test_err(bool(len(file_list_corr)), compute_corr_field,
test_err(bool(len(file_list_corr)), 'compute_corr_field',
empty_err)
logging.info(str(len(file_list_corr)) + ' correction files')
......@@ -1009,12 +1010,14 @@ def correction(image, have_flat, flat_img, have_dark, dark_img):
Returns corrected image
"""
# After removing dark field, force all negative values to 0
# For numerator, force all null and negative values to 0.00000001
if (have_flat != 0 and have_dark != 0):
numerator = flat_img - dark_img
numerator = (flat_img - dark_img).clip(0)
numerator[numerator == 0] = 0.00000001
image = (image - dark_img) / numerator
elif (have_dark != 0):
image = image - dark_img
image = (image - dark_img).clip(0)
elif (have_flat != 0):
flat_img[flat_img == 0] = 0.00000001
image = image / flat_img
......@@ -2595,5 +2598,5 @@ def save_plot(data, file_name, dir_out, sub_dir='', xlabel=None,
if not os.path.exists(dir_out + sub_dir):
os.makedirs(dir_out + sub_dir)
plt.savefig(dir_out + sub_dir + file_name + '.png')
plt.savefig(os.path.join(dir_out, sub_dir, file_name + '.png'))
plt.close(fig)
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