def test_DataFile_plotA4(): plt.ioff() import matplotlib #matplotlib.use('Agg') fileName = os.path.join(dataPath, 'camea2018n000136.hdf') fileName2 = os.path.join(dataPath, 'camea2018n000136.nxs') file = DataFile(fileName) try: file.plotA4(binning=20) # Binning not found in data file assert False except AttributeError: assert True fig = file.plotA4(1) fig2 = file.plotA4() assertFile(fileName2) file2 = DataFile(fileName2) try: file2.plotA4(binning=20) # Binning not found in data file assert False except AttributeError: assert True file2.plotA4(binning=1) plt.close('all')
def test_DataFile(): try: DF = DataFile('/nope.txt') assert False except: assert True try: DF = DataFile(os.path.join(dataPath, 'CAMEA_Full.xml')) # Wrong file assert False except: assert True files = [ os.path.join(dataPath, 'camea2018n000137.hdf'), os.path.join(dataPath, 'camea2018n000137.nxs') ] DF1 = DataFile(files[0]) assertFile(files[1]) DF2 = DataFile(files[1]) s = str(DF2) sampleS = str(DF2.sample) print(str(DF1.sample)) print(str(DF2.sample)) assert (DF1.sample == DF2.sample)
def test_DataFile_ScanParameter(): files = [ os.path.join(dataPath, 'camea2018n000136.hdf'), os.path.join(dataPath, 'camea2018n000136.nxs') ] assertFile(files[1]) for file in files: dfile = DataFile(file) assert (dfile.scanParameters[0] == 'rotation_angle') assert (len(dfile.scanParameters) == len(dfile.scanUnits)) assert (len(dfile.scanParameters) == len(dfile.scanValues)) assert (len(dfile.scanParameters) == 1) assert (dfile.scanUnits[0] == 'degree')