Skip to content

Commit 333d225

Browse files
authored
Merge pull request #113 from danieletimpano/sas-plugin-mfuel-update
SAS plugin modifications to handle MFUEL output.
2 parents 8216c13 + 39c78d5 commit 333d225

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/watts/plugin_sas.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ class PluginSAS(PluginGeneric):
9494
List of command-line arguments used to call the executable
9595
conv_channel
9696
Path to CHANNELtoCSV utility executable
97+
conv_mfuel
98+
Path to MFUELPeaktoCSV utility executable
9799
conv_primar4
98100
Path to PRIMAR4toCSV utility executable
99101
@@ -118,6 +120,7 @@ def __init__(
118120
# Set other executables based on the main SAS executable
119121
suffix = executable.suffix
120122
self._conv_channel = executable.with_name(f"CHANNELtoCSV{suffix}")
123+
self._conv_mfuel = executable.with_name(f"MFUELtoCSV{suffix}")
121124
self._conv_primar4 = executable.with_name(f"PRIMAR4toCSV{suffix}")
122125

123126
@property
@@ -128,6 +131,10 @@ def conv_channel(self) -> Path:
128131
def conv_primar4(self) -> Path:
129132
return self._conv_primar4
130133

134+
@property
135+
def conv_mfuel(self) -> Path:
136+
return self._conv_mfuel
137+
131138
@conv_channel.setter
132139
def conv_channel(self, exe: PathLike):
133140
if shutil.which(exe) is None:
@@ -140,6 +147,12 @@ def conv_primar4(self, exe: PathLike):
140147
raise RuntimeError(f"PRIMAR4toCSV utility executable '{exe}' is missing.")
141148
self._conv_primar4 = Path(exe)
142149

150+
@conv_mfuel.setter
151+
def conv_mfuel(self, exe: PathLike):
152+
if shutil.which(exe) is None:
153+
raise RuntimeError(f"MFUELtoCSV utility executable '{exe}' is missing.")
154+
self._conv_mfuel = Path(exe)
155+
143156
@property
144157
def execute_command(self):
145158
return [str(self.executable), "-i", self.input_name, "-o", "out.txt"]
@@ -159,9 +172,10 @@ def postrun(self, params: Parameters, exec_info: ExecInfo) -> ResultsSAS:
159172
SAS results object
160173
"""
161174

162-
# Convert CHANNEl.dat and PRIMER4.dat to csv files
175+
# Convert CHANNEl.dat and PRIMAR4.dat and MFUELss.dat to csv files
163176
# using SAS utilities. Check if files exist because
164177
# they may not be outputted per user's choice.
178+
165179
if Path("CHANNEL.dat").is_file():
166180
with open("CHANNEL.dat", "r") as file_in, open("CHANNEL.csv", "w") as file_out:
167181
subprocess.run(str(self.conv_channel), stdin=file_in, stdout=file_out)
@@ -170,4 +184,8 @@ def postrun(self, params: Parameters, exec_info: ExecInfo) -> ResultsSAS:
170184
with open("PRIMAR4.dat", "r") as file_in, open("PRIMAR4.csv", "w") as file_out:
171185
subprocess.run(str(self.conv_primar4), stdin=file_in, stdout=file_out)
172186

187+
if Path("MFUELss_C000001.dat").is_file():
188+
with open("MFUELss_C000001.dat", "r") as file_in:
189+
subprocess.run(str(self.conv_mfuel), stdin=file_in)
190+
173191
return super().postrun(params, exec_info)

0 commit comments

Comments
 (0)