Source code for epygram.fields.V1DField

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
V1DField:

Contains the class that handle a Vertical 1D field.
"""

import numpy

from epygram import epygramError, profiles
from epygram.base import Field, FieldValidity
from epygram.geometries import V1DGeometry



[docs]class V1DField(Field): """ Vertical 1-Dimension (column) field class. A field is defined by its identifier 'fid', its data, its geometry, and its validity. """ _collector = ('field',) _footprint = dict( attr=dict( geometry=dict(type=V1DGeometry), validity=dict( type=FieldValidity, optional=True, default=FieldValidity()), processtype=dict( optional=True, info="Generating process.") ) )
[docs] def setdata(self, data): """Sets data, checking it to be 1D.""" if len(numpy.shape(data)) != 1: raise epygramError("data must be 1D array.") super(V1DField, self).setdata(data) ################### # PRE-APPLICATIVE # ################### # (but useful and rather standard) ! # [so that, subject to continuation through updated versions, # including suggestions/developments by users...]
[docs] def plotfield(self): """ Makes a simple (profile) plot of the field. """ return profiles.plotprofiles(self) ############# # OPERATORS # #############
def __add__(self, other): """ Definition of addition, 'other' being: - a scalar (integer/float) - another Field of the same subclass. Returns a new Field whose data is the resulting operation, with 'fid' = {'op':'+'} and null validity. """ newfield = super(V1DField, self)._add(other, geometry=self.geometry) return newfield def __mul__(self, other): """ Definition of multiplication, 'other' being: - a scalar (integer/float) - another Field of the same subclass. Returns a new Field whose data is the resulting operation, with 'fid' = {'op':'*'} and null validity. """ newfield = super(V1DField, self)._mul(other, geometry=self.geometry) return newfield def __sub__(self, other): """ Definition of substraction, 'other' being: - a scalar (integer/float) - another Field of the same subclass. Returns a new Field whose data is the resulting operation, with 'fid' = {'op':'-'} and null validity. """ newfield = super(V1DField, self)._sub(other, geometry=self.geometry) return newfield def __div__(self, other): """ Definition of division, 'other' being: - a scalar (integer/float) - another Field of the same subclass. Returns a new Field whose data is the resulting operation, with 'fid' = {'op':'/'} and null validity. """ newfield = super(V1DField, self)._div(other, geometry=self.geometry) return newfield