Beispiel #1
0
  def __init__ (self, values, trunc=None, M=None, N=None, **kwargs):
  # {{{
    if isinstance(values, int):
      trunc = values
      values = np.arange((trunc+1)*(trunc+2)/2)

    if trunc is None:
      # Infer triangular truncation by length of values
      trunc = int(np.sqrt(len(values) * 2 + 0.25) - 1.5)

    if N is None:
      N = np.concatenate([np.arange(n, trunc+1) for n in np.arange(0, trunc+1)])
      M = np.concatenate([n*np.ones(trunc+1-n, 'i') for n in np.arange(0, trunc+1)])

    # Just pass all the stuff to the superclass
    Axis.__init__ (self, values, N=N, M=M, **kwargs)
Beispiel #2
0
def test_issue010():
  from pygeode.var import Var
  from pygeode.axis import Axis
  from pygeode.dataset import Dataset
  from pygeode.formats import netcdf as nc

  # Make some axes
  time_axis = Axis(values=[0], name='time')
  bnds_axis = Axis(values=[0,1], name='bnds')

  # Make some vars (note we don't have a 'bnds' variable corresponding to the 'bnds' dimension
  time_var = Var(axes=[time_axis], values=[1], name='time')
  time_bnds = Var(axes=[time_axis,bnds_axis], values=[[3,4]], name='time_bnds')

  # Make a dataset to hold the vars
  dataset = Dataset([time_var, time_bnds])

  # Manually appy dims2axes to detect our axes
  dataset = nc.dims2axes(dataset)
Beispiel #3
0
    def __init__(self, values, trunc=None, M=None, N=None, **kwargs):
        # {{{
        if isinstance(values, int):
            trunc = values
            values = np.arange((trunc + 1) * (trunc + 2) // 2)

        if trunc is None:
            # Infer triangular truncation by length of values
            trunc = int(np.sqrt(len(values) * 2 + 0.25) - 1.5)

        if N is None:
            N = np.concatenate(
                [np.arange(n, trunc + 1) for n in np.arange(0, trunc + 1)])
            M = np.concatenate([
                n * np.ones(trunc + 1 - n, 'i')
                for n in np.arange(0, trunc + 1)
            ])

        # Just pass all the stuff to the superclass
        Axis.__init__(self, values, N=N, M=M, **kwargs)
Beispiel #4
0
 def __eq__ (self, other):
   from pygeode.axis import Axis
   return Axis.__eq__(self,other) and self.name == other.name