-
Notifications
You must be signed in to change notification settings - Fork 2
/
plotaif.py
36 lines (27 loc) · 1.19 KB
/
plotaif.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
# -*- coding: utf-8 -*-
"""Plot AIF from command line"""
import os
import sys
import matplotlib.pyplot as plt
import numpy as np
from gemmi import cif # pylint: disable-msg=no-name-in-module
def main():
"""Main plot function."""
filename = sys.argv[1]
aif = cif.read(filename)
block = aif.sole_block()
ads_press = np.array(block.find_loop('_adsorp_pressure'), dtype=float)
ads_amount = np.array(block.find_loop('_adsorp_amount'), dtype=float)
des_press = np.array(block.find_loop('_desorp_pressure'), dtype=float)
des_amount = np.array(block.find_loop('_desorp_amount'), dtype=float)
material_id = block.find_pair('_adsnt_material_id')[-1]
plt.plot(ads_press, ads_amount, 'o-', color='C0')
plt.plot(des_press, des_amount, 'o-', color='C0', markerfacecolor='white')
plt.ylabel('quantity adsorbed / ' + block.find_pair('_units_loading')[-1])
plt.xlabel('pressure / ' + block.find_pair('_units_pressure')[-1])
plt.title(
block.find_pair('_exptl_adsorptive')[-1] + ' on ' + material_id +
' at ' + block.find_pair('_exptl_temperature')[-1] + 'K')
plt.savefig(os.path.splitext(filename)[0] + '.pdf')
if __name__ == '__main__':
main()