Commit 227e49b1 authored by Zolnierczuk, Piotr's avatar Zolnierczuk, Piotr
Browse files

bug fixes

- clarify nseplot help messages
- bugfix in echowriter (missing f-format)
- test fixture fix (timestamps)
parent c5c13ccb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -366,7 +366,7 @@ class EchoWriter(EchoScan):
                fd.write(f"phi =    {phi:g} \n")
                fd.write(f"psi =    {psi:g} \n")
                fd.write(f"q =      {qmin/ANGSTROM:g} /m ")
                fd.write( "( {qmin*sx/ANGSTROM:g}, {qmin*cx/ANGSTROM:g}, 0.0 ) \n")
                fd.write(f"( {qmin*sx/ANGSTROM:g}, {qmin*cx/ANGSTROM:g}, 0.0 ) \n")
                fd.write(f"hkl =    {qmin:g} ( {qmin*sx:g}, {qmin*cx:g}, 0.0 ) \n")
                fd.write(f"fouriertime ............:  {ftau:g} \n")
                fd.write(f"phaseangle sensitivities:  {phasesens:g}     0.000000 deg/a\n")
+2 −0
Original line number Diff line number Diff line
@@ -53,7 +53,9 @@ t --> nanoseconds
import numpy as np

from numpy import pi, cos, exp, sqrt, mgrid, atleast_1d, asarray, sum as npsum, where, expm1
#pylint: disable=no-name-in-module
from scipy.special   import erfc
#pylint: enable=no-name-in-module
from scipy.integrate import quad
from scipy.constants import (Boltzmann as k_B, angstrom as ANGSTROM)

+2 −2
Original line number Diff line number Diff line
@@ -3,8 +3,8 @@ PySEN revision module
"""
import sys
__version__  = "2.0"
__release__  = ".6a"
__date__     = "Aug 27, 2025"
__release__  = ".6"
__date__     = "Sep 2, 2025"

def version(full=False):
    "get pysen version number"
+8 −8
Original line number Diff line number Diff line
@@ -40,18 +40,18 @@ def arguments_common():
    verbose.add_argument('--verbose', '-v', dest='loglevel', action='count',
                        help='verbose output')
    verbose.add_argument('--quiet',   '-q', dest='loglevel', action='store_const', const=0,
                        help='suppress terminal output')
                        help='succinct output')
    return pars

def arguments_savefig():
def arguments_saveopt():
    "savefig arguments"
    pars = argparse.ArgumentParser(add_help=False)
    pars.set_defaults(savefile=None, savefig=None, outdir='.')
    # save figure/data options
    pars.add_argument('--output-file', '-o', dest='savefile', metavar='file',
                        help='save resulting data (if any) to a file.')
    pars.add_argument('--save-figure', '-S', dest='savefig', metavar='file',
                        help='save the output figure to a file and do not show it.')
    pars.add_argument('--output-data', '-o', dest='savefile', metavar='file',
                        help='write the resulting data (if any) to a file.')
    return pars

def arguments_selection_tof():
@@ -120,7 +120,7 @@ def add_echo_options(subparser, parents=None):
    pars.add_argument('--only-echo', dest='only_echo', action='store_true',
                       help='show only echo (no up/down)')
    pars.add_argument('--incoherent', '-I', dest='incoherent', action='store_true',
                       help='treat data as from incoherent scatterer')
                       help='assume incoherent scatterer')
    pars.add_argument('--absolute-y', '-Y', dest='absy', metavar='V', type=float,
                       help='use the same vertical scale for all pixels')
    pars.add_argument('--num-pix', '-N', dest='npix', metavar='N', type=int,
@@ -142,9 +142,9 @@ def add_atari_options(subparser, parents=None):
    pars.add_argument('--only-echo', dest='only_echo', action='store_true',
                      help='show only echo (no up/down)')
    pars.add_argument('--incoherent', '-I', dest='incoherent', action='store_true',
                      help='treat data as from incoherent scatterer')
                      help='assume incoherent scatterer')
    pars.add_argument('--phase0' , dest='phase0', type=float,
                      help='set inital phase for echo fitting (default=%(default)s)')
                      help='set inital phase for echo fitting (default it to read it from the data file)')

def add_old_xyz_options(subparser, parents=None):
    "xyz options"
@@ -367,7 +367,7 @@ def main():
                        version='%(prog)s pysen={version}'.format(version=version(full=True)))
    #
    pars_com  = arguments_common()
    pars_fig  = arguments_savefig()
    pars_fig  = arguments_saveopt()
    pars_tof  = arguments_selection_tof()
    pars_pix  = arguments_selection_pix()
    pars_zsc  = arguments_z_scale()
+13 −1
Original line number Diff line number Diff line
@@ -3,8 +3,8 @@ Python unit test cases for pysen.io.utils module
"""

import unittest
import os
import os.path
#import logging
import gzip
import bz2

@@ -17,6 +17,15 @@ class IOUtilsTestCase(unittest.TestCase):
    def setUp(self):
        "Setup"

        # make sure that nexus files have correct times
        file0 = os.path.join(TestDataDir,'NSE_15617.nxs.h5')
        atime = os.stat(file0).st_atime
        mtime = os.stat(file0).st_mtime
        for i, fname in enumerate(('NSE_15774.nxs.h5', 'NSE_16247.nxs.h5', 'NSE_16250.nxs.h5')):
            file1 = os.path.join(TestDataDir,fname)
            os.utime(file1, (atime, mtime+(i+1)*600))


    def tearDown(self):
        "Tear-down method"

@@ -101,6 +110,9 @@ class IOUtilsTestCase(unittest.TestCase):

        # both files exist
        # GO    out=15617 is older than inp=16247
        # make sure that this is true :)


        self.assertFalse(utils.is_file_newer( os.path.join(TestDataDir,'NSE_15617.nxs.h5'),
                                              os.path.join(TestDataDir,'NSE_16247.nxs.h5')))
        # STOP  out=16247 is newer than inp=15617