Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 55e9407b67 | |||
| 5fc512632f | |||
| 55a7b7270c | |||
| f81582554e | |||
| 3e22a94ff6 | |||
|
|
c1dc194548 | ||
|
|
c5f5602a89 | ||
| cf9c0018a5 | |||
| 03ac04ab05 | |||
| b2df980a21 | |||
| eb54e52c66 | |||
| 9b4c384425 |
12
.github/workflows/release.yml
vendored
12
.github/workflows/release.yml
vendored
@@ -38,6 +38,12 @@ jobs:
|
||||
- name: Build PyPI package
|
||||
run: |
|
||||
python3 -m build
|
||||
- name: Archive distribution
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: linux-dist
|
||||
path: |
|
||||
dist/*.tar.gz
|
||||
- name: Upload to PyPI
|
||||
if: github.event_name != 'workflow_dispatch'
|
||||
uses: pypa/gh-action-pypi-publish@release/v1
|
||||
@@ -45,12 +51,6 @@ jobs:
|
||||
user: __token__
|
||||
password: ${{ secrets.PYPI_TOKEN }}
|
||||
skip-existing: true
|
||||
- name: Archive distribution
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: linux-dist
|
||||
path: |
|
||||
dist/*.tar.gz
|
||||
|
||||
build-windows:
|
||||
runs-on: windows-latest
|
||||
|
||||
7
.github/workflows/unit_tests.yml
vendored
7
.github/workflows/unit_tests.yml
vendored
@@ -15,7 +15,7 @@ jobs:
|
||||
runs-on: ubuntu-22.04
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: [3.8, 3.9, '3.10', '3.11', '3.12']
|
||||
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
@@ -31,6 +31,11 @@ jobs:
|
||||
pip install pytest
|
||||
pip install -r requirements.txt
|
||||
|
||||
- name: Backport to 3.8
|
||||
if: matrix.python-version == '3.8'
|
||||
run: |
|
||||
pip install backports.zoneinfo
|
||||
|
||||
- name: Test with pytest
|
||||
run: |
|
||||
cd tests
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
Package to handle data redction at AMOR instrument to be used by eos.py script.
|
||||
"""
|
||||
|
||||
__version__ = '2.1.2'
|
||||
__date__ = '2024-12-03'
|
||||
__version__ = '2.1.3'
|
||||
__date__ = '2024-12-13'
|
||||
|
||||
@@ -3,6 +3,11 @@ import os
|
||||
import subprocess
|
||||
import sys
|
||||
from datetime import datetime, timezone
|
||||
try:
|
||||
import zoneinfo
|
||||
except ImportError:
|
||||
# for python versions < 3.9 try to use the backports version
|
||||
from backports import zoneinfo
|
||||
from typing import List
|
||||
|
||||
import h5py
|
||||
@@ -20,6 +25,9 @@ try:
|
||||
except Exception:
|
||||
nb_helpers = None
|
||||
|
||||
# Time zone used to interpret time strings
|
||||
AMOR_LOCAL_TIMEZONE = zoneinfo.ZoneInfo(key='Europe/Zurich')
|
||||
|
||||
class AmorData:
|
||||
"""read meta-data and event streams from .hdf file(s), apply filters and conversions"""
|
||||
chopperDetectorDistance: float
|
||||
@@ -228,13 +236,17 @@ class AmorData:
|
||||
|
||||
# fill in missing pulse times
|
||||
# TODO: check for real end time
|
||||
self.pulseTimeS = np.array([], dtype=np.int64)
|
||||
try:
|
||||
# further files
|
||||
# TODO: use the first pulse of the respective measurement
|
||||
#nextPulseTime = startTime % np.int64(self.tau*2e9)
|
||||
nextPulseTime = self.pulseTimeS[-1] + chopperPeriod
|
||||
#nextPulseTime = self.pulseTimeS[-1] + chopperPeriod
|
||||
nextPulseTime = pulseTime[0]
|
||||
except AttributeError:
|
||||
# first file
|
||||
nextPulseTime = pulseTime[0] % np.int64(self.tau*2e9)
|
||||
self.pulseTimeS = np.array([], dtype=np.int64)
|
||||
|
||||
for tt in pulseTime:
|
||||
while tt - nextPulseTime > self.tau*1e9:
|
||||
self.pulseTimeS = np.append(self.pulseTimeS, nextPulseTime)
|
||||
@@ -369,7 +381,7 @@ class AmorData:
|
||||
self.pixelID_e = self.pixelID_e[filter_e]
|
||||
self.wallTime_e = self.wallTime_e[filter_e]
|
||||
if np.shape(filter_e)[0]-np.shape(self.tof_e)[0]>0.5:
|
||||
logging.warning(f'# strange times: {np.shape(filter_e)[0]-np.shape(self.tof_e)[0]}')
|
||||
logging.warning(f' strange times: {np.shape(filter_e)[0]-np.shape(self.tof_e)[0]}')
|
||||
|
||||
def read_event_stream(self):
|
||||
self.tof_e = np.array(self.hdf['/entry1/Amor/detector/data/event_time_offset'][:])/1.e9
|
||||
@@ -433,7 +445,8 @@ class AmorData:
|
||||
self.nu = self.config.nu
|
||||
|
||||
# extract start time as unix time, adding UTC offset of 1h to time string
|
||||
self.fileDate = datetime.fromisoformat( self.hdf['/entry1/start_time'][0].decode('utf-8')+"+01:00" )
|
||||
dz = datetime.fromisoformat(self.hdf['/entry1/start_time'][0].decode('utf-8'))
|
||||
self.fileDate=dz.replace(tzinfo=AMOR_LOCAL_TIMEZONE)
|
||||
self.startTime = np.int64( (self.fileDate.timestamp() ) * 1e9 )
|
||||
if self.seriesStartTime is None:
|
||||
self.seriesStartTime = self.startTime
|
||||
|
||||
@@ -372,11 +372,15 @@ class AmorReduction:
|
||||
# projection on lambda-z-grid
|
||||
lamda_l = self.grid.lamda()
|
||||
alphaF_z = fromHDF.nu - fromHDF.mu + fromHDF.delta_z
|
||||
# TODO: implement various methods to obtain alpha_i.
|
||||
#if self.experiment_config.incidentAngle == 'alphaF':
|
||||
# # for specular reflectometry with a highly divergent beam
|
||||
# alphaF_z = fromHDF.nu - fromHDF.mu + fromHDF.delta_z
|
||||
#elif self.experiment_config.incidentAngle == 'nu':
|
||||
# # for specular reflectometry, using kappa nad nu but ignoring mu
|
||||
# alphaF_z = (fromHDF.nu + fromHDF.delta_z + fromHDF.kap + fromHDF.kad) / 2.
|
||||
#else:
|
||||
# # using kappa, for a collimated incoming beam
|
||||
# pass
|
||||
lamda_lz = (self.grid.lz().T*lamda_l[:-1]).T
|
||||
alphaF_lz = self.grid.lz()*alphaF_z
|
||||
@@ -438,7 +442,7 @@ class AmorReduction:
|
||||
if self.monitor > 1e-6 :
|
||||
ref_lz *= self.normMonitor / self.monitor
|
||||
else:
|
||||
logging.warning(' too small monitor value for normalisation -> ignoring monitors')
|
||||
logging.info(' too small monitor value for normalisation -> ignoring monitors')
|
||||
err_lz = ref_lz * np.sqrt( 1/(int_lz+.1) + 1/norm_lz )
|
||||
|
||||
# TODO: allow for non-ideal Delta lambda / lambda (rather than 2.2%)
|
||||
|
||||
Reference in New Issue
Block a user