Created
June 27, 2011 13:13
-
-
Save mattions/1048831 to your computer and use it in GitHub Desktop.
Easy way to get params from external file in the main script (and work with them)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Parameters file for simulation. | |
{ | |
"dt" : 0.025, # integration dt [ms] | |
"dict_ampa_s1" : | |
{"t_stim" : 0.130, # t_stim [s] | |
"numbers" : 4, # number | |
"delay" : 0.1, # delay [s] | |
"type" : "ampa" # , type | |
}, | |
"dict_ampa_s2" : | |
{"t_stim" : 0.230, # t_stim [s] | |
"numbers" : 3, # number | |
"delay" : 0.1, # delay [s] | |
"type" : "ampa" # , type | |
}, | |
'sec_to_rec' : ['all'], | |
"var_to_plot" : ['v','cai','cali','ica'], | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from sumatra.external.NeuroTools import parameters | |
if __name__ == "__main__": | |
if len(sys.argv) != 2: | |
print("No parameter file supplied. Abort.") | |
usage = 'python %s parameters_file.param' %__file__ | |
print usage | |
sys.exit() | |
parameter_file = sys.argv[1] | |
parameter_dict = parameters.ParameterSet(parameter_file) | |
parameter_dict # contains all the param. | |
parameter_dict['dt'] # value is 0.025 Python Float |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment