xray-spectrum-modeling documentation

25
xray-spectrum-modeling Documentation Release 0.2.0 Hendrix Demers Jan 26, 2018

Upload: others

Post on 18-Dec-2021

2 views

Category:

Documents


0 download

TRANSCRIPT

xray-spectrum-modelingDocumentation

Release 0.2.0

Hendrix Demers

Jan 26, 2018

Contents

1 xray-spectrum-modeling 31.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2 Credits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 Installation 52.1 Stable release . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2 For developer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.3 From sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

3 Usage 73.1 create_test_map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73.2 create_map_mm2017_abstract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

4 Contributing 114.1 Types of Contributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114.2 Get Started! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124.3 Pull Request Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134.4 Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

5 Credits 155.1 Development Lead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155.2 Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

6 History 176.1 0.1.0 (2017-03-06) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

7 ToDo 19

8 Indices and tables 21

i

ii

xray-spectrum-modeling Documentation, Release 0.2.0

Contents:

Contents 1

xray-spectrum-modeling Documentation, Release 0.2.0

2 Contents

CHAPTER 1

xray-spectrum-modeling

Modeling of an X-ray spectrum in EDS detector

• Free software: Apache Software License 2.0

• Documentation: https://xray-spectrum-modeling.readthedocs.io.

1.1 Features

• TODO

1.2 Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

3

xray-spectrum-modeling Documentation, Release 0.2.0

4 Chapter 1. xray-spectrum-modeling

CHAPTER 2

Installation

Warning: Some feature of xray-spectrum-modeling need the microanalysis_file_format project to be installed.The project can be found on github: microanalysis_file_format

2.1 Stable release

To install xray-spectrum-modeling, run this command in your terminal:

Todo: Add pypi installation for this project.

$ pip install xrayspectrummodeling

This is the preferred method to install xray-spectrum-modeling, as it will always install the most recent stable release.

If you don’t have pip installed, this Python installation guide can guide you through the process.

Note: On windows use the py -m pip command and not pip.

2.2 For developer

Clone the public repository:

$ git clone git://github.com/drix00/xray-spectrum-modeling

Go in the project folder and install it with pip in developer mode:

5

xray-spectrum-modeling Documentation, Release 0.2.0

$ cd xray-spectrum-modeling$ pip install -e .

Note: The project use Git LFS for the test data file. Follow the information on Git LFS to get the test data when therepository is pull.

2.3 From sources

The sources for xray-spectrum-modeling can be downloaded from the Github repo.

You can either clone the public repository:

$ git clone git://github.com/drix00/xray-spectrum-modeling

Or download the tarball:

$ curl -OL https://github.com/drix00/xray-spectrum-modeling/tarball/master

Once you have a copy of the source, you can install it with:

$ python setup.py install

6 Chapter 2. Installation

CHAPTER 3

Usage

To use xray-spectrum-modeling in a project look in the examples folder. You need reference spectrum from mcxraysimulation saved in a hdf5 file.

To run the example, you need to specify a path were to find a the mcxray reference spectrum in hdf5 file.

$python create_test_map.py ../../test_data/map

Note: On windows use the py command and not python if you have more than one python version installed.

3.1 create_test_map

To run this example, you need to specify a path were to find a the mcxray reference spectrum in hdf5 file.

$python create_test_map.py ../../test_data/map

This path is passed to the method run_maps parameter data_path. The variable data_path hold the path were the inputand output data is read and writen.

First you need reference spectrum from mcxray simulation saved in a hdf5 file and an output file to save the data.

hdf5_file_path = os.path.join(data_path, "SimulationMapsMM2017_3x3.hdf5")hdf5_file_out_path = os.path.join(data_path, "map_mm2017_abstract_3x3.hdf5")

Currently the probe positions to create a map are not read from the mcxray hdf5 file. You need to create it yourselfand if the positions does not correspond at the position simulated, bad pixel will occur and maybe a crash of the script.

position = Positions()position.x_pixels = 3position.y_pixels = 3position.minimum_x_nm = -5.0e3position.maximum_x_nm = 5.0e3

7

xray-spectrum-modeling Documentation, Release 0.2.0

position.minimum_y_nm = -5.0e3position.maximum_y_nm = 5.0e3

With the correct positions, you can create different maps and spectra:

• Electron map using _create_electron_maps

• Intensity map using _create_intensity_maps

• Spectra which model the EDS detector noise using _create_spectra_maps

• Export the spectra map into .raw files using _export_raw_map

_create_electron_maps(data_path, hdf5_file_path, position)

_create_intensity_maps(data_path, hdf5_file_path, position)

_create_spectra(data_path, hdf5_file_path, position)

_create_spectra_maps(data_path, hdf5_file_path, hdf5_file_out_path, position)

_export_raw_map(hdf5_file_out_path)

Warning: _create_spectra need to be called before _create_spectra_maps

Warning: _create_spectra_maps need to be called before _export_raw_map

Note: You need to have the project microanalysis_file_format installed to use _export_raw_map.

This example shows a good pratice when working with xray-spectrum-modeling. Use a small set of position to test thesimulation and the code creating the x-ray spectrum and map. The script will be fast and can be run with the debugger.When everything is OK, run the larger probe positions to have a reallistic map.

