Changeset 3999 for nappy/trunk


Ignore:
Timestamp:
05/06/08 23:07:15 (12 years ago)
Author:
astephen
Message:

Added annotation numbering.

Location:
nappy/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • nappy/trunk/annotations.ini

    r3986 r3999  
    99DX = Interval between coordinate variable values (zero if not used) 
    1010NVPM = Number of extra independent variable points between independent variable values 
    11 NX = Number of coordinate variable values 
     11NX = Length of coordinate variables 
    1212NXDEF = Number of coordinate variable values explicity defined in header 
    1313X = Values of coordinate variable 
  • nappy/trunk/nappy/na_file/na_file_2010.py

    r3966 r3999  
    6363        NX.reverse() 
    6464        self.header.write(wrapLine("NX", self.annotation, self.delimiter, (("%s" + self.delimiter) * (self.NIV - 2) + "%s\n") % tuple(NX))) 
    65         NXDEF = self.NXDEF 
     65        NXDEF = self.NXDEF[:] 
    6666        NXDEF.reverse() 
    6767        self.header.write(wrapLine("NXDEF", self.annotation, self.delimiter, (("%s" + self.delimiter) * (self.NIV - 2) + "%s\n") % tuple(NXDEF))) 
     
    7070 
    7171        for i in range(self.NIV - 1): 
    72             print "NIV:", self.NIV, "NXDEF[i]:", self.NXDEF[i], "self.X[i + 1][0:self.NXDEF[i]]", self.X[i + 1][0:self.NXDEF[i]] 
     72            #print "COUNTER:", i 
     73            #print "NXDEF[i]:", self.NXDEF[i], "self.X[i][0:self.NXDEF[i]]", self.X[i + 1][0:self.NXDEF[i]] 
     74            #print self.X 
     75            #print self.NXDEF 
     76            #X_lines.append((self.format * self.NXDEF[i] % tuple(self.X[i + 1][0:self.NXDEF[i]])).rstrip(" ,") + "\n") 
    7377            X_lines.append((self.format * self.NXDEF[i] % tuple(self.X[i + 1][0:self.NXDEF[i]])).rstrip(" ,") + "\n") 
    7478 
     
    7781            self.header.write(wrapLine("X", self.annotation, self.delimiter, line.lstrip())) 
    7882 
    79         XNAME = self.XNAME 
     83        XNAME = self.XNAME[:] 
    8084        XNAME.reverse() 
    8185        self.header.write(wrapLines("XNAME", self.annotation, self.delimiter, "%s\n" * self.NIV % tuple(XNAME))) 
  • nappy/trunk/nappy/utils/common_utils.py

    r3988 r3999  
    153153 
    154154 
    155 def getAnnotation(item, annotation, delimiter=None): 
     155def getAnnotation(item, annotation, delimiter=None, count=None): 
    156156    """ 
    157157    Returns the annotation string for a given NASA Ames item. 
     
    160160        delimiter = getDefault("default_delimiter")  
    161161    dict = parse_config.getAnnotationsConfigDict() 
    162     if annotation: return dict[item] + delimiter 
    163     else: return '' 
     162 
     163    if count == None: 
     164        count_string = "" 
     165    else: 
     166        count_string = " %s" % count 
     167     
     168    if annotation: 
     169        return "%s%s%s" % (dict[item], count_string, delimiter) 
     170    else: 
     171        return "" 
     172#    if annotation: return dict[item] + delimiter 
     173#    else: return '' 
    164174 
    165175 
     
    172182    split_lines = lines.splitlines(1) 
    173183    output = "" 
     184 
     185    count = 1 
    174186    for line in split_lines: 
    175         output = output + annotateLine(item_name, annotate, delimiter, line) 
     187        output = output + annotateLine(item_name, annotate, delimiter, line, count) 
     188        count += 1 
    176189 
    177190    #print "Outgoing lines are", output 
    178191    return output 
     192 
    179193     
    180 def annotateLine(item_name, annotate, delimiter, line): 
     194def annotateLine(item_name, annotate, delimiter, line, count=None): 
    181195    """ 
    182196    Takes item_name to look up, delimiter and item to render and returns full line. 
     
    184198 
    185199    if annotate: 
    186         annotation = getAnnotation(item_name, annotate, delimiter = delimiter) 
     200        annotation = getAnnotation(item_name, annotate, delimiter=delimiter, count=count) 
    187201        line = "%s%s" % (annotation, line) 
    188202        return line 
Note: See TracChangeset for help on using the changeset viewer.