Ignore:
Timestamp:
20/02/08 17:18:00 (12 years ago)
Author:
astephen
Message:

Fixed and broken - got 2110 and 2310 writing from NetCDF. But the solution breaks the basic readNA/writeNA cycle. The reason is that the new code writes the data from NX, DX and X rather than A and NAUXV. Maybe the data really needs to be encoded to NAUXV and A in order for this to work unformly. Hmmmm.

File:
1 edited

Legend:

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

    r3474 r3482  
    149149        self.na_dict["NIV"] = number_of_dims 
    150150 
     151 
     152        # If 2D then do a quick test to see if 2310 is feasible (i.e. uniformly spaced 2nd axis) 
     153        if number_of_dims == 2: 
     154            ffis_limited = [2010, 2110] 
     155            axis = best_var.getAxis(1) 
     156            if nappy.cdms_utils.axis_utils.isUniformlySpaced(axis): 
     157                ffis_limited.append(2310) 
     158 
    151159        # Get the axes for the main variable being used 
    152160        best_var_axes = best_var.getAxisList() 
     
    278286            ffi = 10 + (number_of_dims * 1000) 
    279287        elif number_of_dims == 2: 
    280             if self.requested_ffi == 2310: 
    281                 raise Exception("FFI '" + str(self.requested_ffi) + "' conversion not yet supported.") 
    282             elif self.requested_ffi in (2010, 2110): 
     288            if self.requested_ffi in (2010, 2110, 2310): 
    283289                ffi = self.requested_ffi  
    284290            else: 
     
    374380                    self.na_dict["ASCAL"] = [1.0] 
    375381 
     382                # If FFI is 2310 then need to modify na_dict items for that 
     383                elif self.na_dict["FFI"] == 2310: 
     384                    new_x = [] 
     385                    new_nx = [] 
     386                    new_dx = [] 
     387                    ax2_values = var.getAxis(1)[:].tolist() 
     388                    incr = ax2_values[1] - ax2_values[0] 
     389 
     390                    for i in self.ax0[:]: 
     391                        new_x.append([i, ax2_values]) 
     392                        new_nx.append(len(ax2_values)) 
     393                        new_dx.append(incr) 
     394 
     395                    # Re-assign to new lists 
     396                    self.na_dict["NX"] = new_nx 
     397                    self.na_dict["X"] = new_x 
     398                    self.na_dict["DX"] = new_dx 
     399 
     400                    # Now auxiliary variable info here with independent var info 
     401                    ind_var_name = self.na_dict["XNAME"][0] 
     402                    self.na_dict["ANAME"] = ["Number of '%s' values recorded in subsequent data records" % ind_var_name, 
     403                                             "'%s' value for first data point" % ind_var_name, 
     404                                             "'%s' increment" % ind_var_name] 
     405                    self.na_dict["AMISS"] = [-9999.999, -9999.999, -9999.999] 
     406                    self.na_dict["ASCAL"] = [1.0, 1.0, 1.0] 
     407  
    376408 
    377409    def _defineNAAuxVars(self, aux_vars): 
Note: See TracChangeset for help on using the changeset viewer.