Note: The time to create a map increases with larger dose. A 128x128 map with a high dose with a acquisition timeof 1000 s can take between 30 minutes to 1 hour.

To verify the map creation, the method _read_raw_map can be used. But you need to have the project microanaly-sis_file_format installed.

file_path = hdf5_file_out_path[:-5] + "_" + "map_1000000_us" + ".raw"_read_raw_map(file_path)

3.2 create_map_mm2017_abstract

This example is very similar to the previous one, but it create a 128x128 maps.

The only difference is different hdf5 files are specified and the positions list is different.

8 Chapter 3. Usage

xray-spectrum-modeling Documentation, Release 0.2.0

hdf5_file_path = os.path.join(data_path, "SimulationMapsMM2017.hdf5")hdf5_file_out_path = os.path.join(data_path, "map_mm2017_abstract_128x128.hdf5")

position = Positions()position.x_pixels = 128position.y_pixels = 128position.minimum_x_nm = -5.0e3position.maximum_x_nm = 5.0e3position.minimum_y_nm = -5.0e3position.maximum_y_nm = 5.0e3

The rest of the code is the same. Obvoiusly you need to pass the correct path for the 128x128 data to the script.

3.2. create_map_mm2017_abstract 9

xray-spectrum-modeling Documentation, Release 0.2.0

10 Chapter 3. Usage

CHAPTER 4

Contributing

Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.

You can contribute in many ways:

4.1 Types of Contributions

4.1.1 Report Bugs

Report bugs at https://github.com/drix00/xrayspectrummodeling/issues.

If you are reporting a bug, please include:

• Your operating system name and version.

• Any details about your local setup that might be helpful in troubleshooting.

• Detailed steps to reproduce the bug.

4.1.2 Fix Bugs

Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wantsto implement it.

4.1.3 Implement Features

Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open towhoever wants to implement it.

11

xray-spectrum-modeling Documentation, Release 0.2.0

4.1.4 Write Documentation

xray-spectrum-modeling could always use more documentation, whether as part of the official xray-spectrum-modeling docs, in docstrings, or even on the web in blog posts, articles, and such.

4.1.5 Submit Feedback

The best way to send feedback is to file an issue at https://github.com/drix00/xrayspectrummodeling/issues.

If you are proposing a feature:

• Explain in detail how it would work.

• Keep the scope as narrow as possible, to make it easier to implement.

• Remember that this is a volunteer-driven project, and that contributions are welcome :)

4.2 Get Started!

Ready to contribute? Here’s how to set up xrayspectrummodeling for local development.

1. Fork the xrayspectrummodeling repo on GitHub.

2. Clone your fork locally:

$ git clone [email protected]:your_name_here/xrayspectrummodeling.git

3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set upyour fork for local development:

$ mkvirtualenv xrayspectrummodeling$ cd xrayspectrummodeling/$ python setup.py develop

4. Create a branch for local development:

$ git checkout -b name-of-your-bugfix-or-feature

Now you can make your changes locally.

5. When you’re done making changes, check that your changes pass flake8 and the tests, including testing otherPython versions with tox:

$ flake8 xrayspectrummodeling tests$ python setup.py test or py.test$ tox

To get flake8 and tox, just pip install them into your virtualenv.

6. Commit your changes and push your branch to GitHub:

$ git add .$ git commit -m "Your detailed description of your changes."$ git push origin name-of-your-bugfix-or-feature

7. Submit a pull request through the GitHub website.

12 Chapter 4. Contributing

xray-spectrum-modeling Documentation, Release 0.2.0

4.3 Pull Request Guidelines

Before you submit a pull request, check that it meets these guidelines:

1. The pull request should include tests.

2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a functionwith a docstring, and add the feature to the list in README.rst.

3. The pull request should work for Python 2.6, 2.7, 3.3, 3.4 and 3.5, and for PyPy. Check https://travis-ci.org/drix00/xrayspectrummodeling/pull_requests and make sure that the tests pass for all supported Python versions.

4.4 Tips

To run a subset of tests:

$ python -m unittest tests.test_xrayspectrummodeling

4.3. Pull Request Guidelines 13

xray-spectrum-modeling Documentation, Release 0.2.0

14 Chapter 4. Contributing

CHAPTER 5

Credits

5.1 Development Lead

• Hendrix Demers <[email protected]>

5.2 Contributors

None yet. Why not be the first?

15

xray-spectrum-modeling Documentation, Release 0.2.0

16 Chapter 5. Credits

CHAPTER 6

History

6.1 0.1.0 (2017-03-06)

• First release on PyPI.

17

xray-spectrum-modeling Documentation, Release 0.2.0

18 Chapter 6. History

CHAPTER 7

ToDo

Todo: Add pypi installation for this project.

(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/xray-spectrum-modeling/checkouts/latest/docs/installation.rst, line 18.)

19

xray-spectrum-modeling Documentation, Release 0.2.0

20 Chapter 7. ToDo

CHAPTER 8

Indices and tables

• genindex

• modindex

• search

21