Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
00ed220
Modified fastccd.c/h/module.c to remove gain setting
nisarnk Feb 19, 2025
33aa488
small error fixed
nisarnk Feb 19, 2025
24eed3c
modified utils.py settings.py and fastccd/images.py to remove gain se…
nisarnk Feb 21, 2025
0a3d842
Bugs fixed and now it works
nisarnk Feb 22, 2025
aed1d7a
modifies all 'fccd' to 'axis' and 'fastccd' to 'axis1'
nisarnk Feb 25, 2025
a038659
'fccd' and 'fastccd' added
nisarnk Feb 25, 2025
d03cf71
Update utils.py
nisarnk Feb 25, 2025
12ac143
csxtools/__init__.py modified
nisarnk Feb 25, 2025
49fef4b
Mirror reflection operation is done
nisarnk Mar 4, 2025
98e597f
Bug fix
nisarnk Mar 4, 2025
da37d35
Formatiing and docstring correction is done
nisarnk Mar 19, 2025
be1bcd7
Implement methode that returb AXIS1 timestamp
nisarnk Mar 24, 2025
45ad128
The photon count is removed for axis detector. A bug originated from …
nisarnk May 28, 2025
13a83d7
test
nisarnk Jun 4, 2025
9067577
The C-module for correcting image for dark and flatfeile is modified …
nisarnk Jun 4, 2025
8b4f877
api name changed from get_axis1_ to get_axis_
nisarnk Jun 18, 2025
07e7b35
formating done using balck
nisarnk Jun 19, 2025
0827b49
black and flake8 formatting applied
nisarnk Jun 20, 2025
96d9b71
some flake8 format issues fixed
nisarnk Jun 20, 2025
d79a6ea
some falke8 formatting done
nisarnk Jun 20, 2025
0d2c4b5
max line in .flake8 changed to 130
nisarnk Jun 23, 2025
0462bb8
max length in .flake8 set to 140 and ingnored bare exceptio
nisarnk Jun 23, 2025
ea5356e
tests/test_fastccd.py and tests/test_image.py are modified and improved
nisarnk Jun 24, 2025
a9a2a28
black and flake8 formatting done
nisarnk Jun 24, 2025
539cd59
updated test_fastccd.py and test_image.py
nisarnk Jun 24, 2025
78ae874
updated test_fastccd.py and test_image.py
nisarnk Jun 24, 2025
f1fb99d
updated test_fastccd.py and test_image.py
nisarnk Jun 24, 2025
32e98b3
updated test_fastccd.py and test_image.py
nisarnk Jun 24, 2025
aaceeef
updated test_fastccd.py and test_image.py
nisarnk Jun 24, 2025
9561393
removed tests folder containing test_fastccd.py and test_image.py
nisarnk Jun 24, 2025
90c24de
restored test_fastccd.py and test_image.py
nisarnk Jun 24, 2025
3964415
corrected test_image.py
nisarnk Jun 24, 2025
d7b9811
updated setup.py
nisarnk Jun 24, 2025
0ba6460
added pyproject.toml
nisarnk Jun 24, 2025
9e737b7
modified csxtools/.github/workflows/_test-in-conda-env.yml
nisarnk Jun 24, 2025
b7e404b
Changed from distutils.core import Extension to from setuptools impor…
nisarnk Jun 25, 2025
f00e630
extende the packege for python version 3.11 and 3.12
nisarnk Jun 25, 2025
fe79bf0
upgrade setup-python to v5 and codecov-action to v4 for improved comp…
nisarnk Jun 25, 2025
533a294
updated MANIFEST.in and extended classifiers in setup.py
nisarnk Jun 25, 2025
0f06457
Refactor: Simplify .flake8 exclude for .ipynb_checkpoints
nisarnk Jun 25, 2025
6752d44
Few docstrings are corrected
nisarnk Jun 25, 2025
688e3a4
modified csxtools/settings.py and csxtools/utils.py to add all AXIS d…
nisarnk Jun 26, 2025
d691e01
axis_mask() is removed from csxtools/utils.py
nisarnk Jun 26, 2025
1bb48c1
Remove dead Landscape.io badge from README
nisarnk Jun 28, 2025
cea94b3
Update README: removed broken Travis CI badge and added GitHub Action…
nisarnk Jun 28, 2025
e3bf201
A version implementing suggestions from Phil Maffettone in the PR.
nisarnk Jun 30, 2025
f6ce50c
Update README.md
nisarnk Jul 1, 2025
726e12e
Update README.md
nisarnk Jul 1, 2025
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
7 changes: 5 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ exclude =
build,
dist,
versioneer.py,
doc/conf.py
max-line-length = 115
csxtools/doc/conf.py
*.ipynb_checkpoints,

