<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def expand(self, grid='DH', lat=None, colat=None, lon=None, degrees=True, zeros=None, lmax=None, lmax_calc=None):
 """ Evaluate the spherical harmonic coefficients either on a global grid or for a list of coordinates. Usage ----- f = x.expand([grid, lmax, lmax_calc, zeros]) g = x.expand(lat=lat, lon=lon, [lmax_calc, degrees]) g = x.expand(colat=colat, lon=lon, [lmax_calc, degrees]) Returns ------- f : SHGrid class instance g : float, ndarray, or list Parameters lat : int, float, ndarray, or list, optional, default = None Latitude coordinates where the function is to be evaluated. colat : int, float, ndarray, or list, optional, default = None Colatitude coordinates where the function is to be evaluated. lon : int, float, ndarray, or list, optional, default = None Longitude coordinates where the function is to be evaluated. degrees : bool, optional, default = True True if lat, colat and lon are in degrees, False if in radians. grid : str, optional, default = 'DH' 'DH' or 'DH1' for an equisampled lat/lon grid with nlat=nlon, 'DH2' for an equidistant lat/lon grid with nlon=2*nlat, or 'GLQ' for a Gauss-Legendre quadrature grid. lmax : int, optional, default = x.lmax The maximum spherical harmonic degree, which determines the grid spacing of the output grid. lmax_calc : int, optional, default = x.lmax The maximum spherical harmonic degree to use when evaluating the function. zeros : ndarray, optional, default = None The cos(colatitude) nodes used in the Gauss-Legendre Quadrature grids. Description This method either (1) evaluates the spherical harmonic coefficients on a global grid and returns an SHGrid class instance, or (2) evaluates the spherical harmonic coefficients for a list of (co)latitude and longitude coordinates. For the first case, the grid type is defined by the optional parameter grid, which can be 'DH', 'DH2' or 'GLQ'.For the second case, the optional parameters lon and either colat or lat must be provided. """

        if lat is not None and colat is not None:
            raise ValueError('lat and colat can not both be specified.')

        if lat is not None and lon is not None:
            if lmax_calc is None:
                lmax_calc = self.lmax

            values = self._expand_coord(lat=lat, lon=lon, degrees=degrees,
                                        lmax_calc=lmax_calc)
            return values

        if colat is not None and lon is not None:
            if lmax_calc is None:
                lmax_calc = self.lmax

            if type(colat) is list:
                lat = list(map(lambda x: 90 - x, colat))
            else:
                lat = 90 - colat

            values = self._expand_coord(lat=lat, lon=lon, degrees=degrees,
                                        lmax_calc=lmax_calc)
            return values

        else:
            if lmax is None:
                lmax = self.lmax
            if lmax_calc is None:
                lmax_calc = lmax

            if type(grid) != str:
                raise ValueError('grid must be a string. ' +
                                 'Input type was {:s}'
                                 .format(str(type(grid))))

            if grid.upper() in ('DH', 'DH1'):
                gridout = self._expandDH(sampling=1, lmax=lmax,
                                         lmax_calc=lmax_calc)
            elif grid.upper() == 'DH2':
                gridout = self._expandDH(sampling=2, lmax=lmax,
                                         lmax_calc=lmax_calc)
            elif grid.upper() == 'GLQ':
                gridout = self._expandGLQ(zeros=zeros, lmax=lmax,
                                          lmax_calc=lmax_calc)
            else:
                raise ValueError(
                    "grid must be 'DH', 'DH1', 'DH2', or 'GLQ'. " +
                    "Input value was {:s}".format(repr(grid)))

            return gridout