Skip to content

Commit 9407bb5

Browse files
committed
Cleaned up syntax for nsdfview and for rdesigneur outputFileList specifiers.
1 parent 793eb68 commit 9407bb5

File tree

3 files changed

+48
-31
lines changed

3 files changed

+48
-31
lines changed

python/rdesigneur/moogul.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ def firstDraw( self, mergeDisplays, rotation=0.0, elev=0.0, azim=0.0, center = [
236236
self.doAutoscale()
237237
self.updateAxis()
238238
if self.viewIdx == (MooView.viewIdx-1):
239-
print( "last View", self.viewIdx)
240239
self.graph = vp.graph( title = "Graph", xtitle = "Time (s)", ytitle = " Units here", width = 700, fast=False, align = "left" )
241240
self.graphPlot1 = vp.gcurve( color = vp.color.blue, interval=-1)
242241
#self.graphPlot1.data = [[0,0], [1,1],[2,0],[3,4],[4,0], [5,1]]

python/rdesigneur/nsdfview.py

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,22 @@ def __init__( self, path ):
1616
self.path = str( path, "utf-8" )
1717

1818
class NsdfNeuronDataWrapper( moogul.DataWrapper ):
19-
def __init__( self, nsdf, neuronName, field ):
20-
if len( neuronName.split('/' ) ) != 2:
21-
print( "Error: neuronName needs '/' between base and rel parts: ", objname )
22-
assert( 0 )
19+
def __init__( self, nsdf, path, field ):
2320
moogul.DataWrapper.__init__( self, field )
2421
self.nsdf_ = nsdf
25-
self.neuronName_ = neuronName
26-
self.objBase_ = neuronName.split( '/' )[0]
27-
self.objRel_ = neuronName.split( '/' )[1]
22+
self.path_ = path
23+
spl = path.split( '/', 1 )
24+
self.objBase_ = "%elec"
25+
if len( spl ) > 1: # Some relative path tree.
26+
if spl[0] == "#":
27+
self.objRel_ = "##[ISA=CompartmentBase]%" + spl[1].replace( '/', '%' )
28+
else:
29+
self.objRel_ = spl[0] + "%" + spl[1].replace( '/', '%' )
30+
else:
31+
if spl[0] == "#":
32+
self.objRel_ = "##[ISA=CompartmentBase]"
33+
else:
34+
self.objRel_ = path # No slashes in the string.
2835
self.field_ = field
2936
self.simTime_ = 0.0
3037
self.idx_ = 0
@@ -80,9 +87,18 @@ def __init__( self, nsdf, objname, field ):
8087
assert( 0 )
8188
moogul.DataWrapper.__init__( self, field )
8289
self.nsdf_ = nsdf
83-
self.objBase_ = objname.split( '/' )[0]
84-
self.objRel_ = objname.split( '/' )[1]
85-
90+
spl = objname.split( '/', 1 )
91+
if len( spl ) > 1: # Can't deal with case where we have /chem as base but multiple levels below it.
92+
self.objBase_ = '%' + spl[0]
93+
self.objRel_ = spl[1].replace( '/', '%' )
94+
if self.objRel_[-1] != ']': # put in wildcard, if none provided
95+
self.objRel_ += '[]'
96+
else: # obj is direct child of /chem.
97+
self.objBase_ = "%chem"
98+
self.objRel_ = objname # doesn't have any slashes either.
99+
if self.objRel_[-1] != ']': # put in wildcard, if none provided
100+
self.objRel_ += '[]'
101+
86102
self.field_ = field
87103
self.simTime_ = 0.0
88104
self.idx_ = 0

python/rdesigneur/rdesigneur.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,24 +1021,23 @@ def _buildFileOutput( self ):
10211021
# Should check for duplication.
10221022
nsdfPath = fileBase.path + '/' + oname
10231023
if fentry.field in ["n", "conc"]:
1024-
if fentry.basepath[:4] == 'chem': #chem itself as compt
1025-
modelPath = self.modelPath
1024+
modelPath = self.modelPath + "/chem"
1025+
basePath = modelPath + "/" + fentry.path
1026+
if fentry.path[-1] in [']', '#']: # explicit index
1027+
pathStr = basePath + "." + fentry.field
10261028
else:
1027-
modelPath = self.modelPath + "/chem"
1028-
basePath = modelPath + "/" + fentry.basepath
1029-
pathStr = basePath + '/' + fentry.relpath + "[]." + fentry.field
1029+
pathStr = basePath + "[]." + fentry.field
10301030
else:
10311031
modelPath = self.modelPath + "/elec"
1032-
if fentry.basepath in ["elec", "#", "."]:
1033-
fentry.basepath = "##[ISA=CompartmentBase]"
1034-
elif fentry.basepath in ["spine", "SPINE", "head", "HEAD"]:
1035-
fentry.basepath = "#head#[ISA=CompartmentBase]"
1032+
spl = fentry.path.split('/')
1033+
if spl[0] == "#":
1034+
if len( spl ) == 1:
1035+
fentry.path = "##[ISA=CompartmentBase]"
1036+
else:
1037+
fentry.path = "##[ISA=CompartmentBase]" + fentry.path[1:]
10361038
# Otherwise we use basepath as is.
1037-
basePath = modelPath + "/" + fentry.basepath
1038-
if fentry.relpath in [".", "/", "./"]:
1039-
pathStr = basePath + "." + fentry.field
1040-
else:
1041-
pathStr = basePath + '/' + fentry.relpath + "." + fentry.field
1039+
basePath = modelPath + "/" + fentry.path
1040+
pathStr = basePath + "." + fentry.field
10421041
if not nsdfPath in nsdfBlocks:
10431042
self.nsdfPathList.append( nsdfPath )
10441043
nsdfBlocks[nsdfPath] = [pathStr]
@@ -1262,7 +1261,7 @@ def _buildStims( self ):
12621261
}
12631262
stims = moose.Neutral( self.modelPath + '/stims' )
12641263
k = 0
1265-
# rstim class has {elecpath, geom_expr, relpath, field, expr}
1264+
# rstim class has {fname, path, field, dt, flush_steps }
12661265
for i in self.stimList:
12671266
pair = i.elecpath + " " + i.geom_expr
12681267
dendCompts = self.elecid.compartmentsFromExpression[ pair ]
@@ -1965,10 +1964,12 @@ def convertArg( arg ):
19651964

19661965
class rfile:
19671966
def __init__( self,
1968-
fname = 'output.h5', basepath = 'elec', relpath = '.', field = 'Vm', dt = 1e-4, flushSteps = 200, start = 0.0, stop = -1.0, ftype = 'nsdf'):
1967+
fname = 'output.h5', path = 'soma', field = 'Vm', dt = 1e-4, flushSteps = 200, start = 0.0, stop = -1.0, ftype = 'nsdf'):
19691968
self.fname = fname
1970-
self.basepath = basepath
1971-
self.relpath = relpath
1969+
self.path = path
1970+
if not field in knownFieldsDefault:
1971+
print( "Error: Field '{}' not known.".format( field ) )
1972+
assert( 0 )
19721973
self.field = field
19731974
self.dt = dt
19741975
self.flushSteps = flushSteps
@@ -1977,11 +1978,12 @@ def __init__( self,
19771978
self.ftype = self.fname.split(".")[-1]
19781979
if not self.ftype in ["txt", "csv", "h5", "nsdf"]:
19791980
print( "Error: output file format for ", fname , " not known")
1981+
assert( 0 )
19801982
self.fname = self.fname.split("/")[-1]
19811983

19821984
def printme( self ):
1983-
print( "{0}, {1}, {2}, {3}, {4}".format(
1984-
self.fname, self.basepath, self.relpath, self.field, self.dt) )
1985+
print( "{0}, {1}, {2}, {3}".format(
1986+
self.fname, self.path, self.field, self.dt) )
19851987

19861988
@staticmethod
19871989
def convertArg( arg ):

0 commit comments

Comments
 (0)