12
12
import math
13
13
14
14
print ("*****************************" )
15
- print ("OpenWorm Master Script" )
15
+ print (" OpenWorm Master Script" )
16
16
print ("*****************************" )
17
17
print ("" )
18
- print (
19
- "This script attempts to run a full pass through the OpenWorm scientific libraries."
20
- )
18
+ print ("This script attempts to run a full pass through the OpenWorm software stack." )
21
19
print (
22
20
"This depends on several other repositories being loaded to work and presumes it is running in a preloaded Docker instance."
23
21
)
24
22
print ("It will report out where steps are missing." )
25
23
print ("Eventually all the steps will be filled in." )
26
24
print ("" )
27
25
28
- print ("****************************" )
29
- print ("Step 1: Rebuild c302 from the latest owmeta" )
30
- print ("****************************" )
31
- print ("Not yet implemented. See https://github.com/openworm/c302/issues/10" )
32
-
33
26
34
27
print ("****************************" )
35
- print ("Step 2: Execute unit tests via the c302 simulation framework" )
36
- print ("****************************" )
37
- """
38
- from runAndPlot import run_c302
39
- orig_display_var = None
40
- if os.environ.has_key('DISPLAY'):
41
- orig_display_var = os.environ['DISPLAY']
42
- del os.environ['DISPLAY'] # https://www.neuron.yale.edu/phpBB/viewtopic.php?f=6&t=1603
43
-
44
- run_c302(DEFAULTS['reference'],
45
- DEFAULTS['c302params'],
46
- '',
47
- DEFAULTS['duration'],
48
- DEFAULTS['dt'],
49
- 'jNeuroML_NEURON',
50
- data_reader=DEFAULTS['datareader'],
51
- save=True,
52
- show_plot_already=False,
53
- target_directory=os.path.join(os.environ['C302_HOME'], 'examples'),
54
- save_fig_to='tmp_images')
55
- prev_dir = os.getcwd()
56
- os.chdir(DEFAULTS['outDir'])
57
- try:
58
- os.mkdir('c302_out')
59
- except OSError as e:
60
- if e.errno != errno.EEXIST:
61
- raise
62
- src_files = os.listdir(os.path.join(os.environ['C302_HOME'], 'examples', 'tmp_images'))
63
- for file_name in src_files:
64
- full_file_name = os.path.join(os.environ['C302_HOME'], 'examples', 'tmp_images', file_name)
65
- print("COPY %s" % full_file_name)
66
- if (os.path.isfile(full_file_name)):
67
- shutil.copy2(full_file_name, 'c302_out')
68
- shutil.rmtree(os.path.join(os.environ['C302_HOME'], 'examples', 'tmp_images'))
69
- os.chdir(prev_dir)
70
- if orig_display_var:
71
- os.environ['DISPLAY'] = orig_display_var
72
- """
73
-
74
- print ("****************************" )
75
- print ("Step 3: Run c302 + Sibernetic in the same loop." )
28
+ print (" Step 1: Run c302 + Sibernetic in the same loop." )
76
29
print ("****************************" )
77
30
78
31
OW_OUT_DIR = os .environ ["OW_OUT_DIR" ]
@@ -131,10 +84,11 @@ def execute_with_realtime_output(command, directory, env=None):
131
84
sim_duration = float (os .environ ["DURATION" ])
132
85
133
86
noc302 = False
134
- if "NOC302" in os .environ :
135
- noc302 = bool (os .environ ["NOC302" ])
87
+ if "CONFIGURATION" in os .environ :
88
+ configuration = os .environ ["CONFIGURATION" ]
89
+ noc302 = "worm" not in configuration
136
90
137
- DEFAULTS = {
91
+ PARAMETERS = {
138
92
"duration" : sim_duration ,
139
93
"dt" : 0.005 ,
140
94
"dtNrn" : 0.05 ,
@@ -143,7 +97,7 @@ def execute_with_realtime_output(command, directory, env=None):
143
97
"c302params" : "C2" ,
144
98
"verbose" : False ,
145
99
"device" : "CPU" ,
146
- "configuration" : "worm_crawl_half_resolution" ,
100
+ "configuration" : configuration ,
147
101
"noc302" : noc302 ,
148
102
"datareader" : "UpdatedSpreadsheetDataReader2" ,
149
103
"outDir" : OW_OUT_DIR ,
@@ -161,6 +115,10 @@ def execute_with_realtime_output(command, directory, env=None):
161
115
) # TODO: terminate xvfb after recording
162
116
163
117
try :
118
+ print ("Starting Sibernetic simulation with parameters:" )
119
+ for p in PARAMETERS :
120
+ print (" %s: %s" % (p , PARAMETERS [p ]))
121
+
164
122
command = """python3 sibernetic_c302.py
165
123
-duration %s
166
124
-dt %s
@@ -172,23 +130,24 @@ def execute_with_realtime_output(command, directory, env=None):
172
130
-c302params %s
173
131
-datareader %s
174
132
-outDir %s""" % (
175
- DEFAULTS ["duration" ],
176
- DEFAULTS ["dt" ],
177
- DEFAULTS ["dtNrn" ],
178
- DEFAULTS ["logstep" ],
179
- DEFAULTS ["device" ],
180
- DEFAULTS ["configuration" ],
181
- DEFAULTS ["reference" ],
182
- DEFAULTS ["c302params" ],
183
- DEFAULTS ["datareader" ],
133
+ PARAMETERS ["duration" ],
134
+ PARAMETERS ["dt" ],
135
+ PARAMETERS ["dtNrn" ],
136
+ PARAMETERS ["logstep" ],
137
+ PARAMETERS ["device" ],
138
+ PARAMETERS ["configuration" ],
139
+ PARAMETERS ["reference" ],
140
+ PARAMETERS ["c302params" ],
141
+ PARAMETERS ["datareader" ],
184
142
"simulations" ,
185
143
)
186
- # DEFAULTS ['outDir'])
144
+ # PARAMETERS ['outDir'])
187
145
188
146
if noc302 :
189
147
command += " -noc302"
190
148
191
149
execute_with_realtime_output (command , os .environ ["SIBERNETIC_HOME" ], env = my_env )
150
+
192
151
except KeyboardInterrupt :
193
152
pass
194
153
@@ -198,7 +157,7 @@ def execute_with_realtime_output(command, directory, env=None):
198
157
for dirpath , dirnames , filenames in os .walk (sibernetic_sim_dir ):
199
158
for directory in dirnames :
200
159
if directory .startswith (
201
- "%s_%s" % (DEFAULTS ["c302params" ], DEFAULTS ["reference" ])
160
+ "%s_%s" % (PARAMETERS ["c302params" ], PARAMETERS ["reference" ])
202
161
):
203
162
all_subdirs .append (os .path .join (dirpath , directory ))
204
163
if directory .startswith ("Sibernetic" ):
@@ -238,10 +197,14 @@ def execute_with_realtime_output(command, directory, env=None):
238
197
shutil .move (report , new_sim_out )
239
198
240
199
# Copy position files etc.
241
- reports = glob .glob ('%s/position_buffer*' % latest_subdir )
242
- for report in reports :
243
- print ("Moving %s to %s" % (report , new_sim_out ))
244
- shutil .move (report , new_sim_out )
200
+ txt_files = glob .glob ("%s/*.txt" % latest_subdir )
201
+ for txt_file in txt_files :
202
+ print ("Moving %s to %s" % (txt_file , new_sim_out ))
203
+ shutil .move (txt_file , new_sim_out )
204
+ dat_files = glob .glob ("%s/*.dat" % latest_subdir )
205
+ for dat_file in dat_files :
206
+ print ("Moving %s to %s" % (dat_file , new_sim_out ))
207
+ shutil .move (dat_file , new_sim_out )
245
208
246
209
# Copy WCON file(s)
247
210
wcons = glob .glob ("%s/*.wcon" % latest_subdir )
@@ -273,7 +236,7 @@ def execute_with_realtime_output(command, directory, env=None):
273
236
)
274
237
275
238
command = "./Release/Sibernetic -f %s -l_from lpath=%s" % (
276
- DEFAULTS ["configuration" ],
239
+ PARAMETERS ["configuration" ],
277
240
latest_subdir ,
278
241
)
279
242
execute_with_realtime_output (command , os .environ ["SIBERNETIC_HOME" ], env = my_env )
@@ -356,7 +319,7 @@ def execute_with_realtime_output(command, directory, env=None):
356
319
357
320
358
321
print ("****************************" )
359
- print ("Step 4 : Run movement analysis" )
322
+ print (" Step 2 : Run movement analysis" )
360
323
print ("****************************" )
361
324
print ("Not yet implemented." )
362
325
print (
@@ -366,6 +329,6 @@ def execute_with_realtime_output(command, directory, env=None):
366
329
367
330
368
331
print ("****************************" )
369
- print ("Step 5 : Report on movement analysis fit to real worm videos" )
332
+ print (" Step 3 : Report on movement analysis fit to real worm videos" )
370
333
print ("****************************" )
371
334
print ("Not yet implemented." )
0 commit comments