def runAnalyzeCurrent20120406(): configurationFilepath = get_current_module_path(__file__, "../../pyMcGill.cfg") dataPath = getResultsMcGillPath( configurationFilepath, r"experimental\McGill\su8000\hdemers\20120406\current") filenames = ["20120406_4keV_30uA_H.txt", "20120406_4keV_30uA_N.txt"] for filename in filenames: filepath = os.path.join(dataPath, filename) logFile = LogFile.LogFile(filepath) logFile._read(filepath) plt.figure() basename, _extension = os.path.splitext(filename) plt.title(basename) x = logFile.times_s y = logFile.currents_nA plt.plot(x, y) plt.xlabel("Time (s)") plt.ylabel("Current (nA)") figureFilepath = os.path.join(dataPath, basename) for extension in ['.png', '.pdf']: plt.savefig(figureFilepath + extension)
def test_uniqueParameter(self): """ Tests for method `uniqueEtcCommand`. """ path = get_current_module_path(__file__, "../../../testdata/su8230") filename = "Ras_20150302_Emission.txt" filepath = os.path.join(path, filename) if not os.path.isfile(filepath): raise SkipTest emissionData = read_emission(filepath) parameters = uniqueParameter(emissionData, EMISSION_CURRENT) self.assertEqual(70, len(parameters)) parameters = uniqueParameter(emissionData, EMISSION_VEXT) self.assertEqual(20, len(parameters)) parameters = uniqueParameter(emissionData, EMISSION_IF) self.assertEqual(1, len(parameters)) parameters = uniqueParameter(emissionData, EMISSION_VS) self.assertEqual(1, len(parameters)) parameters = uniqueParameter(emissionData, EMISSION_VACC) self.assertEqual(28, len(parameters)) parameters = uniqueParameter(emissionData, EMISSION_VD) self.assertEqual(13, len(parameters))
def setUp(self): """ Setup method. """ unittest.TestCase.setUp(self) self.filepath = get_current_module_path(__file__, "../../../testData/su8230/log/SemLog.xml") if not os.path.isfile(self.filepath): raise SkipTest
def test_testFile(self): """ Tests for method `readFile`. """ self.assertTrue(os.path.isfile(self.filepathNotFull), self.filepathNotFull) filepathFull = get_current_module_path( __file__, "../../../testData/su8230/log/Sem065.log") self.assertTrue(os.path.isfile(filepathFull), filepathFull)
def setUp(self): """ Setup method. """ unittest.TestCase.setUp(self) self._dataPath = get_current_module_path(__file__, "../../testData/nanopico") if not os.path.isdir(self._dataPath): raise SkipTest
def test_read_etc(self): """ Tests for method `read_etc`. """ path = get_current_module_path(__file__, "../../../testdata/su8230") filename = "Ras_20150302_Etc.txt" filepath = os.path.join(path, filename) if not os.path.isfile(filepath): raise SkipTest etcData = read_etc(filepath) self.assertEqual(1207, len(etcData))
def _get20121111Data(): configurationFilepath = get_current_module_path(__file__, "../../pyMcGillOld.cfg") dataPath = getResultsMcGillPath(configurationFilepath, r"experimental\McGill\su8000\hdemers\BeamCurrents\FlashingTimeoutSetting") filename = "BeamCurrent_20121111.txt" filepath = os.path.join(dataPath, filename) logFile = LogFile.LogFile(filepath) logFile._read(filepath) x = np.array(logFile.times_s) y = np.array(logFile.currents_nA) return x, y
def _get20120428Data(): configurationFilepath = get_current_module_path(__file__, "../../pyMcGill.cfg") dataPath = getResultsMcGillPath(configurationFilepath, r"experimental\McGill\su8000\hdemers\20120428\beamCurrent") filename = "5h30AfterFlash_25keV.txt" filepath = os.path.join(dataPath, filename) logFile = LogFile.LogFile(filepath) logFile._read(filepath) x = np.array(logFile.times_s) y = np.array(logFile.currents_nA) return x, y
def setUp(self): """ Setup method. """ path = get_current_module_path(__file__, "../../../testdata/su8230") filename = "Ras_20150302_Etc.txt" self._filepath = os.path.join(path, filename) if not os.path.isfile(self._filepath): raise SkipTest self._etcData = read_etc(self._filepath) unittest.TestCase.setUp(self)
def runFlash(): from pyprobecurrent import get_current_module_path import os.path import matplotlib.pyplot as plt path = get_current_module_path(__file__, "../../../testdata/su8230") filename = "Ras_20150302_Etc.txt" filepath = os.path.join(path, filename) flashData = getFlash(filepath) indices = [] flashIntensities = [] emissionCurrents_uA = [] acceleratingVoltages_V = [] index = 0 for data in flashData: flash_parameters = FlashParameters(data[ETC_PARAMETERS]) flashIntensity = flash_parameters.flashIntensity emissionCurrent_uA = flash_parameters.emissionCurrent_uA acceleratingVoltage_V = flash_parameters.acceleratingVoltage_V if emissionCurrent_uA > 0.0: indices.append(index) emissionCurrents_uA.append(emissionCurrent_uA) flashIntensities.append(flashIntensity) acceleratingVoltages_V.append(acceleratingVoltage_V) index += 1 fig, ax_f = plt.subplots() ax_c = ax_f.twinx() ax_f.plot(indices, emissionCurrents_uA, 'o') ax_c.plot(indices, flashIntensities, 'or') plt.figure() plt.plot(indices, flashIntensities, '.') plt.figure() plt.plot(indices, emissionCurrents_uA, '.') plt.figure() plt.plot(indices, acceleratingVoltages_V, '.') plt.show()
def runTestFile(): # filepath = get_current_module_path(__file__, "../../../testData/su8230/log/Sem065.log") path = get_current_module_path(__file__, "../../../testData/su8230/log/") if os.path.isdir(path): logging.info("Path exist: %s", path) logFiles = LogFiles(path) logFiles.findLogFiles() logging.info("Number of log files: %i", logFiles.numberLogFiles) logFile = logFiles.readLastLogFile() if logFile is not None: logging.info("Number of lines: %i", logFile.numberLines) uniqueInterv = logFile.uniqueInterv() logging.info("Number of unique Interv: %i", len(uniqueInterv)) uniqueFI = logFile.uniqueFI() logging.info("Number of unique from instrument: %i", len(uniqueFI)) logging.info("Unique from instruments: %s", uniqueFI) uniqueTI = logFile.uniqueTI() logging.info("Number of unique to instrument: %i", len(uniqueTI)) logging.info("Unique to instruments: %s", uniqueTI) uniqueFITI = logFile.uniqueFITI() logging.info("Number of unique from/to instrument: %i", len(uniqueFITI)) logging.info("Unique from/to instruments:") for fi, ti in uniqueFITI: logging.debug(" : %s, %s", fi, ti) uniqueCodes = logFile.uniqueCodes() logging.info("Number of unique code: %i", len(uniqueCodes)) logging.info("Unique codes: %s", uniqueCodes) uniqueFITICode = logFile.uniqueFITICode() logging.info("Number of unique from/to instrument with code: %i", len(uniqueFITICode)) logging.info("Unique from/to instruments code:") for fi, ti, code in uniqueFITICode: logging.info(" : %s, %s, %s", fi, ti, code)
def run(): from pyprobecurrent import get_current_module_path import os.path import matplotlib.pyplot as plt path = get_current_module_path(__file__, "../../../testdata/su8230") filename = "Ras_20150302_Emission.txt" filepath = os.path.join(path, filename) emissionData = read_emission(filepath) indices = [] emissionCurrents_uA = [] extractionVoltages_V = [] acceleratingVoltages_V = [] index = 0 for data in emissionData: emissionCurrent_uA = float(data[EMISSION_CURRENT]) * 1.0e-1 extractionVoltage_V = float(data[EMISSION_VEXT]) acceleratingVoltage_V = float(data[EMISSION_VACC]) if emissionCurrent_uA > 0.0 and extractionVoltage_V > 0.0: indices.append(index) emissionCurrents_uA.append(emissionCurrent_uA) extractionVoltages_V.append(extractionVoltage_V) acceleratingVoltages_V.append(acceleratingVoltage_V) index += 1 fig, ax_f = plt.subplots() ax_c = ax_f.twinx() ax_f.plot(indices, emissionCurrents_uA, 'o') ax_c.plot(indices, extractionVoltages_V, 'or') ax_c.set_ylim(top=4000.0) plt.figure() plt.plot(acceleratingVoltages_V, extractionVoltages_V, '.') plt.ylim(ymax=4000.0) plt.figure() plt.plot(acceleratingVoltages_V, emissionCurrents_uA, '.') plt.show()
def analyzeAllBeamCurrentMeasurement(): folders = [] folders.append(r"experimental\McGill\su8000\hdemers\20120406\current") folders.append(r"experimental\McGill\su8000\hdemers\20120410") folders.append(r"experimental\McGill\su8000\hdemers\20120411") folders.append(r"experimental\McGill\su8000\hdemers\20120414") folders.append(r"experimental\McGill\su8000\hdemers\20120420") folders.append(r"experimental\McGill\su8000\hdemers\20120423") folders.append(r"experimental\McGill\su8000\hdemers\20120424") folders.append(r"experimental\McGill\su8000\hdemers\20120427") folders.append(r"experimental\McGill\su8000\hdemers\20120428\beamCurrent") for folder in folders: configurationFilepath = get_current_module_path(__file__, "../../pyMcGill.cfg") dataPath = getResultsMcGillPath(configurationFilepath, folder) for filepath in findAllFiles(dataPath, "*.txt"): logging.info(filepath) _createFigures(filepath)
def runAnalyzeCurrent(): xA, yA = _get20120420Data() xB, yB = _get20120411Data() xC, yC = _get20120414Data() xD, yD = _get20120428Data() # inverse current sign yA *= -1 yB *= -1 yC *= -1 yD *= -1 # scale #yB -= 3.45 plt.figure() plt.plot(xA, yA, label='Right after flash') plt.plot(xB, yB, label='2h after flash') plt.plot(xC, yC, label='FE bombardment + 4:30h after flash') plt.plot(xD, yD, label='5:30h after flash') plt.xlabel("Time (s)") plt.ylabel("Current (nA)") plt.legend(loc='best') xMax_s = 16*60.0*60.0 xMin_s = min(xA[0], xB[0], xC[0]) plt.xlim((xMin_s, xMax_s)) ax2 = plt.gca().twiny() ax2.set_xlim((xMin_s/60.0/60.0, xMax_s/60.0/60.0)) ax2.set_xlabel("Time (h)") configurationFilepath = get_current_module_path(__file__, "../../pyMcGill.cfg") graphicPath = getLabbookMcGillPath(configurationFilepath, "graphics/beamCurrent"); basename = "GraphicBeamCurrent" figureFilepath = os.path.join(graphicPath, basename) for extension in ['.png', '.pdf']: plt.savefig(figureFilepath+extension) headers = ["Time (s)", 'Right after flash', '2h after flash', 'FE bombardment + 4:30h after flash', '5:30h after flash']
def run(): import os.path import matplotlib.pyplot as plt dataPath = get_current_module_path(__file__, "../../testData/nanopico") #filepath = os.path.join(dataPath, "testCurrent_10s.txt") filepath = os.path.join(dataPath, "testCurrent_1s.txt") #filepath = os.path.join(dataPath, "testCurrent.txt") logFile = LogFile(filepath) logFile._read(filepath) plt.figure() x = logFile.times_s y = logFile.currents_nA plt.plot(x, y) plt.xlabel("Time (s)") plt.ylabel("Current (nA)") plt.show()
def runAnalyzeCurrent(): xA, yA = _get20140127Data() xB, yB = _get20140128Data() # inverse current sign yA *= -1 yB *= -1 # scale #yB -= 3.45 plt.figure() xA += 5.47*60.0*60.0 #plt.plot(xA, yA, label='End of the day') plt.plot(xB, yB, label='Right after flashing') plt.xlabel("Time (s)") plt.ylabel("Current (nA)") #plt.legend(loc='best') xMax_s = 12.0*60.0*60.0 xMin_s = min(xA[0], xB[0]) plt.xlim((xMin_s, xMax_s)) plt.ylim(ymax=2.5) ax2 = plt.gca().twiny() ax2.set_xlim((xMin_s/60.0/60.0, xMax_s/60.0/60.0)) ax2.set_xlabel("Time (h)") configurationFilepath = get_current_module_path(__file__, "../../pyMcGill.cfg") graphicPath = getLabbookMcGillPath(configurationFilepath, "graphics/beamCurrent"); basename = "GraphicBeamCurrentSU8230" figureFilepath = os.path.join(graphicPath, basename) for extension in ['.png', '.pdf']: plt.savefig(figureFilepath+extension)
def runAnalyzeFlashingTime(): xA, yA = _get20121110Data() # inverse current sign yA *= -1 # scale #yB -= 3.45 plt.figure() plt.plot(xA, yA, label='Flash time of 12h') plt.xlabel("Time (s)") plt.ylabel("Current (nA)") plt.legend(loc='best') xMax_s = 20*60.0*60.0 xMin_s = xA[0] plt.xlim((xMin_s, xMax_s)) ax2 = plt.gca().twiny() ax2.set_xlim((xMin_s/60.0/60.0, xMax_s/60.0/60.0)) ax2.set_xlabel("Time (h)") configurationFilepath = get_current_module_path(__file__, "../../pyMcGillOld.cfg") graphicPath = getLabbookMcGillPath(configurationFilepath, "graphics/beamCurrent"); basename = "GraphicBeamCurrent_FlashTime12h" figureFilepath = os.path.join(graphicPath, basename) for extension in ['.pdf']: plt.savefig(figureFilepath+extension) xA, yA = _get20121111Data() # inverse current sign yA *= -1 # scale #yB -= 3.45 plt.figure() plt.plot(xA, yA, label='Flash time of 16h') plt.xlabel("Time (s)") plt.ylabel("Current (nA)") plt.legend(loc='best') xMax_s = 20*60.0*60.0 xMin_s = xA[0] plt.xlim((xMin_s, xMax_s)) ax2 = plt.gca().twiny() ax2.set_xlim((xMin_s/60.0/60.0, xMax_s/60.0/60.0)) ax2.set_xlabel("Time (h)") configurationFilepath = get_current_module_path(__file__, "../../pyMcGillOld.cfg") graphicPath = getLabbookMcGillPath(configurationFilepath, "graphics/beamCurrent"); basename = "GraphicBeamCurrent_FlashTime16h" figureFilepath = os.path.join(graphicPath, basename) for extension in ['.pdf']: plt.savefig(figureFilepath+extension)