-
Notifications
You must be signed in to change notification settings - Fork 26
/
decoder_gauss.py
79 lines (52 loc) · 2.24 KB
/
decoder_gauss.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import os
import logging
import pandas as pd
from easyvvuq.decoders import BaseDecoder
from easyvvuq import OutputType
__copyright__ = """
Copyright 2018 Robin A. Richardson, David W. Wright
This file is part of EasyVVUQ
EasyVVUQ is free software: you can redistribute it and/or modify
it under the terms of the Lesser GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
EasyVVUQ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Lesser GNU General Public License for more details.
You should have received a copy of the Lesser GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
__license__ = "LGPL"
logger = logging.Logger(__name__)
class GaussDecoder(BaseDecoder, decoder_name="gauss"):
def __init__(self, target_filename=None):
if target_filename is None:
msg = (
f"target_filename must be set for SimpleCSV. This should be"
f"the name of the output file this decoder acts on."
)
logging.error(msg)
raise Exception(msg)
self.output_type = OutputType('sample')
self.target_filename = target_filename
@staticmethod
def _get_output_path(run_info=None, outfile=None):
run_path = run_info['run_dir']
if not os.path.isdir(run_path):
raise RuntimeError(f"Run directory does not exist: {run_path}")
return os.path.join(run_path, outfile)
def sim_complete(self, run_info=None):
out_path = self._get_output_path(run_info, self.target_filename)
if not os.path.isfile(out_path):
return False
else:
return True
def parse_sim_output(self, run_info={}):
out_path = self._get_output_path(run_info, self.target_filename)
data = pd.read_csv(out_path, header=0, index_col=False)
return data
def get_restart_dict(self):
return {"target_filename": self.target_filename}
def element_version(self):
return "0.1"