proteus.TriangleFileUtils module

A collection of functions for reading and manipulating files so that I can try to read and write files in the format that Triangle expects

proteus.TriangleFileUtils.checkFileExists(filename)[source]
proteus.TriangleFileUtils.checkDataRead(dataArray, notReadVal)[source]

just go through data variable and check to make sure no values are equal to a special value to which data should have been initialized before it was read

returns boolean for ok or not

proteus.TriangleFileUtils.generateDefaultFormatPattern(recInfo, verbose=0)[source]

generate the initial line format for the Triangle data files based on the variable types specified in recInfo

This is in most cases a line that looks like
Nentries NumEntriesInRec0 NumEntriesInRec1 ….

In some cases (e.g., segments) the number of entries in a segment is omitted so that the default format doesn’t follow

proteus.TriangleFileUtils.findInitialFormatLine(lines, recInfo, formatpattern, commchar='#', nbase=0, verbose=0)[source]

find the line for the Triangle data files, specified in formatpattern.

Generate dataInfo dictionary that should specify dataInfo[‘nEntries’] : number of entries in the file dataInfo[‘recordSizes’] : size of each record per entry (can be 0) dataInfo[‘dataStartLineNumber’] : line where actual data entries may start dataInfo[‘recordLocationsPerLine’] : array of indeces saying where each record should start on a valid entry line record I is in entries recStart[I]:recStart[I+1]

proteus.TriangleFileUtils.readSimpleFormattedDataEntries(lines, recInfo, dataInfo, commchar='#', nbase=0, verbose=0)[source]

Try to read some data consisting of records stored in lines. The records are described in recInfo. The basic thing I need is the possible number of records per line and the type for each one.

I’ll go ahead and assume the file looks like a series of blank lines or commented lines and then the first meaningful line which gives the file format that should be the same as what I’m expecting …

Nentries NumEntriesInRec0 NumEntriesInRec1 ….

The regex format for this line is given in formatpattern.

After that comes Nentry values with the basic format

Entry Num. Rec0 Rec1 …

If NumEntriesInRecI is 0 then that record shouldn’t appear

returns
data : what was read ilast : index of last line read
proteus.TriangleFileUtils.readSimpleFormattedDataEntriesLastOptional(lines, recInfo, dataInfo, commchar='#', nbase=0, verbose=0)[source]

Try to read some data consisting of records stored in lines. The records are described in recInfo. The basic thing I need is the possible number of records per line and the type for each one.

This version allows the last data entry to be omitted so that I
can read the regions list. I need to generalize to allow a given entry to not be found I guess

I’ll go ahead and assume the file looks like a series of blank lines or commented lines and then the first meaningful line which gives the file format that should be the same as what I’m expecting …

Nentries NumEntriesInRec0 NumEntriesInRec1 ….

The regex format for this line is given in formatpattern.

After that comes Nentry values with the basic format

Entry Num. Rec0 Rec1 …

If NumEntriesInRecI is 0 then that record shouldn’t appear

returns
data : what was read ilast : index of last line read