-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into ticket42_sum_detect_m…
…onitor_spectra
- Loading branch information
Showing
41 changed files
with
941 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: test-against-main | ||
on: | ||
schedule: | ||
- cron: "0 0 * * *" | ||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
version: ['3.11', "3.12"] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.version }} | ||
- name: install requirements | ||
run: pip install -e .[dev] | ||
- name: install latest bluesky and ophyd-async | ||
run: pip install --upgrade --force-reinstall git+https://github.com/bluesky/bluesky.git@main git+https://github.com/bluesky/ophyd-async.git@main | ||
- name: run ruff | ||
run: python -m ruff check | ||
- name: run pyright | ||
run: python -m pyright | ||
- name: run pytest | ||
run: python -m pytest | ||
results: | ||
if: ${{ always() }} | ||
runs-on: ubuntu-latest | ||
name: Final Results | ||
needs: [tests] | ||
steps: | ||
- run: exit 1 | ||
# see https://stackoverflow.com/a/67532120/4907315 | ||
if: >- | ||
${{ | ||
contains(needs.*.result, 'failure') | ||
|| contains(needs.*.result, 'cancelled') | ||
}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Variance addition to counts data | ||
|
||
## Status | ||
|
||
Current | ||
|
||
## Context | ||
|
||
For counts data, the uncertainty on counts is typically defined by poisson counting statistics, i.e. the standard deviation on `N` counts is `sqrt(N)`. | ||
|
||
This can be problematic in cases where zero counts have been collected, as the standard deviation will then be zero, which will subsequently lead to "infinite" point weightings in downstream fitting routines for example. | ||
|
||
A number of possible approaches were considered: | ||
|
||
| Option | Description | | ||
| --- | --- | | ||
| A | Reject data with zero counts, i.e. explicitly throw an exception if any data with zero counts is seen as part of a scan. | | ||
| B | Use a standard deviation of `NaN` for points with zero counts. | | ||
| C | Define the standard deviation of `N` counts as `1` if counts are zero, otherwise `sqrt(N)`. This is one of the approaches available in mantid for example. | | ||
| D | Define the standard deviation of `N` counts as `sqrt(N+0.5)` unconditionally - on the basis that "half a count" is smaller than the smallest possible actual measurement which can be taken. | | ||
| E | No special handling, calculate std. dev. as `sqrt(N)`. | | ||
|
||
For clarity, the following table shows the value and associated uncertainty for each option: | ||
|
||
| Counts | Std. Dev. (A) | Std. Dev. (B) | Std. Dev. (C) | Std. Dev. (D) | Std. Dev. (E) | | ||
| ------- | ------ | ------- | ------- | ------- | --- | | ||
| 0 | raise exception | NaN | 1 | 0.707 | 0 | | ||
| 1 | 1 | 1 | 1 | 1.224745 | 1 | | ||
| 2 | 1.414214 | 1.414214 | 1.414214 | 1.581139 | 1.414214 | | ||
| 3 | 1.732051 | 1.732051 | 1.732051 | 1.870829 | 1.732051 | | ||
| 4 | 2 | 2 | 2 | 2.12132 | 2 | | ||
| 5 | 2.236068 | 2.236068 | 2.236068 | 2.345208 | 2.236068 | | ||
| 10 | 3.162278 | 3.162278 | 3.162278 | 3.24037 | 3.162278 | | ||
| 50 | 7.071068 | 7.071068 | 7.071068 | 7.106335 | 7.071068 | | ||
| 100 | 10 | 10 | 10 | 10.02497 | 10 | | ||
| 500 | 22.36068 | 22.36068 | 22.36068 | 22.37186 | 22.36068 | | ||
| 1000 | 31.62278 | 31.62278 | 31.62278 | 31.63068 | 31.62278 | | ||
| 5000 | 70.71068 | 70.71068 | 70.71068 | 70.71421 | 70.71068 | | ||
| 10000 | 100 | 100 | 100 | 100.0025 | 100 | | ||
|
||
## Present | ||
|
||
These approaches were discussed in a regular project update meeting including | ||
- TW & FA (Experiment controls) | ||
- CK (Reflectometry) | ||
- JL (Muons) | ||
- RD (SANS) | ||
|
||
## Decision | ||
|
||
The consensus was to go with Option D. | ||
|
||
## Justification | ||
|
||
- Option A will cause real-life scans to crash in low counts regions. | ||
- Option B involves `NaN`s, which have many surprising floating-point characteristics and are highly likely to be a source of future bugs. | ||
- Option D was preferred to option C by scientists present. | ||
- Option E causes surprising results and/or crashes downstream, for example fitting may consider points with zero uncertainty to have "infinite" weight, therefore effectively disregarding all other data. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,34 @@ | ||
# Logging | ||
To invoke the `ibex_bluesky_core` logger, create and use a `logger` object in [the standard way](https://docs.python.org/3/library/logging.html): | ||
|
||
To invoke the bluesky logger, import and use it at the desired level: | ||
```python | ||
from ibex_bluesky_core.logger import logger | ||
logger.blueskylogger.warning("Message to be logged") | ||
import logging | ||
logger = logging.getLogger(__name__) | ||
logger.warning("Message to be logged") | ||
``` | ||
The logger utilizes a `TimedRotatingFileHandler` defined in the `logging.conf` file that rolls over the log at midnight. | ||
|
||
The default logging level is defined at `INFO`. This means that events of lesser severity will not be logged. To change the default level, change level attribute of logger_blueskycore in the `logging.conf` | ||
The logger utilizes a `TimedRotatingFileHandler` defined in `src/ibex_bluesky_core/log.py` that rolls over the log at midnight. | ||
|
||
By default, the log files will be created in `c:\instrument\var\logs\bluesky`. This can be configured by setting | ||
the `IBEX_BLUESKY_CORE_LOGS` environment variable. | ||
|
||
There are 3 primary logger objects which are "interesting" in the context of `ibex_bluesky_core`: | ||
- `ibex_bluesky_core` itself | ||
- `bluesky`, for low-level diagnostic logging from the run engine & plans | ||
- `ophyd_async` for low-level diagnostic logging from ophyd-async devices | ||
|
||
The default logging level for bluesky libraries is defined at `INFO`. This means that events of lesser severity will not be logged. | ||
To change the logging level for all bluesky libraries simultaneously, call: | ||
|
||
```python | ||
from ibex_bluesky_core.log import set_bluesky_log_levels | ||
set_bluesky_log_levels("DEBUG") | ||
``` | ||
|
||
To change the logging level of just a single library (for example, just `opyhyd_async`), use the standard | ||
python `logging` mechanisms: | ||
|
||
```python | ||
import logging | ||
logging.getLogger("ophyd_async").setLevel("DEBUG") | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.