Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions src/diffpy/__init__.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
#!/usr/bin/env python
##############################################################################
#
# dpx.pdfgetxgui by Simon J. L. Billinge group
# (c) 2012 Trustees of the Columbia University
# in the City of New York. All rights reserved.
# (c) 2025 The Trustees of Columbia University in the City of New York.
# All rights reserved.
#
# File coded by: Xiaohao Yang
# File coded by: Billinge Group members and community contributors.
#
# See AUTHORS.txt for a list of people who contributed.
# See LICENSE.txt for license information.
# See GitHub contributions for a more detailed list of contributors.
# https://github.com/diffpy/diffpy.srxplanargui/graphs/contributors
#
# See LICENSE.rst for license information.
#
##############################################################################
"""Blank namespace package."""

__import__("pkg_resources").declare_namespace(__name__)

# End of file
20 changes: 12 additions & 8 deletions src/diffpy/srxplanargui/__init__.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
#!/usr/bin/env python
##############################################################################
#
# dpx.pdfgetxgui by Simon J. L. Billinge group
# (c) 2012 Trustees of the Columbia University
# in the City of New York. All rights reserved.
# (c) 2025 The Trustees of Columbia University in the City of New York.
# All rights reserved.
#
# File coded by: Xiaohao Yang
# File coded by: Rundong Hua, Simon Billinge, Billinge Group members.
#
# See AUTHORS.txt for a list of people who contributed.
# See LICENSE.txt for license information.
# See GitHub contributions for a more detailed list of contributors.
# https://github.com/diffpy/diffpy.srxplanargui/graphs/contributors
#
# See LICENSE.rst for license information.
#
##############################################################################
"""XPDFsuite, a software for PDF transformation and visualization."""

# package version
from diffpy.srxplanargui.version import __version__ # noqa

# obtain version information
# from diffpy.srxplanargui.version import __version__
# silence the pyflakes syntax checker
assert __version__ or True

# End of file
8 changes: 4 additions & 4 deletions src/diffpy/srxplanargui/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
import re
import sys

from diffpy.srxconfutils.tools import module_exists_lower
from diffpy.srxplanar.selfcalibrate import selfCalibrate
from diffpy.srxplanar.srxplanar import SrXplanar
from diffpy.srxplanar.srxplanarconfig import checkMax
from pyface.api import ImageResource
from traits.api import (
Bool,
Expand All @@ -38,6 +34,10 @@
from traitsui.api import Group, Handler, HGroup, Item, VGroup, View
from traitsui.menu import CancelButton, OKButton

from diffpy.srxconfutils.tools import module_exists_lower
from diffpy.srxplanar.selfcalibrate import selfCalibrate
from diffpy.srxplanar.srxplanar import SrXplanar
from diffpy.srxplanar.srxplanarconfig import checkMax
from diffpy.srxplanargui.srxconfig import SrXconfig

ETSConfig.toolkit = "qt"
Expand Down
52 changes: 33 additions & 19 deletions src/diffpy/srxplanargui/imageplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,38 +101,50 @@ class ImagePlot(HasTraits):
)
avgmask = DelegatesTo(
"srxconfig",
desc=("Mask the pixels too bright or too dark compared to"
" the average intensity at the similar diffraction angle"),
desc=(
"Mask the pixels too bright or too dark compared to"
" the average intensity at the similar diffraction angle"
),
)
brightpixelr = DelegatesTo(
"srxconfig",
desc=("Pixels with intensity large than this relative threshold"
" (times the local environment) value will be masked"),
desc=(
"Pixels with intensity large than this relative threshold"
" (times the local environment) value will be masked"
),
)
brightpixelsize = DelegatesTo(
"srxconfig", desc="Size of testing area for detecting bright pixels"
)
darkpixelr = DelegatesTo(
"srxconfig",
desc=("Pixels with intensity less than this relative threshold"
" (times the local environment) value will be masked"),
desc=(
"Pixels with intensity less than this relative threshold"
" (times the local environment) value will be masked"
),
)
avgmaskhigh = DelegatesTo(
"srxconfig",
desc=("Comparing to the average intensity at "
"similar diffraction angle, \npixels with intensity larger than"
" avg_int*high will be masked"),
desc=(
"Comparing to the average intensity at "
"similar diffraction angle, \npixels with intensity larger than"
" avg_int*high will be masked"
),
)
avgmasklow = DelegatesTo(
"srxconfig",
desc=("Comparing to the average intensity at "
"similar diffraction angle, \npixels with intensity less than "
"avg_int*low will be masked"),
desc=(
"Comparing to the average intensity at "
"similar diffraction angle, \npixels with intensity less than "
"avg_int*low will be masked"
),
)
cropedges = DelegatesTo(
"srxconfig",
desc=("The number of pixels masked"
" at each edge (left, right, top, bottom)"),
desc=(
"The number of pixels masked"
" at each edge (left, right, top, bottom)"
),
)

