コード例 #1
0
    def __init__(self,
                 values=None,
                 axes=None,
                 time=None,
                 lat=None,
                 lon=None,
                 **kwargs):
        """ 
        """
        keyword = (time is not None or lat is not None or lon is not None)
        assert not (axes is not None and
                    keyword), "can't input both `axes=` and keyword arguments!"

        # construct the axes
        if keyword:
            axes = Axes()
            if time is not None: axes.append(Axis(time, 'time'))
            if lat is not None: axes.append(Axis(lat, 'lat'))
            if lon is not None: axes.append(Axis(lon, 'lon'))

        super(GeoArray, self).__init__(values, axes,
                                       **kwargs)  # order dimensions

        # add weight on latitude
        for ax in self.axes:
            if is_latitude(ax.name):
                ax.weights = lambda x: np.cos(np.radians(x))
            if is_longitude(ax.name):
                ax.modulo = 360