Example #1
0
    def constant(cls, name=None, units=None, variables=None):
        if any(var is None for var in (name, variables, units)):
            raise ValueError("name, variables, or units may not be None")

        if not isinstance(variables, collections.Iterable):
            raise TypeError('{0} variables must be an iterable'.format(name))
        t = Time.constant_time()
        return cls(name=name,
                   units=units,
                   time=t,
                   variables=[v for v in variables])
Example #2
0
    def constant(
        cls,
        name=None,
        units=None,
        data=None,
    ):
        if any(var is None for var in (name, data, units)):
            raise ValueError("name, data, or units may not be None")

        if not isinstance(data, Number):
            raise TypeError('{0} data must be a number'.format(name))
        t = Time.constant_time()
        return cls(name=name, units=units, time=t, data=[data])
Example #3
0
 def __init__(self, angle=None, **kwargs):
     """
     :param angle: scalar field of cell rotation angles (for rotated/distorted grids)
     """
     if 'variables' in kwargs:
         variables = kwargs['variables']
         if len(variables) == 2:
             variables.append(TimeSeriesProp(name='constant w', data=[0.0], time=Time.constant_time(), units='m/s'))
         kwargs['variables'] = variables
     if angle is None:
         df = None
         if kwargs.get('dataset', None) is not None:
             df = kwargs['dataset']
         elif kwargs.get('grid_file', None) is not None:
             df = _get_dataset(kwargs['grid_file'])
         if df is not None and 'angle' in df.variables.keys():
             # Unrotated ROMS Grid!
             self.angle = GriddedProp(name='angle', units='radians', time=None, grid=kwargs['grid'], data=df['angle'])
         else:
             self.angle = None
     else:
         self.angle = angle
     super(VelocityGrid, self).__init__(**kwargs)