Changeset 4700 for nappy


Ignore:
Timestamp:
23/12/08 00:55:49 (10 years ago)
Author:
astephen
Message:

More fixes to nappy to get all DCIP stuff writing properly.

Location:
nappy/trunk/nappy
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • nappy/trunk/nappy/cdms_utils/axis_utils.py

    r4698 r4700  
    3333    for axtype in ("time", "level", "latitude", "longitude"): 
    3434        if cdms.axisMatches(ax1, axtype) and not cdms.axisMatches(ax2, axtype): 
     35#            print "AXTYPE:", axtype 
    3536            return False 
    3637 
     
    4142    # Check units 
    4243    if hasattr(ax1, "units") and hasattr(ax2, "units"): 
    43         if ax1.units != ax2.units: return False 
     44        if ax1.units != ax2.units:  
     45#            print ax1.units, ax2.units 
     46            return False 
    4447     
    4548    # Do different comparisons depending on 'is_subset' argument 
    4649    if is_subset == False: 
    4750        # Check lengths and values 
    48         if (len(ax1) != len(ax2)) or (ax1.getData()[:].tolist() != ax2.getData()[:].tolist()): return False 
     51        if (len(ax1) != len(ax2)): 
     52#            print len(ax1), len(ax2) 
     53            return False 
     54 
     55        if ax1[:].tolist() != ax2[:].tolist():  
     56#            print ax1[:10], ax2[:10] 
     57            return False 
     58 
    4959    elif is_subset == True: 
    5060        # Check whether values are a subset 
  • nappy/trunk/nappy/nc_interface/cdms_to_na.py

    r4698 r4700  
    107107        # If there are variables that were not captured (i.e. unused) by NAContentCollector then loop through these 
    108108        # in attempt to convert all to a set of na_dicts 
     109        print "\n\nUNUSED VARS:", collector.unused_vars 
    109110        while len(collector.unused_vars) > 0: 
    110111            collector = nappy.nc_interface.na_content_collector.NAContentCollector(collector.unused_vars,  
  • nappy/trunk/nappy/nc_interface/na_content_collector.py

    r4699 r4700  
    129129        for var in self.vars: 
    130130            msg = "Analysing: %s" % var.id 
    131             print msg 
    132131            self.output_message.append(msg) 
    133132            count = count + 1 
     
    149148                highest_rank = rank 
    150149                best_var = var 
    151                 best_var_index = count 
     150                best_var_index = count - 1 
    152151 
    153152        # If all are zero ranked variables or no vars identified/found then we cannot write any to NASA Ames and return ([], []) 
     
    173172        best_var_axes = best_var.getAxisList() 
    174173         
    175         # Get other variable info 
    176         rest_of_the_vars = self.vars[:best_var_index - 1] + self.vars[best_var_index:] 
     174        # Get other variables into a list and analyse them 
     175        rest_of_the_vars = self.vars[:best_var_index] + self.vars[(best_var_index + 1):] 
    177176 
    178177        for var in rest_of_the_vars: 
     
    219218                    if nappy.cdms_utils.axis_utils.areAxesIdentical(best_var_axes[i], this_var_axes[i]) == False: 
    220219                        self.unused_vars.append(var) 
    221                         continue 
    222  
    223                 # OK, I think the current variable is compatible to write with the best variable along with a NASA Ames file  
    224                 vars_for_na.append(var) 
     220                        break 
     221                else: 
     222                    # OK, I think the current variable is compatible to write with the best variable along with a NASA Ames file  
     223                    vars_for_na.append(var) 
    225224 
    226225        # Send vars_for_na AND aux_vars_for_na to a method to check if they have previously been mapped  
  • nappy/trunk/nappy/nc_interface/nc_to_na.py

    r4699 r4700  
    193193                            comments_list = new_item[:] 
    194194                        elif comment_override_rule in ("insert", "extend"): 
     195                            new_comments = new_item[:] 
     196                            existing_comments = this_na_dict.get(key, []) 
    195197                            comments_list = self._cleanWrapComments(existing_comments, new_comments, key, comment_override_rule) 
    196198                        else: 
     
    198200 
    199201                        """elif comment_override_rule == "insert": 
    200                             new_comments = new_items[:] 
     202                            new_comments = new_item[:] 
    201203                            existing_comments = this_na_dict.get(key, []) 
    202204                            comments_list = self._cleanWrapComments(existing_comments, new_comments, key, comment_override_rule) 
     
    231233            # If not having to split file into multiple outputs (normal condition) 
    232234            else:                
     235                print "LLLLLLLLLLLLLLLLLLLLLLLLLLLL", file_name 
    233236                x = nappy.openNAFile(file_name, 'w', this_na_dict) 
    234237                x.write(delimiter=delimiter, float_format=float_format, annotation=annotation) 
     
    370373        Returns a new list of combined_comments. 
    371374        """ 
     375        if existing_comments == []:   return new_comments 
     376        if new_comments == []:        return existing_comments 
     377 
    372378        # Strip start header if used 
    373379        c1 = key[0].lower() 
Note: See TracChangeset for help on using the changeset viewer.