def createPlot(self):
Expand Down Expand Up @@ -231,7 +243,7 @@ def addPointMask(self, ndx, remove=None):
"""Param ndx -- (x,y) float."""
x, y = ndx
r = self.pts - np.array((x, y))
r = np.sum(r ** 2, axis=1)
r = np.sum(r**2, axis=1)
mask = r < ((self.pointmaskradius + 1) ** 2)
mask = mask.reshape(self.staticmask.shape)
if remove:
Expand Down Expand Up @@ -318,9 +330,11 @@ def _enableMaskEditing(self):
self.plot.tools.remove(self.pan)
self.plot.overlays.append(self.lstool)
self.titlebak = self.plot.title
self.plot.title = ("Click: add a vertex; "
"<Ctrl>+Click: remove a vertex; \n "
"<Enter>: finish the selection")
self.plot.title = (
"Click: add a vertex; "
"<Ctrl>+Click: remove a vertex; \n "
"<Enter>: finish the selection"
)
return

def _disableMaskEditing(self):
Expand Down Expand Up @@ -687,7 +701,7 @@ class AdvHint(HasTraits):
compared to their local environment
Average mask: Mask the pixels too bright or too dark
compared to the average intensity at the similar diffraction angle.
Currect calibration information is required."""
Correct calibration information is required."""
)

advhint_view = View(
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/srxplanargui/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import os
import sys

from diffpy.srxplanar.srxplanar import SrXplanar
from pyface.api import GUI, ImageResource, SplashScreen
from traits.api import Any, on_trait_change
from traits.etsconfig.api import ETSConfig
Expand All @@ -32,6 +31,7 @@
)
from traitsui.menu import OKButton

from diffpy.srxplanar.srxplanar import SrXplanar
from diffpy.srxplanargui.calibration import Calibration
from diffpy.srxplanargui.help import SrXguiHelp
from diffpy.srxplanargui.selectfiles import AddFiles
Expand Down
3 changes: 1 addition & 2 deletions src/diffpy/srxplanargui/selectfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
from diffpy.pdfgete.functs import sortKeyNumericString

from diffpy.srxplanar.loadimage import openImage, saveImage

from diffpy.srxplanargui.datacontainer import DataContainer
from diffpy.srxplanargui.imageplot import ImagePlot
from diffpy.srxplanargui.srxconfig import SrXconfig
Expand Down Expand Up @@ -94,7 +93,7 @@ class AddFiles(HasTraits):

srxconfig = Instance(SrXconfig)

# The currenty inputdir directory being searched:
# The currently inputdir directory being searched:
# inputdir = DelegatesTo('srxconfig')
inputdir = Directory() # , entries = 10 )

Expand Down
11 changes: 6 additions & 5 deletions src/diffpy/srxplanargui/srxconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@
import os

import numpy as np
from pyface.api import ImageResource
from traits.api import Bool, Enum, Property, on_trait_change
from traits.etsconfig.api import ETSConfig
from traitsui.api import Group, Item, View

