source: nappy/trunk/naFile2310.py @ 343

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/nappy/trunk/naFile2310.py@348
Revision 343, 2.0 KB checked in by astephen, 16 years ago (diff)

Latest version with new files in test directory.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1"""
2naFile2310.py
3=============
4
5Container module for NAFile2310 class.
6
7"""
8
9# Imports from python standard library
10
11# Imports from local package
12from textParser import *
13import naFile2110
14
15class NAFile2310(naFile2110.NAFile2110):
16    """
17    Class to read, write and interact with NASA Ames files conforming to the
18    File Format Index (FFI) 2310.
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(), 1, float)
28        self.XNAME=readItemsFromLines(self._readLines(self.NIV), self.NIV, str)
29        self.XNAME.reverse()  # Reverse because C-type array is least-changing first         
30        self._readVariablesHeaderSection()
31        self._readAuxVariablesHeaderSection()
32        self._readComments()
33   
34    def _readData1(self, datalines, ivar_count): 
35        """
36        Reads first line/section of current block of data.
37        """       
38        # Start with independent and Auxilliary vars
39        (x_and_a, rtlines)=readItemsFromUnknownLines(datalines, self.NAUXV+1, float)
40        (x, aux)=(x_and_a[0], x_and_a[1:])
41        for a in range(self.NAUXV):
42            self.A.append(aux[a])
43        self.X.append([])
44        self.X[ivar_count].append(x)
45        # Set up list to take second changing independent variable
46        self.X[ivar_count].append([aux[1]]) 
47        self.NX.append(int(aux[0]))
48        self.DX.append(int(aux[2]))
49        return rtlines
50   
51    def _readData2(self, datalines, ivar_count):
52        """
53        Reads second line/section (if used) of current block of data.
54        """
55        # Now get the dependent variables
56        (v, rtlines)=readItemsFromUnknownLines(datalines, self.NV*self.NX[ivar_count], float)
57        count=0
58        for n in range(self.NV):
59            self.V[n].append([])
60            for i in range(self.NX[ivar_count]):
61                self.V[n][ivar_count].append(v[count])
62                count=count+1
63        return rtlines
Note: See TracBrowser for help on using the repository browser.