max-line-length = 140
ignore = E203, W503
5 changes: 5 additions & 0 deletions .github/workflows/_test-in-conda-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ jobs:
- name: Check out the code repo
uses: actions/checkout@v4

- name: Workaround: Fix .condarc MultipleKeysError
run: |
sed -i '/auto_activate_base/d' /home/runner/.condarc || true
sed -i '/auto_activate:/d' /home/runner/.condarc || true

- name: Set up Python ${{ inputs.python-version }} with conda
uses: conda-incubator/setup-miniconda@v3
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ jobs:

strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

fail-fast: false
steps:

- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -39,7 +39,7 @@ jobs:
coverage xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
flags: unittests
Expand Down
19 changes: 16 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
# Metadata and versioning
include README.md
include LICENSE.txt
include versioneer.py
include csxtools/_version.py

# Requirements
include requirements.txt
include requirements-extras.txt

include versioneer.py
include csxtools/_version.py
# Source code
recursive-include csxtools *.py *.so

# C sources and headers
recursive-include src *.c *.h

# Documentation and notebooks
recursive-include doc *
recursive-include examples *.ipynb

recursive-include src * *.[hc]
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
CSX Data Analysis Tools
=======================



[![Build Status](https://travis-ci.org/NSLS-II-CSX/csxtools.svg?branch=master)](https://travis-ci.org/NSLS-II-CSX/csxtools)
[![Coverage Status](https://coveralls.io/repos/NSLS-II-CSX/csxtools/badge.svg?branch=master&service=github)](https://coveralls.io/github/NSLS-II-CSX/csxtools?branch=master)
[![Code Health](https://landscape.io/github/NSLS-II-CSX/csxtools/master/landscape.svg?style=flat)](https://landscape.io/github/NSLS-II-CSX/csxtools/master)
[![Unit Tests](https://github.com/NSLS-II-CSX/csxtools/actions/workflows/tests.yml/badge.svg)](https://github.com/NSLS-II-CSX/csxtools/actions/workflows/tests.yml)
[![codecov](https://codecov.io/gh/NSLS-II-CSX/csxtools/branch/master/graph/badge.svg)](https://codecov.io/gh/NSLS-II-CSX/csxtools)
[![PyPI version](https://badge.fury.io/py/csxtools.svg)](https://badge.fury.io/py/csxtools)
[![License: BSD-3-Clause](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
[![Downloads](https://pepy.tech/badge/csxtools)](https://pepy.tech/project/csxtools)

Python library for tools to be used at the Coherent Soft X-ray scattering
beamline at NSLS-II, (CSX, 23-ID)
12 changes: 10 additions & 2 deletions csxtools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
# Now import useful functions

from .utils import (get_fastccd_images, get_fastccd_timestamps) # noqa F401
from .utils import get_fastccd_images # noqa: F401
from .utils import get_fastccd_flatfield # noqa: F401
from .utils import get_fastccd_timestamps # noqa: F401

from .utils import get_axis_images # noqa: F401
from .utils import get_axis_flatfield # noqa: F401
from .utils import get_axis_timestamps # noqa: F401

from .plotting import make_panel_plot # noqa F401

# set version string using versioneer
from ._version import get_versions
__version__ = get_versions()['version']

__version__ = get_versions()["version"]
del get_versions
121 changes: 72 additions & 49 deletions csxtools/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# This file helps to compute a version number in source trees obtained from
# git-archive tarball (such as those provided by githubs download-from-tag
# feature). Distribution tarballs (built by setup.py sdist) and build
Expand Down Expand Up @@ -57,6 +56,7 @@ def decorate(f):
HANDLERS[vcs] = {}
HANDLERS[vcs][method] = f
return f

return decorate


Expand All @@ -67,9 +67,12 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False):
try:
dispcmd = str([c] + args)
# remember shell=False, so use git.cmd on windows, not just git
p = subprocess.Popen([c] + args, cwd=cwd, stdout=subprocess.PIPE,
stderr=(subprocess.PIPE if hide_stderr
else None))
p = subprocess.Popen(
[c] + args,
cwd=cwd,
stdout=subprocess.PIPE,
stderr=(subprocess.PIPE if hide_stderr else None),
)
break
except EnvironmentError:
e = sys.exc_info()[1]
Expand Down Expand Up @@ -99,12 +102,17 @@ def versions_from_parentdir(parentdir_prefix, root, verbose):
dirname = os.path.basename(root)
if not dirname.startswith(parentdir_prefix):
if verbose:
print("guessing rootdir is '%s', but '%s' doesn't start with "
"prefix '%s'" % (root, dirname, parentdir_prefix))
print(
"guessing rootdir is '%s', but '%s' doesn't start with "
"prefix '%s'" % (root, dirname, parentdir_prefix)
)
raise NotThisMethod("rootdir doesn't start with parentdir_prefix")
return {"version": dirname[len(parentdir_prefix):],
"full-revisionid": None,
"dirty": False, "error": None}
return {
"version": dirname[len(parentdir_prefix) :],
"full-revisionid": None,
"dirty": False,
"error": None,
}


@register_vcs_handler("git", "get_keywords")
Expand Down Expand Up @@ -144,7 +152,7 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
# starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of
# just "foo-1.0". If we see a "tag: " prefix, prefer those.
TAG = "tag: "
tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)])
tags = set([r[len(TAG) :] for r in refs if r.startswith(TAG)])
if not tags:
# Either we're using git < 1.8.3, or there really are no tags. We use
# a heuristic: assume all version tags have a digit. The old git %d
Expand All @@ -153,27 +161,32 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
# between branches and tags. By ignoring refnames without digits, we
# filter out many common branch names like "release" and
# "stabilization", as well as "HEAD" and "master".
tags = set([r for r in refs if re.search(r'\d', r)])
tags = set([r for r in refs if re.search(r"\d", r)])
if verbose:
print("discarding '%s', no digits" % ",".join(refs-tags))
print("discarding '%s', no digits" % ",".join(refs - tags))
if verbose:
print("likely tags: %s" % ",".join(sorted(tags)))
for ref in sorted(tags):
# sorting will prefer e.g. "2.0" over "2.0rc1"
if ref.startswith(tag_prefix):
r = ref[len(tag_prefix):]
r = ref[len(tag_prefix) :]
if verbose:
print("picking %s" % r)
return {"version": r,
"full-revisionid": keywords["full"].strip(),
"dirty": False, "error": None
}
return {
"version": r,
"full-revisionid": keywords["full"].strip(),
"dirty": False,
"error": None,
}
# no suitable tags, so version is "0+unknown", but full hex is still there
if verbose:
print("no suitable tags, using unknown + full revision id")
return {"version": "0+unknown",
"full-revisionid": keywords["full"].strip(),
"dirty": False, "error": "no suitable tags"}
return {
"version": "0+unknown",
"full-revisionid": keywords["full"].strip(),
"dirty": False,
"error": "no suitable tags",
}


@register_vcs_handler("git", "pieces_from_vcs")
Expand All @@ -193,9 +206,9 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
GITS = ["git.cmd", "git.exe"]
# if there is a tag, this yields TAG-NUM-gHEX[-dirty]
# if there are no tags, this yields HEX[-dirty] (no NUM)
describe_out = run_command(GITS, ["describe", "--tags", "--dirty",
"--always", "--long"],
cwd=root)
describe_out = run_command(
GITS, ["describe", "--tags", "--dirty", "--always", "--long"], cwd=root
)
# --long was added in git-1.5.5
if describe_out is None:
raise NotThisMethod("'git describe' failed")
Expand All @@ -218,17 +231,16 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
dirty = git_describe.endswith("-dirty")
pieces["dirty"] = dirty
if dirty:
git_describe = git_describe[:git_describe.rindex("-dirty")]
git_describe = git_describe[: git_describe.rindex("-dirty")]

# now we have TAG-NUM-gHEX or HEX

if "-" in git_describe:
# TAG-NUM-gHEX
mo = re.search(r'^(.+)-(\d+)-g([0-9a-f]+)$', git_describe)
mo = re.search(r"^(.+)-(\d+)-g([0-9a-f]+)$", git_describe)
if not mo:
# unparseable. Maybe git-describe is misbehaving?
pieces["error"] = ("unable to parse git-describe output: '%s'"
% describe_out)
pieces["error"] = "unable to parse git-describe output: '%s'" % describe_out
return pieces

# tag
Expand All @@ -237,10 +249,12 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
if verbose:
fmt = "tag '%s' doesn't start with prefix '%s'"
print(fmt % (full_tag, tag_prefix))
pieces["error"] = ("tag '%s' doesn't start with prefix '%s'"
% (full_tag, tag_prefix))
pieces["error"] = "tag '%s' doesn't start with prefix '%s'" % (
full_tag,
tag_prefix,
)
return pieces
pieces["closest-tag"] = full_tag[len(tag_prefix):]
pieces["closest-tag"] = full_tag[len(tag_prefix) :]

# distance: number of commits since tag
pieces["distance"] = int(mo.group(2))
Expand All @@ -251,8 +265,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
else:
# HEX: no tags
pieces["closest-tag"] = None
count_out = run_command(GITS, ["rev-list", "HEAD", "--count"],
cwd=root)
count_out = run_command(GITS, ["rev-list", "HEAD", "--count"], cwd=root)
pieces["distance"] = int(count_out) # total number of commits

return pieces
Expand Down Expand Up @@ -281,8 +294,7 @@ def render_pep440(pieces):
rendered += ".dirty"
else:
# exception #1
rendered = "0+untagged.%d.g%s" % (pieces["distance"],
pieces["short"])
rendered = "0+untagged.%d.g%s" % (pieces["distance"], pieces["short"])
if pieces["dirty"]:
rendered += ".dirty"
return rendered
Expand Down Expand Up @@ -389,10 +401,12 @@ def render_git_describe_long(pieces):

def render(pieces, style):
if pieces["error"]:
return {"version": "unknown",
"full-revisionid": pieces.get("long"),
"dirty": None,
"error": pieces["error"]}
return {
"version": "unknown",
"full-revisionid": pieces.get("long"),
"dirty": None,
"error": pieces["error"],
}

if not style or style == "default":
style = "pep440" # the default
Expand All @@ -412,8 +426,12 @@ def render(pieces, style):
else:
raise ValueError("unknown style '%s'" % style)

return {"version": rendered, "full-revisionid": pieces["long"],
"dirty": pieces["dirty"], "error": None}
return {
"version": rendered,
"full-revisionid": pieces["long"],
"dirty": pieces["dirty"],
"error": None,
}


def get_versions():
Expand All @@ -426,8 +444,7 @@ def get_versions():
verbose = cfg.verbose

try:
return git_versions_from_keywords(get_keywords(), cfg.tag_prefix,
verbose)
return git_versions_from_keywords(get_keywords(), cfg.tag_prefix, verbose)
except NotThisMethod:
pass

Expand All @@ -436,12 +453,15 @@ def get_versions():
# versionfile_source is the relative path from the top of the source
# tree (where the .git directory might live) to this file. Invert
# this to find the root from __file__.
for i in cfg.versionfile_source.split('/'):
for i in cfg.versionfile_source.split("/"):
root = os.path.dirname(root)
except NameError:
return {"version": "0+unknown", "full-revisionid": None,
"dirty": None,
"error": "unable to find root of source tree"}
return {
"version": "0+unknown",
"full-revisionid": None,
"dirty": None,
"error": "unable to find root of source tree",
}

try:
pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose)
Expand All @@ -455,6 +475,9 @@ def get_versions():
except NotThisMethod:
pass

return {"version": "0+unknown", "full-revisionid": None,
"dirty": None,
"error": "unable to compute version"}
return {
"version": "0+unknown",
"full-revisionid": None,
"dirty": None,
"error": "unable to compute version",
}
9 changes: 9 additions & 0 deletions csxtools/axis1/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from .images import correct_images_axis

__all__ = ["correct_images_axis"]

# set version string using versioneer
from .._version import get_versions

__version__ = get_versions()["version"]
del get_versions
Loading
Loading