from diffpy.srxconfutils.configtraits import ConfigBaseTraits
from diffpy.srxplanar.srxplanarconfig import (
_description,
_epilog,
_optdatalist,
checkMax,
)
from pyface.api import ImageResource
from traits.api import Bool, Enum, Property, on_trait_change
from traits.etsconfig.api import ETSConfig
from traitsui.api import Group, Item, View

ETSConfig.toolkit = "qt"

Expand Down Expand Up @@ -109,7 +110,7 @@ class SrXconfig(ConfigBaseTraits):

_optdatalist = _optdatalist

_defaultdata = {"configfile": [], "headertitle": "SrXgui configration"}
_defaultdata = {"configfile": [], "headertitle": "SrXgui configuration"}

rotation = Property(
depends_on="rotationd", fget=lambda self: np.radians(self.rotationd)
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/srxplanargui/srxgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import os
import sys

from diffpy.srxplanar.srxplanar import SrXplanar
from pyface.api import ImageResource
from traits.api import Any, Button, File, HasTraits, Instance
from traits.etsconfig.api import ETSConfig
Expand All @@ -33,6 +32,7 @@
)
from traitsui.menu import CancelButton, OKButton

from diffpy.srxplanar.srxplanar import SrXplanar
from diffpy.srxplanargui.calibration import Calibration
from diffpy.srxplanargui.help import SrXguiHelp
from diffpy.srxplanargui.selectfiles import AddFiles
Expand Down
34 changes: 34 additions & 0 deletions src/diffpy/srxplanargui/srxplanargui_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import argparse

from diffpy.srxplanargui.version import __version__ # noqa


def main():
parser = argparse.ArgumentParser(
prog="diffpy.srxplanargui",
description=(
"xPDFsuite, a software for PDF transformation"
" and visualization.\n\n"
"For more information, visit: "
"https://github.com/diffpy/diffpy.srxplanargui/"
),
formatter_class=argparse.RawDescriptionHelpFormatter,
)

parser.add_argument(
"--version",
action="store_true",
help="Show the program's version number and exit",
)

args = parser.parse_args()

if args.version:
print(f"diffpy.srxplanargui {__version__}")
else:
# Default behavior when no arguments are given
parser.print_help()


if __name__ == "__main__":
main()
34 changes: 16 additions & 18 deletions src/diffpy/srxplanargui/version.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
#!/usr/bin/env python
##############################################################################
#
# diffpy.srxplanar by DANSE Diffraction group
# Simon J. L. Billinge
# (c) 2010 Trustees of the Columbia University
# in the City of New York. All rights reserved.
# (c) 2025 The Trustees of Columbia University in the City of New York.
# All rights reserved.
#
# File coded by: Xiaohao Yang
# File coded by: Rundong Hua, Simon Billinge, Billinge Group members.
#
# See AUTHORS.txt for a list of people who contributed.
# See LICENSENOTICE.txt for license information.
# See GitHub contributions for a more detailed list of contributors.
# https://github.com/diffpy/diffpy.srxplanargui/graphs/contributors # noqa: E501
#
# See LICENSE.rst for license information.
#
##############################################################################
"""Definition of __version__ and __date__ for this package."""

# obtain version information
from pkg_resources import get_distribution
"""Definition of __version__."""

_pkgname = __name__.rsplit(".", 1)[0]
__version__ = get_distribution(_pkgname).version
# We do not use the other three variables, but can be added back if needed.
# __all__ = ["__date__", "__git_commit__", "__timestamp__", "__version__"]

# we assume that tag_date was used and __version__ ends in YYYYMMDD
__date__ = (
__version__[-8:-4] + "-" + __version__[-4:-2] + "-" + __version__[-2:]
)
# obtain version information
from importlib.metadata import PackageNotFoundError, version

# End of file
try:
__version__ = version("diffpy.srxplanargui")
except PackageNotFoundError:
__version__ = "unknown"