Skip to content

Instantly share code, notes, and snippets.

@mattions
Created June 27, 2011 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattions/1048831 to your computer and use it in GitHub Desktop.
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)
# 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'],
}
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