forked from AIF-development-team/adsorptioninformationformat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
raw2aif_gui.py
87 lines (72 loc) · 3.03 KB
/
raw2aif_gui.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
80
81
82
83
84
85
86
87
# -*- coding: utf-8 -*-
"""GUI for Converting Raw (format agnostic) files to AIF"""
# pylint: disable-msg=invalid-name # to allow non-conforming variable names
import os
from gooey import Gooey, GooeyParser # pylint: disable-msg=import-error
from raw2aif import makeAIF, parse
def convert(filename, material_id, filetype):
"""Wrapper for converting Raw to AIF"""
data_meta, data_ads, data_des = parse(filetype, filename)
outputfilename = os.path.splitext(filename)[0] + '.aif'
print(f'Writing output to {outputfilename}')
makeAIF(data_meta, data_ads, data_des, material_id, filename)
@Gooey(required_cols=1,
optional_cols=1,
default_size=(300, 675),
menu=[{
'name':
'Help',
'items': [{
'type': 'AboutDialog',
'menuTitle': 'About',
'name': 'RAW to AIF Converter',
'description':
'A universal file format for gas adsorption experiments',
'version': '0.0.5',
'copyright': '2021',
'website':
'https://github.com/jackevansadl/adsorptioninformationfile',
'developer': '@jackevansadl, GUI + Compilation by @renkoh',
'license': 'MIT License'
}]
}])
def main():
"""Main GUI Loop for Raw to AIF Converter"""
parser = GooeyParser(description='raw2aif converter')
group = parser.add_argument_group()
group.add_argument('filename', widget='FileChooser')
group.add_argument('material_id')
input_type = group.add_mutually_exclusive_group(required=True,
gooey_options={
'initial_selection': 0,
'title': 'filetype'
})
input_type.add_argument('-quantachrome',
metavar='Quantachrome (.txt)',
action='store_true')
input_type.add_argument('-belsorp-max',
metavar='BELSORP-max (.dat)',
action='store_true')
input_type.add_argument('-belsorp-csv',
metavar='BEL-csv (.csv)',
action='store_true')
input_type.add_argument('-belsorp-csv-JIS',
metavar='BEL-csv JIS encoding (.csv)',
action='store_true')
input_type.add_argument('-micromeritics',
metavar='Micromeritics (.xls)',
action='store_true')
args = parser.parse_args()
filetype = None
if args.quantachrome:
filetype = 'quantachrome'
elif args.belsorp_max:
filetype = 'BELSORP-max'
elif args.belsorp_csv:
filetype = 'BEL-csv'
elif args.belsorp_csv_JIS:
filetype = 'BEL-csv_JIS'
elif args.micromeritics:
filetype = 'micromeritics'
convert(args.filename, args.material_id, filetype)
main()