-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConcentration.py
77 lines (60 loc) · 2.74 KB
/
Concentration.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
# pyBrown is a bundle of tools useful for Brownian and Stokesian dynamics
# simulations. Copyright (C) 2018 Tomasz Skora ([email protected])
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see https://www.gnu.org/licenses.
import click
import os
from pyBrown_tools.input_MSD import InputDataMSD
from pyBrown_tools.messaging import timestamp
from pyBrown_tools.trajectories import read_trajectories, add_auxiliary_data_multibeads, \
separate_center_of_mass, \
compute_cons, \
save_cons_to_file
#-------------------------------------------------------------------------------
@click.command()
@click.argument('input_filename',
type = click.Path( exists = True ))
def main(input_filename):
# here the list of keywords that are required for program to work is provided
required_keywords = ["labels", "input_xyz_template", "input_xyz_range", "chosen_box"]
# here the dict of keywords:default values is provided
# if given keyword is absent in JSON, it is added with respective default value
defaults = {"debug": False, "verbose": False,
"probing_frequency": 1, "min_time": 0.0,
"float_type": 32}
timestamp( 'Reading input from {} file', input_filename )
i = InputDataMSD(input_filename, required_keywords, defaults)
timestamp( 'Input data:\n{}', i )
timestamp( 'Reading trajectories' )
times, labels, auxiliary_data = read_trajectories(i.input_data)
add_auxiliary_data_multibeads( i.input_data, labels, auxiliary_data )
timestamp( 'Separating the center of mass movement' )
cm_labels = separate_center_of_mass( i.input_data, labels, auxiliary_data )
del labels
timestamp( 'Computing concentration in chosen box' )
cons = compute_cons( i.input_data, cm_labels, auxiliary_data )
del cm_labels
timestamp( 'Saving concentration to a file' )
save_cons_to_file(i.input_data, times, cons)
del times
del cons
timestamp( 'Deleting binary files' )
delete_binary_files(auxiliary_data)
#-------------------------------------------------------------------------------
def delete_binary_files(aux):
for key in aux.keys():
if "temp_filename" in key: os.remove(aux[key])
#-------------------------------------------------------------------------------
if __name__ == '__main__':
main()