Ejemplo n.º 1
0
 def test_saving_files(self):
     # Test for saving XYE data file.
     HB2AReduce_ws = HB2AReduce(
         'HB2A_exp0660_scan0146.dat',
         Vanadium='HB2A_exp0644_scan0018.dat',
         IndividualDetectors=True,
         OutputFormat='XYE',
         OutputDirectory=self._default_save_directory,
     )
     self.assertTrue(HB2AReduce_ws)
     self.assertTrue(
         os.path.exists(
             os.path.join(self._default_save_directory,
                          f"{HB2AReduce_ws}.dat")))
     # Test for saving GSAS data file.
     HB2AReduce_ws = HB2AReduce(
         'HB2A_exp0735_scan0016.dat',
         Vanadium='HB2A_exp0644_scan0018.dat',
         IndividualDetectors=True,
         OutputFormat='GSAS',
         OutputDirectory=self._default_save_directory,
     )
     self.assertTrue(HB2AReduce_ws)
     self.assertTrue(
         os.path.exists(
             os.path.join(self._default_save_directory,
                          f"{HB2AReduce_ws}.gss")))
     HB2AReduce_ws.delete()
Ejemplo n.º 2
0
    def test_new_convention(self):
        HB2AReduce_ws_old = HB2AReduce('HB2A_exp0666_scan0024.dat',
                                       IndividualDetectors=True,
                                       SaveData=False)
        HB2AReduce_ws_old.delete()

        HB2AReduce_ws_new = HB2AReduce('HB2A_exp0742_scan0028.dat',
                                       IndividualDetectors=True,
                                       SaveData=False)
        HB2AReduce_ws_new.delete()
Ejemplo n.º 3
0
 def test_NotBinned(self):
     HB2AReduce_ws = HB2AReduce('HB2A_exp0666_scan0024.dat', BinData=False)
     self.assertTrue(HB2AReduce_ws)
     self.assertEquals(HB2AReduce_ws.getNumberHistograms(), 1)
     self.assertEquals(HB2AReduce_ws.blocksize(), 5324)
     self.assertEquals(np.argmax(HB2AReduce_ws.extractY()), 4887)
     self.assertAlmostEquals(np.max(HB2AReduce_ws.extractY()), 2.789331777)
     HB2AReduce_ws.delete()
Ejemplo n.º 4
0
 def test_Binned(self):
     HB2AReduce_ws = HB2AReduce('HB2A_exp0666_scan0024.dat', SaveData=False)
     self.assertTrue(HB2AReduce_ws)
     self.assertEqual(HB2AReduce_ws.getNumberHistograms(), 1)
     self.assertEqual(HB2AReduce_ws.blocksize(), 2439)
     self.assertEqual(np.argmax(HB2AReduce_ws.extractY()), 2203)
     self.assertAlmostEquals(np.max(HB2AReduce_ws.extractY()), 2.788603131)
     HB2AReduce_ws.delete()
Ejemplo n.º 5
0
    def test_new_convention(self):
        HB2AReduce_ws_old = HB2AReduce('HB2A_exp0666_scan0024.dat',
                                       IndividualDetectors=True,
                                       SaveData=False)
        norm_time_wsk = mtd[HB2AReduce_ws_old.name() + "_norm_time"]
        self.assertTrue(norm_time_wsk)

        HB2AReduce_ws_old.delete()
        norm_time_wsk.delete()

        HB2AReduce_ws_new = HB2AReduce('HB2A_exp0742_scan0028.dat',
                                       IndividualDetectors=True,
                                       SaveData=False)
        norm_time_wsk = mtd[HB2AReduce_ws_new.name() + "_norm_time"]
        self.assertTrue(norm_time_wsk)

        HB2AReduce_ws_new.delete()
        norm_time_wsk.delete()
Ejemplo n.º 6
0
    def test_new_new_convention(self):
        HB2AReduce_ws = HB2AReduce('HB2A_exp0755_scan0027.dat',
                                   IndividualDetectors=True,
                                   SaveData=False)
        norm_time_wsk = mtd[HB2AReduce_ws.name() + "_norm_time"]
        self.assertTrue(norm_time_wsk)

        HB2AReduce_ws.delete()
        norm_time_wsk.delete()
Ejemplo n.º 7
0
 def test_IndividualDetectors(self):
     HB2AReduce_ws = HB2AReduce('HB2A_exp0666_scan0024.dat',
                                IndividualDetectors=True)
     self.assertTrue(HB2AReduce_ws)
     self.assertEquals(HB2AReduce_ws.getNumberHistograms(), 44)
     self.assertEquals(HB2AReduce_ws.blocksize(), 121)
     self.assertEquals(np.argmax(HB2AReduce_ws.extractY()), 4887)
     self.assertAlmostEquals(np.max(HB2AReduce_ws.extractY()), 2.789331777)
     HB2AReduce_ws.delete()
