Created
October 1, 2024 04:06
-
-
Save akirayou/16362e28f946dd0c75b21c9933329f15 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from mocca2.classes import Data2D | |
import re | |
def parse_labsolutions(file, encoding="ShiftJIS"): | |
"""Reads the .txt Lab Solutions file""" | |
f = open(file, "r", encoding=encoding) | |
for line in f: | |
if "[PDA 3D" == line[:7]: | |
break | |
for line in f: | |
if "R.Time" == line[:6]: | |
break | |
waveLen = np.array([float(s) for s in re.split(r'[\t,]',f.readline())[1:] ]) | |
N = len(waveLen) | |
rt = [] | |
inten = [] | |
for line in f: | |
d = re.split(r'[\t,]',line) | |
if len(d) != N + 1: | |
break | |
d = [float(s) for s in d] | |
rt.append(d[0]) | |
inten.append(d[1:]) | |
rt = np.array(rt) | |
inten = np.array(inten) | |
return Data2D(rt, waveLen/100, inten.T/100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment