Skip to content

Commit

Permalink
black and flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
sbillinge committed Mar 30, 2024
1 parent 48d3237 commit e6fb4ff
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
11 changes: 8 additions & 3 deletions diffpy/labpdfproc/functions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from diffpy.utils.scattering_objects.diffraction_objects import Diffraction_object
import numpy as np
import math

import numpy as np

from diffpy.utils.scattering_objects.diffraction_objects import Diffraction_object

RADIUS_MM = 1
N_POINTS_ON_DIAMETER = 249
TTH_GRID = np.arange(1, 141, 1)
Expand Down Expand Up @@ -138,7 +140,10 @@ def _get_entry_exit_coordinates(self, coordinate, angle):

def get_path_length(self, grid_point, angle):
"""
return the path length of a horizontal line entering the circle to the grid point then exiting at angle angle
return the path length
This is the pathlength of a horizontal line entering the circle at the
same height to the grid point then exiting at angle angle
Parameters
----------
Expand Down
34 changes: 22 additions & 12 deletions diffpy/labpdfproc/labpdfprocapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,52 @@
from argparse import ArgumentParser
from pathlib import Path

import numpy as np
from diffpy.labpdfproc.functions import compute_cve, apply_corr
from diffpy.labpdfproc.functions import apply_corr, compute_cve
from diffpy.utils.parsers.loaddata import loadData
from diffpy.utils.scattering_objects.diffraction_objects import Diffraction_object, XQUANTITIES
from diffpy.utils.scattering_objects.diffraction_objects import XQUANTITIES, Diffraction_object

WAVELENGTHS = {"Mo": 0.71, "Ag": 0.59, "Cu": 1.54}
known_sources = [key for key in WAVELENGTHS.keys()]


def get_args():
p = ArgumentParser()
p.add_argument("mud", help="Value of mu*D for your sample. Required.", type=float)
p.add_argument("-i", "--input-file", help="The filename of the datafile to load")
p.add_argument("-a", "--anode-type", help=f"X-ray source, allowed values:{*[known_sources],}", default="Mo")
p.add_argument("mud", help="Value of mu*D for your " "sample. Required.", type=float)
p.add_argument("-i", "--input-file", help="The filename of the " "datafile to load")
p.add_argument(
"-a", "--anode-type", help=f"X-ray source, allowed " f"values: {*[known_sources], }", default="Mo"
)
p.add_argument(
"-w",
"--wavelength",
help=f"X-ray source wavelength. Not needed if the anode-type is specified. This will override the wavelength if anode type is specified",
help="X-ray source wavelength. Not needed if the anode-type "
"is specified. This will override the wavelength if anode "
"type is specified",
default=None,
type=float,
)
p.add_argument(
"-o",
"--output-directory",
help=f"the name of the output directory. If it doesn't exist it will be created. Not currently implemented",
help="the name of the output directory. If it doesn't exist it "
"will be created. Not currently implemented",
default=None,
)
p.add_argument(
"-x",
"--xtype",
help=f"the quantity on the independnt variable axis. allowed values:{*XQUANTITIES,}. If not specified then two-theta is assumed for the independent variable. Only implemented for tth currently",
help=f"the quantity on the independnt variable axis. allowed "
f"values: {*XQUANTITIES, }. If not specified then two-theta "
f"is assumed for the independent variable. Only implemented for "
f"tth currently",
default="tth",
)
p.add_argument(
"-c",
"--output-correction",
action="store_true",
help=f"the quantity on the independnt variable axis. allowed values:{*XQUANTITIES,}. If not specified then two-theta is assumed for the independent variable. Only implemented for tth currently",
help="the absorption correction will be output to a file if this "
"flag is set. Default is that it is not output",
default="tth",
)
p.add_argument(
Expand All @@ -63,11 +71,13 @@ def main():

if outfile.exists() and not args.force_overwrite:
sys.exit(
f"output file {str(outfile)} already exists. Please rerun specifying -f if you want to overwrite it"
f"output file {str(outfile)} already exists. Please rerun "
f"specifying -f if you want to overwrite it"
)
if corrfile.exists() and args.output_correction and not args.force_overwrite:
sys.exit(
f"corrections file {str(corrfile)} was requested and already exists. Please rerun specifying -f if you want to overwrite it"
f"corrections file {str(corrfile)} was requested and already "
f"exists. Please rerun specifying -f if you want to overwrite it"
)

input_pattern = Diffraction_object(wavelength=wavelength)
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import sys
import os
import sys
from os import path

from setuptools import find_packages, setup
from setuptools import setup

import versioneer

Expand Down Expand Up @@ -45,7 +45,8 @@
name="diffpy.labpdfproc",
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
description="An app for preprocessing data from laboratory x-ray diffractometers before using PDFgetX3 to obtain PDFs",
description="An app for preprocessing data from laboratory x-ray "
"diffractometers before using PDFgetX3 to obtain PDFs",
long_description=readme,
author="diffpy project",
author_email="[email protected]",
Expand Down

0 comments on commit e6fb4ff

Please sign in to comment.