source: nappy/trunk/naFile2160.py @ 349

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/nappy/trunk/naFile2160.py@357
Revision 349, 2.4 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"""
6naFile2160.py
7=============
8
9Container module for NAFile2160 class.
10
11"""
12
13# Imports from python standard library
14
15# Imports from local package
16from textParser import *
17import naFile2110
18
19class NAFile2160(naFile2110.NAFile2110):
20    """
21    Class to read, write and interact with NASA Ames files conforming to the
22    File Format Index (FFI) 2160.
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.LENX=readItemFromLine(self.file.readline(), float)
33        self.XNAME=readItemsFromLines(self._readLines(self.NIV), self.NIV, str)
34        self.XNAME.reverse()  # Reverse because C-type array is least-changing first         
35        self._readVariablesHeaderSection()
36        self._readCharAuxVariablesHeaderSection()
37        self._readComments()
38
39    def _setupArrays(self):
40        """
41        Sets up FFI-specific arrays to fill with data (lists of lists).
42        """
43        self.V=[]
44        self.A=[]
45        self.X=[]
46        self.NX=[]
47       
48        for n in range(self.NV):
49            self.V.append([])
50        for i in range(self.NAUXV):
51            self.A.append([])
52
53    def _readData1(self, datalines, ivar_count):
54        """
55        Reads first line/section of current block of data.
56        """     
57        # Start with independent and Auxilliary vars
58        # Get character string independent variable
59        (x1, datalines)=readItemsFromUnknownLines(datalines, 1, str)
60        self.X.append([])
61        self.X[ivar_count].append(x1)
62        # Set up list to take second changing independent variable
63        self.X[ivar_count].append([]) 
64        # Get NX and Non-character AUX vars
65        (aux, datalines)=readItemsFromUnknownLines(datalines, (self.NAUXV-self.NAUXC), float)
66        self.NX.append(int(aux[0]))
67        for a in range(self.NAUXV-self.NAUXC):
68            self.A.append(aux[a])
69        # Get character AUX vars
70        (auxc)=readItemsFromLines(datalines[:self.NAUXC], self.NAUXC, str)
71        rtlines=datalines[self.NAUXC:]
72        for a in range(self.NAUXC):
73            self.A.append(auxc[a])
74        return rtlines
75   
Note: See TracBrowser for help on using the repository browser.