Skip to content

Commit

Permalink
feat: allow to provide wavelength
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin committed Oct 7, 2020
1 parent 7b8f523 commit 8baf000
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/flaskapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8]
python-version: [3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ REST-API built with flask that exposes [pymatgen](https://duckduckgo.com/?q=pyma
- `GET` to `/` shows the `README.md`
- `GET` to `/health` shows status information (for debugging)
- `POST` to `/api/predictxrd` with `structurefile` data (CIF as string) returns:

- `x`: with the 2 theta positions of the reflexes
- `y`: intensity of the reflexes
- `hkl` array of objects `{hkl: , multiplicity: }`

if you also provide `jcamp=true` you will receive

- `jcamp`: a string of the JCAMP-DX file with the predicted pattern

you can also specify a `wavelength` which must be one of the following strings: CuKa, CuKa2, CuKa1, CuKb1, MoKa, MoKa2, MoKa1, MoKb1, CrKa, CrKa2, CrKa1, CrKb1, FeKa, FeKa2, FeKa1, FeKb1, CoKa, CoKa2, CoKa1, CoKb1, AgKa, AgKa2, AgKa1, AgKb1.
8 changes: 8 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from flask import Flask, abort, jsonify, request
from flask_cors import CORS
from pymatgen import Structure
from pymatgen.analysis.diffraction.xrd import WAVELENGTHS

from xrd_tools import calculate_pattern

Expand Down Expand Up @@ -70,6 +71,13 @@ def predictxrd():
abort(500, "Could not read structure")

wavelength = "CuKa"
try:
if request.form["wavelength"] in list(WAVELENGTHS.keys()):
extension = request.form["extension"]
else:
abort(400, "This wavelength is not implemented")
except Exception: # pylint:disable=broad-except
pass

try:
output_dict = calculate_pattern(structure, wavelength, return_jcamp)
Expand Down

0 comments on commit 8baf000

Please sign in to comment.