1 | """ |
---|
2 | naFile1020.py |
---|
3 | ============= |
---|
4 | |
---|
5 | Container module for NAFile1020 class. |
---|
6 | |
---|
7 | """ |
---|
8 | |
---|
9 | # Imports from python standard library |
---|
10 | |
---|
11 | # Imports from local package |
---|
12 | from textParser import * |
---|
13 | import naFile1010 |
---|
14 | |
---|
15 | class NAFile1020(naFile1010.NAFile1010): |
---|
16 | """ |
---|
17 | Class to read, write and interact with NASA Ames files conforming to the |
---|
18 | File Format Index (FFI) 1020. |
---|
19 | """ |
---|
20 | |
---|
21 | def readHeader(self): |
---|
22 | """ |
---|
23 | Reads FFI-specifc header section. |
---|
24 | """ |
---|
25 | self._normalizedX="no" |
---|
26 | self._readCommonHeader() |
---|
27 | self.DX=readItemsFromLine(self.file.readline(), self.NIV, float) |
---|
28 | if self.DX==0: |
---|
29 | raise "DX found to be zero (0). Not allowed for FFI 1020." |
---|
30 | |
---|
31 | self.NVPM=readItemFromLine(self.file.readline(), int) |
---|
32 | self.XNAME=readItemsFromLines(self._readLines(self.NIV), self.NIV, str) |
---|
33 | self._readVariablesHeaderSection() |
---|
34 | self._readAuxVariablesHeaderSection() |
---|
35 | self._readComments() |
---|
36 | |
---|
37 | def _readData2(self, datalines, ivar_count): |
---|
38 | """ |
---|
39 | Reads second line/section (if used) of current block of data. |
---|
40 | """ |
---|
41 | # Now get the dependent variables |
---|
42 | (v, rtlines)=readItemsFromUnknownLines(datalines, self.NV*self.NVPM, float) |
---|
43 | count=0 |
---|
44 | for n in range(self.NV): |
---|
45 | self.V[n].append([]) |
---|
46 | for i in range(self.NVPM): # Number of steps where independent variable is implied |
---|
47 | self.V[n][ivar_count].append(v[count]) |
---|
48 | count=count+1 |
---|
49 | return rtlines |
---|
50 | |
---|
51 | def _normalizeIndVars(self): |
---|
52 | """ |
---|
53 | Normalizes the values in the unbounded independent variable for FFIs |
---|
54 | that store an abbreviated version of this axis. |
---|
55 | """ |
---|
56 | newX=[] |
---|
57 | for x in self.X[0]: |
---|
58 | for i in range(self.NVPM): |
---|
59 | newX.append(x+(i*self.DX)) |
---|
60 | self.X[0]=newX |
---|
61 | self._normalizedX="yes" |
---|