Ejemplo n.º 8
0
 def test_Vanadium(self):
     HB2AReduce_ws = HB2AReduce('HB2A_exp0666_scan0024.dat',
                                Vanadium='HB2A_exp0644_scan0018.dat')
     self.assertTrue(HB2AReduce_ws)
     self.assertEquals(HB2AReduce_ws.getNumberHistograms(), 1)
     self.assertEquals(HB2AReduce_ws.blocksize(), 2439)
     self.assertEquals(np.argmax(HB2AReduce_ws.extractY()), 2203)
     self.assertAlmostEquals(np.max(HB2AReduce_ws.extractY()), 78.50058933)
     HB2AReduce_ws.delete()
Ejemplo n.º 9
0
 def test_ExcludeDetectors(self):
     HB2AReduce_ws = HB2AReduce('HB2A_exp0666_scan0024.dat',
                                ExcludeDetectors='1-20,40-42')
     self.assertTrue(HB2AReduce_ws)
     self.assertEquals(HB2AReduce_ws.getNumberHistograms(), 1)
     self.assertEquals(HB2AReduce_ws.blocksize(), 1360)
     self.assertEquals(np.argmax(HB2AReduce_ws.extractY()), 283)
     self.assertAlmostEquals(np.max(HB2AReduce_ws.extractY()), 0.826432392)
     HB2AReduce_ws.delete()
Ejemplo n.º 10
0
 def test_TwoFiles(self):
     HB2AReduce_ws = HB2AReduce(
         'HB2A_exp0666_scan0024.dat,HB2A_exp0666_scan0025.dat')
     self.assertTrue(HB2AReduce_ws)
     self.assertEquals(HB2AReduce_ws.getNumberHistograms(), 1)
     self.assertEquals(HB2AReduce_ws.blocksize(), 2439)
     self.assertEquals(np.argmax(HB2AReduce_ws.extractY()), 2203)
     self.assertAlmostEquals(np.max(HB2AReduce_ws.extractY()), 2.780263137)
     HB2AReduce_ws.delete()
Ejemplo n.º 11
0
 def test_anode_vs_temp(self):
     HB2AReduce_ws = HB2AReduce('HB2A_exp0660_scan0146.dat',
                                Vanadium='HB2A_exp0644_scan0018.dat',
                                IndividualDetectors=True)
     self.assertTrue(HB2AReduce_ws)
     self.assertEquals(HB2AReduce_ws.getNumberHistograms(), 44)
     self.assertEquals(HB2AReduce_ws.blocksize(), 56)
     self.assertEquals(np.argmax(HB2AReduce_ws.readY(7)), 2)
     self.assertAlmostEquals(np.max(HB2AReduce_ws.readY(7)), 2.13258433)
     HB2AReduce_ws.delete()
Ejemplo n.º 12
0
 def test_Binned(self):
     HB2AReduce_ws = HB2AReduce('HB2A_exp0666_scan0024.dat', SaveData=False)
     self.assertTrue(HB2AReduce_ws)
     self.assertEqual(HB2AReduce_ws.getNumberHistograms(), 1)
     self.assertEqual(HB2AReduce_ws.blocksize(), 2439)
     self.assertEqual(np.argmax(HB2AReduce_ws.extractY()), 2203)
     self.assertAlmostEqual(np.max(HB2AReduce_ws.extractY()), 2.788603131)
     norm_time_wsk = mtd[HB2AReduce_ws.name() + "_norm_time"]
     self.assertTrue(norm_time_wsk)
     self.assertEqual(norm_time_wsk.getNumberHistograms(), 1)
     self.assertEqual(norm_time_wsk.blocksize(), 2439)
     self.assertEqual(np.argmax(norm_time_wsk.extractY()), 2203)
     self.assertAlmostEqual(np.max(norm_time_wsk.extractY()), 707.480233538)
     HB2AReduce_ws.delete()
     norm_time_wsk.delete()
