Changeset 3469 for nappy


Ignore:
Timestamp:
20/02/08 14:01:06 (12 years ago)
Author:
astephen
Message:

Some temporary scripts to test functionality before formalising into unit tests.

Location:
nappy/trunk/nappy/nc_interface
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • nappy/trunk/nappy/nc_interface/cdms_to_na.py

    r3441 r3469  
    4747 
    4848    def __init__(self, cdms_variables, global_atts={}, na_items_to_override={},  
    49                  only_return_file_names=False): 
     49                 only_return_file_names=False, requested_ffi=None): 
    5050        """ 
    5151        Sets up instance variables.       
     
    5555        self.na_items_to_override = na_items_to_override 
    5656        self.only_return_file_names = only_return_file_names 
     57        self.requested_ffi = requested_ffi 
     58 
    5759        self.converted = False 
    5860        self.output_message = [] 
     
    8789 
    8890        # Make first call to collector class that creates NA dict from CDMS variables and global atts dicts 
    89         collector = nappy.nc_interface.na_content_collector.NAContentCollector(variables, self.global_atts) 
     91        collector = nappy.nc_interface.na_content_collector.NAContentCollector(variables,  
     92                                        self.global_atts, requested_ffi=self.requested_ffi) 
    9093        collector.collectNAContent() 
    9194 
     
    106109        # in attempt to convert all to a set of na_dicts 
    107110        while len(collector.unused_vars) > 0: 
    108             collector = nappy.nc_interface.na_content_collector.NAContentCollector(collector.unused_vars, self.global_atts) 
     111            collector = nappy.nc_interface.na_content_collector.NAContentCollector(collector.unused_vars,  
     112                                       self.global_atts, requested_ffi=self.requested_ffi) 
    109113            collector.collectNAContent()            
    110114            self.output_message += collector.output_message 
  • nappy/trunk/nappy/nc_interface/na_content_collector.py

    r3442 r3469  
    6969        self.var_ids = None 
    7070        self.globals = global_attributes         
    71         self.requested_ffi = ffi 
     71        self.requested_ffi = requested_ffi 
    7272        self.rank_zero_vars = [] 
    7373        self.rank_zero_var_ids = [] 
     
    182182                # I think it is an auxiliary variable 
    183183                aux_vars_for_na.append(var)  
    184                 # Also put it in unused var bin because auxiliary vars might be useful later on in there own right 
    185                 print "NOTE: Auxiliary variables are recorded in file but also placed in unused category just in case they should be re-used in other files." 
    186                 self.unused_vars.append(var) 
    187184 
    188185            else: 
     
    278275                ffi = 1001 
    279276 
    280         if self.requestd_ffi and ffi != self.requested_ffi: 
     277        if self.requested_ffi and ffi != self.requested_ffi: 
    281278            raise Exception("Cannot write this data to FFI '" + str(self.requested_ffi) + "', can only write to: " + str(ffi) + ".") 
    282279        return ffi 
     
    312309                self.ax0 = var.getAxis(0) 
    313310                self.na_dict["X"] = [self.ax0[:].tolist()] 
     311                print self.na_dict["X"] 
    314312                self.na_dict["XNAME"] = [nappy.cdms_utils.var_utils.getBestName(self.ax0)] 
    315313                if len(self.ax0) == 1: 
  • nappy/trunk/nappy/nc_interface/nc_to_na.py

    r3441 r3469  
    4242 
    4343    def __init__(self, nc_file, var_ids=None, na_items_to_override={},  
    44             only_return_file_names=False, exclude_vars=[]): 
     44            only_return_file_names=False, exclude_vars=[], 
     45            requested_ffi=None): 
    4546        """ 
    4647        Sets up instance variables. 
     
    6061        (cdms_variables, global_atts) = self._readCDMSFile(var_ids, exclude_vars) 
    6162        nappy.nc_interface.cdms_to_na.CDMSToNA.__init__(self, cdms_variables, global_atts=global_atts,  
    62                     na_items_to_override=na_items_to_override, only_return_file_names=only_return_file_names) 
     63                                                        na_items_to_override=na_items_to_override,  
     64                                                        only_return_file_names=only_return_file_names, 
     65                                                        requested_ffi=requested_ffi) 
    6366  
    6467 
  • nappy/trunk/nappy/nc_interface/quick_tests_na_to_nc.py

    r3416 r3469  
    66out_dir = "../../test_outputs" 
    77 
    8 for ffi in (1001, 2010, 3010, 4010): 
     8for ffi in (1001, 1010, 1020, 2010, 3010, 4010): 
    99 
    1010    infile = os.path.join(in_dir, "%s.na" % ffi) 
Note: See TracChangeset for help on using the changeset viewer.