Skip to content

Commit 1145f6d

Browse files
authored
Update quick_check.py
1 parent e46a0b8 commit 1145f6d

1 file changed

Lines changed: 29 additions & 29 deletions

File tree

quick_check.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ def bader_to_list_of_floats(bader):
8080

8181

8282
def to_db_with_bader_for_each_atom(db, atom_type='cation'):
83-
'''Returns Dataframe where each row corresponds to
84-
an atom with Bader charge and estimated oxidation state'''
83+
'''Returns Dataframe whrere each row correspons to
84+
an atom with bader charge and estimated oxidation state'''
8585
rows_list = []
8686
for db_i in db.index:
8787
if atom_type == 'cation':
@@ -127,30 +127,30 @@ def plot_os_vs_bader(db):
127127
label = str(os) + ' oxidation state, '+ str(number_of_atoms) +' atoms ')
128128

129129

130-
131-
# specify your path where to save your data
132-
path = 'E:\\work\\Results_aflow\\GitHub\\'
133-
# and desierd anion and cations
134-
cation = 'Fe'
135-
anion = 'F'
136-
137-
138-
db = get_links(cation, anion)
139-
#better to save links
140-
db.to_csv(path+cation+anion+'links'+'.csv')
141-
#uncomment if saved and comment upper one
142-
db = pd.read_csv(path+cation+anion+'links'+'.csv')
143-
db['oxidation_state'] = db.apply(lambda row: oxidation_state(row, cation, anion), axis=1)
144-
145-
#next string gets bader charges for each compound
146-
db[['cation_charges', 'anion_charges']] = db.apply(lambda row: bader_for_quick(row), axis=1).apply(pd.Series) # bader returns tuple. "apply" makes it data series
147-
148-
db = db.dropna(subset=['cation_charges'])
149-
db.to_csv(path+cation+anion+'.csv')
150-
151-
db_for_each = to_db_with_bader_for_each_atom(db, atom_type='cation')
152-
153-
fig, ax = plt.subplots()
154-
plot_os_vs_bader(db_for_each)
155-
plt.legend()
156-
plt.show()
130+
if __name__ == '__main__':
131+
# specify your path where to save your data
132+
path = 'E:\\work\\Results_aflow\\GitHub\\'
133+
# and desierd anion and cations
134+
cation = 'Fe'
135+
anion = 'F'
136+
137+
138+
db = get_links(cation, anion)
139+
#better to save links
140+
db.to_csv(path+cation+anion+'links'+'.csv')
141+
#uncomment if saved and comment upper one
142+
db = pd.read_csv(path+cation+anion+'links'+'.csv')
143+
db['oxidation_state'] = db.apply(lambda row: oxidation_state(row, cation, anion), axis=1)
144+
145+
# # next string gets bader charges for each compound
146+
db[['cation_charges', 'anion_charges']] = db.apply(lambda row: bader_for_quick(row), axis=1).apply(pd.Series) # bader returns tuple. "apply" makes it data series
147+
148+
db = db.dropna(subset=['cation_charges'])
149+
db.to_csv(path+cation+anion+'.csv')
150+
151+
db_for_each = to_db_with_bader_for_each_atom(db, atom_type='cation')
152+
153+
fig, ax = plt.subplots()
154+
plot_os_vs_bader(db_for_each)
155+
plt.legend()
156+
plt.show()

0 commit comments

Comments
 (0)