source: nappy/trunk/naFile2310.py @ 349

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/nappy/trunk/naFile2310.py@360
Revision 349, 2.3 KB checked in by selatham, 15 years ago (diff)

Inserted license information.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1#   Copyright (C) 2004 CCLRC & NERC( Natural Environment Research Council ).
2#   This software may be distributed under the terms of the
3#   Q Public License, version 1.0 or later. http://ndg.nerc.ac.uk/public_docs/QPublic_license.txt
4
5"""
6naFile2310.py
7=============
8
9Container module for NAFile2310 class.
10
11"""
12
13# Imports from python standard library
14
15# Imports from local package
16from textParser import *
17import naFile2110
18
19class NAFile2310(naFile2110.NAFile2110):
20    """
21    Class to read, write and interact with NASA Ames files conforming to the
22    File Format Index (FFI) 2310.
23    """
24
25    def readHeader(self):
26        """
27        Reads FFI-specifc header section.
28        """       
29        self._normalizedX="no"
30        self._readCommonHeader()
31        self.DX=readItemsFromLine(self.file.readline(), 1, float)
32        self.XNAME=readItemsFromLines(self._readLines(self.NIV), self.NIV, str)
33        self.XNAME.reverse()  # Reverse because C-type array is least-changing first         
34        self._readVariablesHeaderSection()
35        self._readAuxVariablesHeaderSection()
36        self._readComments()
37   
38    def _readData1(self, datalines, ivar_count): 
39        """
40        Reads first line/section of current block of data.
41        """       
42        # Start with independent and Auxilliary vars
43        (x_and_a, rtlines)=readItemsFromUnknownLines(datalines, self.NAUXV+1, float)
44        (x, aux)=(x_and_a[0], x_and_a[1:])
45        for a in range(self.NAUXV):
46            self.A.append(aux[a])
47        self.X.append([])
48        self.X[ivar_count].append(x)
49        # Set up list to take second changing independent variable
50        self.X[ivar_count].append([aux[1]]) 
51        self.NX.append(int(aux[0]))
52        self.DX.append(int(aux[2]))
53        return rtlines
54   
55    def _readData2(self, datalines, ivar_count):
56        """
57        Reads second line/section (if used) of current block of data.
58        """
59        # Now get the dependent variables
60        (v, rtlines)=readItemsFromUnknownLines(datalines, self.NV*self.NX[ivar_count], float)
61        count=0
62        for n in range(self.NV):
63            self.V[n].append([])
64            for i in range(self.NX[ivar_count]):
65                self.V[n][ivar_count].append(v[count])
66                count=count+1
67        return rtlines
Note: See TracBrowser for help on using the repository browser.