1 | """ |
---|
2 | naFile1010.py |
---|
3 | ============= |
---|
4 | |
---|
5 | Container module for NAFile1010 class. |
---|
6 | |
---|
7 | """ |
---|
8 | |
---|
9 | # Imports from python standard library |
---|
10 | |
---|
11 | # Imports from local package |
---|
12 | import naFile1001 |
---|
13 | from textParser import * |
---|
14 | |
---|
15 | class NAFile1010(naFile1001.NAFile1001): |
---|
16 | """ |
---|
17 | Class to read, write and interact with NASA Ames files conforming to the |
---|
18 | File Format Index (FFI) 1010. |
---|
19 | """ |
---|
20 | |
---|
21 | def readHeader(self): |
---|
22 | """ |
---|
23 | Reads FFI-specifc header section. |
---|
24 | """ |
---|
25 | self._readCommonHeader() |
---|
26 | self.DX=readItemsFromLine(self.file.readline(), self.NIV, float) |
---|
27 | self.XNAME=readItemsFromLines(self._readLines(self.NIV), self.NIV, str) |
---|
28 | self._readVariablesHeaderSection() |
---|
29 | self._readAuxVariablesHeaderSection() |
---|
30 | self._readComments() |
---|
31 | |
---|
32 | def _setupArrays(self): |
---|
33 | """ |
---|
34 | Sets up FFI-specific arrays to fill with data (lists of lists). |
---|
35 | """ |
---|
36 | self.X=[] |
---|
37 | self.V=[] |
---|
38 | self.A=[] |
---|
39 | for n in range(self.NV): |
---|
40 | self.V.append([]) |
---|
41 | for a in range(self.NAUXV): |
---|
42 | self.A.append([]) |
---|
43 | |
---|
44 | def _readData1(self, datalines, ivar_count): |
---|
45 | """ |
---|
46 | Reads first line/section of current block of data. |
---|
47 | """ |
---|
48 | # Start with independent and Auxilliary vars |
---|
49 | (x2_and_a, rtlines)=readItemsFromUnknownLines(datalines, 1+self.NAUXV, float) |
---|
50 | (x, aux)=(x2_and_a[0], x2_and_a[1:]) |
---|
51 | self.X.append(x) |
---|
52 | count=0 |
---|
53 | for a in range(self.NAUXV): |
---|
54 | self.A[a].append(aux[count]) |
---|
55 | count=count+1 |
---|
56 | return rtlines |
---|
57 | |
---|
58 | def _readData2(self, datalines, ivar_count): |
---|
59 | """ |
---|
60 | Reads second line/section (if used) of current block of data. |
---|
61 | """ |
---|
62 | # Now get the dependent variables |
---|
63 | (v, rtlines)=readItemsFromUnknownLines(datalines, self.NV, float) |
---|
64 | # Set up mth list in self.V |
---|
65 | self.V.append([]) |
---|
66 | count=0 |
---|
67 | for n in range(self.NV): |
---|
68 | self.V[n].append([]) |
---|
69 | self.V[ivar_count].append(v[count]) |
---|
70 | count=count+1 |
---|
71 | return rtlines |
---|