Ejemplo n.º 13
0
 def test_NotBinned(self):
     HB2AReduce_ws = HB2AReduce('HB2A_exp0666_scan0024.dat', BinData=False, SaveData=False)
     self.assertTrue(HB2AReduce_ws)
     self.assertEqual(HB2AReduce_ws.getNumberHistograms(), 1)
     self.assertEqual(HB2AReduce_ws.blocksize(), 5324)
     self.assertEqual(np.argmax(HB2AReduce_ws.extractY()), 4887)
     self.assertAlmostEqual(np.max(HB2AReduce_ws.extractY()), 2.789331777)
     norm_time_wsk = mtd[HB2AReduce_ws.name() + "_norm_time"]
     self.assertTrue(norm_time_wsk)
     self.assertEqual(norm_time_wsk.getNumberHistograms(), 1)
     self.assertEqual(norm_time_wsk.blocksize(), 5324)
     self.assertEqual(np.argmax(norm_time_wsk.extractY()), 4819)
     self.assertAlmostEqual(np.max(norm_time_wsk.extractY()), 707.946308236)
     HB2AReduce_ws.delete()
     norm_time_wsk.delete()
Ejemplo n.º 14
0
 def test_TwoFiles(self):
     HB2AReduce_ws = HB2AReduce('HB2A_exp0666_scan0024.dat,HB2A_exp0666_scan0025.dat',
                                SaveData=False)
     self.assertTrue(HB2AReduce_ws)
     self.assertEqual(HB2AReduce_ws.getNumberHistograms(), 1)
     self.assertEqual(HB2AReduce_ws.blocksize(), 2439)
     self.assertEqual(np.argmax(HB2AReduce_ws.extractY()), 2203)
     self.assertAlmostEqual(np.max(HB2AReduce_ws.extractY()), 2.780263137)
     norm_time_wsk = mtd[HB2AReduce_ws.name() + "_norm_time"]
     self.assertTrue(norm_time_wsk)
     self.assertEqual(norm_time_wsk.getNumberHistograms(), 1)
     self.assertEqual(norm_time_wsk.blocksize(), 2439)
     self.assertEqual(np.argmax(norm_time_wsk.extractY()), 2203)
     self.assertAlmostEqual(np.max(norm_time_wsk.extractY()), 712.465597607)
     HB2AReduce_ws.delete()
     norm_time_wsk.delete()
Ejemplo n.º 15
0
 def test_Vanadium(self):
     HB2AReduce_ws = HB2AReduce('HB2A_exp0666_scan0024.dat',
                                Vanadium='HB2A_exp0644_scan0018.dat',
                                SaveData=False)
     self.assertTrue(HB2AReduce_ws)
     self.assertEqual(HB2AReduce_ws.getNumberHistograms(), 1)
     self.assertEqual(HB2AReduce_ws.blocksize(), 2439)
     self.assertEqual(np.argmax(HB2AReduce_ws.extractY()), 2203)
     self.assertAlmostEqual(np.max(HB2AReduce_ws.extractY()), 78.50058933)
     norm_time_wsk = mtd[HB2AReduce_ws.name() + "_norm_time"]
     self.assertTrue(norm_time_wsk)
     self.assertEqual(norm_time_wsk.getNumberHistograms(), 1)
     self.assertEqual(norm_time_wsk.blocksize(), 2439)
     self.assertEqual(np.argmax(norm_time_wsk.extractY()), 2203)
     self.assertAlmostEqual(np.max(norm_time_wsk.extractY()), 19915.92659908)
     HB2AReduce_ws.delete()
     norm_time_wsk.delete()
Ejemplo n.º 16
0
 def test_ExcludeDetectors(self):
     HB2AReduce_ws = HB2AReduce('HB2A_exp0666_scan0024.dat',
                                ExcludeDetectors='1-20,40-42',
                                SaveData=False)
     self.assertTrue(HB2AReduce_ws)
     self.assertEqual(HB2AReduce_ws.getNumberHistograms(), 1)
     self.assertEqual(HB2AReduce_ws.blocksize(), 1360)
     self.assertEqual(np.argmax(HB2AReduce_ws.extractY()), 283)
     self.assertAlmostEqual(np.max(HB2AReduce_ws.extractY()), 0.826432392)
     norm_time_wsk = mtd[HB2AReduce_ws.name() + "_norm_time"]
     self.assertTrue(norm_time_wsk)
     self.assertEqual(norm_time_wsk.getNumberHistograms(), 1)
     self.assertEqual(norm_time_wsk.blocksize(), 1360)
     self.assertEqual(np.argmax(norm_time_wsk.extractY()), 283)
     self.assertAlmostEqual(np.max(norm_time_wsk.extractY()), 209.011638786)
     HB2AReduce_ws.delete()
     norm_time_wsk.delete()
