From 5a87fca3eb19005c668ec468310558fe8fe9ea3d Mon Sep 17 00:00:00 2001 From: Jared Swift Date: Fri, 21 Jan 2022 14:50:08 +0000 Subject: [PATCH 01/10] feat: set more default values for samples. --- src/gudrun_classes/sample.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/gudrun_classes/sample.py b/src/gudrun_classes/sample.py index 030b9d129..bfde464f4 100644 --- a/src/gudrun_classes/sample.py +++ b/src/gudrun_classes/sample.py @@ -107,35 +107,35 @@ def __init__(self): self.name = "" self.periodNumber = 1 self.dataFiles = DataFiles([], "SAMPLE") - self.forceCalculationOfCorrections = False + self.forceCalculationOfCorrections = True self.composition = Composition("SAMPLE") self.geometry = Geometry.SameAsBeam - self.upstreamThickness = 0.0 - self.downstreamThickness = 0.0 + self.upstreamThickness = 0.05 + self.downstreamThickness = 0.05 self.angleOfRotation = 0.0 - self.sampleWidth = 0.0 + self.sampleWidth = 5.0 self.innerRadius = 0.0 self.outerRadius = 0.0 self.sampleHeight = 0.0 - self.density = 0.0 + self.density = 0.1 self.densityUnits = UnitsOfDensity.ATOMIC self.tempForNormalisationPC = 0.0 self.totalCrossSectionSource = CrossSectionSource.TRANSMISSION self.crossSectionFilename = "" - self.sampleTweakFactor = 0.0 - self.topHatW = 0.0 - self.FTMode = FTModes.SUB_AVERAGE + self.sampleTweakFactor = 1.0 + self.topHatW = 3.0 + self.FTMode = FTModes.ABSOLUTE self.minRadFT = 0.0 self.grBroadening = 0.0 self.resonanceValues = [] - self.exponentialValues = [] - self.normalisationCorrectionFactor = 0.0 + self.exponentialValues = [0, 1] + self.normalisationCorrectionFactor = 1.0 self.fileSelfScattering = "" self.normaliseTo = NormalisationType.NOTHING - self.maxRadFT = 0.0 + self.maxRadFT = 20.0 self.outputUnits = OutputUnits.BARNS_ATOM_SR self.powerForBroadening = 0.0 - self.stepSize = 0.0 + self.stepSize = 0.03 self.runThisSample = True self.scatteringFraction = 0.0 self.attenuationCoefficient = 0.0 @@ -234,13 +234,13 @@ def __str__(self): bjoin( self.exponentialValues, " Exponential amplitude and decay [1/\u212b]\n", - sameseps=True, + sameseps=True,s suffix="0" ) ) selfScatteringLine = ( - f'{self.fileSelfScattering}{TAB}' + f'{self.fileSelfScattering if self.fileSelfScattering else "*"}{TAB}' f'Name of file containing self scattering' f' as a function of wavelength [\u212b]\n' ) From a4c96eba484f66bbdad4b779e2def76610e20e25 Mon Sep 17 00:00:00 2001 From: Jared Swift Date: Fri, 21 Jan 2022 14:51:40 +0000 Subject: [PATCH 02/10] fix: use degrees for angle of rotation units. --- src/gui/widgets/ui_files/mainWindow.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/ui_files/mainWindow.ui b/src/gui/widgets/ui_files/mainWindow.ui index 23da40b7b..269b4c3ff 100644 --- a/src/gui/widgets/ui_files/mainWindow.ui +++ b/src/gui/widgets/ui_files/mainWindow.ui @@ -52,7 +52,7 @@ - 1 + 0 @@ -3930,7 +3930,7 @@ - cm + ° From b607d54bc7cf04da10e7f41e92ab062fb3aef96b Mon Sep 17 00:00:00 2001 From: Jared Swift Date: Fri, 21 Jan 2022 14:53:34 +0000 Subject: [PATCH 03/10] fix: label background scattering fraction/attenuation coefficient correctly. --- src/gui/widgets/ui_files/mainWindow.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/ui_files/mainWindow.ui b/src/gui/widgets/ui_files/mainWindow.ui index 269b4c3ff..09d24a590 100644 --- a/src/gui/widgets/ui_files/mainWindow.ui +++ b/src/gui/widgets/ui_files/mainWindow.ui @@ -6221,7 +6221,7 @@ - Scattering Fraction + Background Scattering Fraction @@ -6248,7 +6248,7 @@ - Attenuation Coefficient + Background Attenuation Coefficient From 9cb98b1ce83c224f0d0c6ed954ea4cc980c4173a Mon Sep 17 00:00:00 2001 From: Jared Swift Date: Fri, 21 Jan 2022 14:54:34 +0000 Subject: [PATCH 04/10] feat: set more default values for containers. --- src/gudrun_classes/container.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gudrun_classes/container.py b/src/gudrun_classes/container.py index 3a617ebc0..542f53eeb 100644 --- a/src/gudrun_classes/container.py +++ b/src/gudrun_classes/container.py @@ -68,18 +68,18 @@ def __init__(self): self.dataFiles = DataFiles([], "CONTAINER") self.composition = Composition("CONTAINER") self.geometry = Geometry.SameAsBeam - self.upstreamThickness = 0.0 - self.downstreamThickness = 0.0 + self.upstreamThickness = 0.1 + self.downstreamThickness = 0.1 self.angleOfRotation = 0.0 - self.sampleWidth = 0.0 + self.sampleWidth = 5.0 self.innerRadius = 0.0 self.outerRadius = 0.0 self.sampleHeight = 0.0 - self.density = 0.0 + self.density = 0.1 self.densityUnits = UnitsOfDensity.ATOMIC self.totalCrossSectionSource = CrossSectionSource.TABLES self.crossSectionFilename = "" - self.tweakFactor = 0.0 + self.tweakFactor = 1.0 self.scatteringFraction = 0.0 self.attenuationCoefficient = 0.0 From 398d905527996dc826f8bc4b0febdb88d0a72cdc Mon Sep 17 00:00:00 2001 From: Jared Swift Date: Fri, 21 Jan 2022 14:56:21 +0000 Subject: [PATCH 05/10] feat: set more default values for beam. --- src/gudrun_classes/beam.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/gudrun_classes/beam.py b/src/gudrun_classes/beam.py index 7e9b00baf..08ef688e1 100644 --- a/src/gudrun_classes/beam.py +++ b/src/gudrun_classes/beam.py @@ -63,14 +63,14 @@ def __init__(self): self.stepSizeMS = 0.0 self.noSlices = 0 self.angularStepForCorrections = 0 - self.incidentBeamLeftEdge = 0.0 - self.incidentBeamRightEdge = 0.0 - self.incidentBeamTopEdge = 0.0 - self.incidentBeamBottomEdge = 0.0 - self.scatteredBeamLeftEdge = 0.0 - self.scatteredBeamRightEdge = 0.0 - self.scatteredBeamTopEdge = 0.0 - self.scatteredBeamBottomEdge = 0.0 + self.incidentBeamLeftEdge = -1.5 + self.incidentBeamRightEdge = 1.5 + self.incidentBeamTopEdge = 1.5 + self.incidentBeamBottomEdge = -1.5 + self.scatteredBeamLeftEdge = -2.0 + self.scatteredBeamRightEdge = 2.0 + self.scatteredBeamTopEdge = 2.0 + self.scatteredBeamBottomEdge = -2.0 self.filenameIncidentBeamSpectrumParams = "" self.overallBackgroundFactor = 0.0 self.sampleDependantBackgroundFactor = 0.0 From c265ea216388b97bf0312e7a95af5496d67e6cf3 Mon Sep 17 00:00:00 2001 From: Jared Swift Date: Tue, 25 Jan 2022 17:02:25 +0000 Subject: [PATCH 06/10] refactor: PEP8 --- src/gudrun_classes/sample.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gudrun_classes/sample.py b/src/gudrun_classes/sample.py index bfde464f4..7488357cd 100644 --- a/src/gudrun_classes/sample.py +++ b/src/gudrun_classes/sample.py @@ -234,13 +234,18 @@ def __str__(self): bjoin( self.exponentialValues, " Exponential amplitude and decay [1/\u212b]\n", - sameseps=True,s + sameseps=True, suffix="0" ) ) + selfScatteringFile = ( + self.fileSelfScattering + if self.fileSelfScattering else "*" + ) + selfScatteringLine = ( - f'{self.fileSelfScattering if self.fileSelfScattering else "*"}{TAB}' + f'{selfScatteringFile}{TAB}' f'Name of file containing self scattering' f' as a function of wavelength [\u212b]\n' ) From 40facd89a02f23e4e2a7eb0cc438b4747f422a74 Mon Sep 17 00:00:00 2001 From: Jared Swift <87013792+jswift-stfc@users.noreply.github.com> Date: Wed, 26 Jan 2022 09:38:44 +0000 Subject: [PATCH 07/10] Chance default density for containers. Co-authored-by: Tristan Youngs --- src/gudrun_classes/container.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gudrun_classes/container.py b/src/gudrun_classes/container.py index 542f53eeb..a13ba8a2f 100644 --- a/src/gudrun_classes/container.py +++ b/src/gudrun_classes/container.py @@ -75,7 +75,7 @@ def __init__(self): self.innerRadius = 0.0 self.outerRadius = 0.0 self.sampleHeight = 0.0 - self.density = 0.1 + self.density = 0.0542 self.densityUnits = UnitsOfDensity.ATOMIC self.totalCrossSectionSource = CrossSectionSource.TABLES self.crossSectionFilename = "" From 89917bafb856acf3394d9911a55ef59c1b6fc78a Mon Sep 17 00:00:00 2001 From: jswift-stfc Date: Wed, 26 Jan 2022 10:52:30 +0000 Subject: [PATCH 08/10] feat: set default minRadFT. --- src/gudrun_classes/sample.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gudrun_classes/sample.py b/src/gudrun_classes/sample.py index 7488357cd..6516ecf4b 100644 --- a/src/gudrun_classes/sample.py +++ b/src/gudrun_classes/sample.py @@ -125,7 +125,7 @@ def __init__(self): self.sampleTweakFactor = 1.0 self.topHatW = 3.0 self.FTMode = FTModes.ABSOLUTE - self.minRadFT = 0.0 + self.minRadFT = 0.75 self.grBroadening = 0.0 self.resonanceValues = [] self.exponentialValues = [0, 1] From c75e3293db568dbdc638d8845bbab95f4ee6b402 Mon Sep 17 00:00:00 2001 From: jswift-stfc Date: Wed, 26 Jan 2022 12:45:57 +0000 Subject: [PATCH 09/10] refactor/fix: PEP8 and fix tests. --- src/gudrun_classes/gudrun_file.py | 3 ++- src/gudrun_classes/instrument.py | 2 -- src/gudrun_classes/sample.py | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gudrun_classes/gudrun_file.py b/src/gudrun_classes/gudrun_file.py index c65e4f490..d0571b7b4 100644 --- a/src/gudrun_classes/gudrun_file.py +++ b/src/gudrun_classes/gudrun_file.py @@ -741,7 +741,6 @@ def parseNormalisation(self): ) except Exception as e: - print(e) raise ParserException( "Whilst parsing Normalisation, an exception occured." " The input file is most likely of an incorrect format, " @@ -957,6 +956,8 @@ def parseSample(self): # If the marker line is encountered, # then the values has been parsed. line = self.getNextToken() + if not "to specify end of exponential parameter input" in line: + sample.exponentialValues = [] while "to specify end of exponential parameter input" not in line: sample.exponentialValues.append( tuple(extract_nums_from_string(line)) diff --git a/src/gudrun_classes/instrument.py b/src/gudrun_classes/instrument.py index 667f356b6..e966b544e 100644 --- a/src/gudrun_classes/instrument.py +++ b/src/gudrun_classes/instrument.py @@ -293,6 +293,4 @@ def __str__(self): f'{numifyBool(self.hardGroupEdges)}{TAB}' f'Hard group edges?' f'{nexusDefinitionLine}' - f'0{TAB}Number of iterations' - f'0{TAB}Tweak the tweak factor(s)?' ) diff --git a/src/gudrun_classes/sample.py b/src/gudrun_classes/sample.py index 6516ecf4b..5132163f0 100644 --- a/src/gudrun_classes/sample.py +++ b/src/gudrun_classes/sample.py @@ -128,7 +128,7 @@ def __init__(self): self.minRadFT = 0.75 self.grBroadening = 0.0 self.resonanceValues = [] - self.exponentialValues = [0, 1] + self.exponentialValues = [(0, 1)] self.normalisationCorrectionFactor = 1.0 self.fileSelfScattering = "" self.normaliseTo = NormalisationType.NOTHING From b3144984cc8528ef7c27938ef01e03bbe2b4ffb4 Mon Sep 17 00:00:00 2001 From: jswift-stfc Date: Wed, 26 Jan 2022 13:04:15 +0000 Subject: [PATCH 10/10] refactor: PEP8 --- src/gudrun_classes/gudrun_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gudrun_classes/gudrun_file.py b/src/gudrun_classes/gudrun_file.py index d0571b7b4..ff0538512 100644 --- a/src/gudrun_classes/gudrun_file.py +++ b/src/gudrun_classes/gudrun_file.py @@ -956,7 +956,7 @@ def parseSample(self): # If the marker line is encountered, # then the values has been parsed. line = self.getNextToken() - if not "to specify end of exponential parameter input" in line: + if "to specify end of exponential parameter input" not in line: sample.exponentialValues = [] while "to specify end of exponential parameter input" not in line: sample.exponentialValues.append(