Ejemplo n.º 17
0
 def test_anode_vs_temp(self):
     HB2AReduce_ws = HB2AReduce('HB2A_exp0660_scan0146.dat',
                                Vanadium='HB2A_exp0644_scan0018.dat',
                                IndividualDetectors=True,
                                SaveData=False)
     self.assertTrue(HB2AReduce_ws)
     self.assertEqual(HB2AReduce_ws.getNumberHistograms(), 44)
     self.assertEqual(HB2AReduce_ws.blocksize(), 56)
     self.assertEqual(np.argmax(HB2AReduce_ws.readY(7)), 2)
     self.assertAlmostEqual(np.max(HB2AReduce_ws.readY(7)), 2.13258433)
     norm_time_wsk = mtd[HB2AReduce_ws.name() + "_norm_time"]
     self.assertTrue(norm_time_wsk)
     self.assertEqual(norm_time_wsk.getNumberHistograms(), 44)
     self.assertEqual(norm_time_wsk.blocksize(), 56)
     self.assertEqual(np.argmax(norm_time_wsk.readY(7)), 2)
     self.assertAlmostEqual(np.max(norm_time_wsk.readY(7)), 1195.31351784)
     HB2AReduce_ws.delete()
     norm_time_wsk.delete()
Ejemplo n.º 18
0
 def test_new_new_convention(self):
     HB2AReduce_ws = HB2AReduce('HB2A_exp0755_scan0027.dat',
                                IndividualDetectors=True,
                                SaveData=False)
     HB2AReduce_ws.delete()
Ejemplo n.º 19
0
import pyoncat
import client
import numpy as np
try:
    from postprocessing.publish_plot import publish_plot
except ImportError:
    from finddata.publish_plot import publish_plot

from mantid.simpleapi import HB2AReduce, SaveFocusedXYE, SavePlot1D, SaveAscii

filename = sys.argv[1]
name, ext = os.path.splitext(os.path.basename(filename))
output_file = name+"_autoreduced"+ext
outdir = sys.argv[2]

ws = HB2AReduce(filename, Scale=20000)

def_y = ws.getRun().getLogData('def_y').value
def_x = ws.getRun().getLogData('def_x').value

anode = None
if 'anode' in def_y:  # Plot anode intensity instead
    try:
        anode = int(def_y.replace('anode', ''))
    except ValueError:
        pass

if anode:  # Re-reduce data for anode plot
    ws = HB2AReduce(filename, IndividualDetectors=True, Scale=20000)
    SaveAscii(ws, Filename=os.path.join(outdir, output_file), SpectrumList=anode-1, Separator='Space', ColumnHeader=False, WriteSpectrumID=False)
    div = SavePlot1D(ws, OutputType='plotly', SpectraList=anode)
Ejemplo n.º 20
0
from mantid.simpleapi import HB2AReduce
import glob

failed = []
failed_msg = []

for filename in glob.iglob(
        '/HFIR/HB2A/IPTS-*/exp6[56]*/Datafiles/HB2A_exp*_scan????.dat'):
    try:
        ws = HB2AReduce(filename, OutputDirectory='/tmp')
    except Exception as e:
        failed.append(filename)
        failed_msg.append(e)

for a, b in zip(failed, failed_msg):
    print(a, b)
print(len(failed))
Ejemplo n.º 21
0
#!/usr/bin/env python2
import os
import sys

sys.path.insert(0, "/opt/mantidnightly/bin")
from mantid.simpleapi import HB2AReduce, SaveFocusedXYE

filename = sys.argv[1]
output_file = os.path.split(filename)[-1].replace('.dat', '.xye')
outdir = sys.argv[2]

ws = HB2AReduce(filename)
SaveFocusedXYE(ws,
               Filename=os.path.join(outdir, output_file),
               SplitFiles=False,
               IncludeHeader=False)
Ejemplo n.º 22
0
import pyoncat
import getpass
import numpy as np
try:
    from postprocessing.publish_plot import publish_plot
except ImportError:
    from finddata import publish_plot

sys.path.insert(0, "/opt/mantidnightly/bin")
from mantid.simpleapi import HB2AReduce, SaveFocusedXYE, SavePlot1D, SaveAscii

filename = sys.argv[1]
output_file = os.path.split(filename)[-1].replace('.dat', '.xye')
outdir = sys.argv[2]

ws = HB2AReduce(filename)

def_y = ws.getRun().getLogData('def_y').value
def_x = ws.getRun().getLogData('def_x').value

anode=None
if 'anode' in def_y: # Plot andoe intensity instead
    try:
        anode = int(def_y.replace('anode',''))
    except ValueError:
        pass

if anode: # Re-reduce data for anode plot
    ws = HB2AReduce(filename, IndividualDetectors=True)
    SaveAscii(ws, Filename=os.path.join(outdir, output_file), SpectrumList=anode-1, Separator='Space', ColumnHeader=False, WriteSpectrumID=False)
    div = SavePlot1D(ws, OutputType='plotly', SpectraList=anode)