Returns the cartesian coordinates given fractional coordinates.

        Args:
            fractional_coords (3x1 array): Fractional coords.

        Returns:
            Cartesian coordinates
426114
def get_cartesian_coords(self, fractional_coords: Vector3Like) -> np.ndarray:
        
        return dot(fractional_coords, self._matrix)
600509
def from_coords(cls, coords, sort=True):
        
        coords = list(coords)
        if sort:
            coords.sort()
        if len(coords[0]) == 2:  # 2D coordinates
            lons, lats = zip(*coords)
            depths = None
        else:  # 3D coordinates
            lons, lats, depths = zip(*coords)
            depths = numpy.array(depths)
        return cls(numpy.array(lons), numpy.array(lats), depths)
348641
def _getDirection(coord1, coord2):
    
    x1, y1 = coord1
    x2, y2 = coord2

    if x1 == x2 and y1 == y2:
        return None # two coordinates are the same.
    elif x1 == x2 and y1 > y2:
        return UP
    elif x1 == x2 and y1 < y2:
        return DOWN
    elif x1 > x2 and y1 == y2:
        return LEFT
    elif x1 < x2 and y1 == y2:
        return RIGHT

    slope = float(y2 - y1) / float(x2 - x1)

    # Figure out which quadrant the line is going in, and then
    # determine the closest direction by calculating the slope
    if x2 > x1 and y2 < y1: # up right quadrant
        if slope > -0.4142:
            return RIGHT # slope is between 0 and 22.5 degrees
        elif slope < -2.4142:
            return UP # slope is between 67.5 and 90 degrees
        else:
            return UPRIGHT # slope is between 22.5 and 67.5 degrees
    elif x2 > x1 and y2 > y1: # down right quadrant
        if slope > 2.4142:
            return DOWN
        elif slope < 0.4142:
            return RIGHT
        else:
            return DOWNRIGHT
    elif x2 < x1 and y2 < y1: # up left quadrant
        if slope < 0.4142:
            return LEFT
        elif slope > 2.4142:
            return UP
        else:
            return UPLEFT
    elif x2 < x1 and y2 > y1: # down left quadrant
        if slope < -2.4142:
            return DOWN
        elif slope > -0.4142:
            return LEFT
        else:
            return DOWNLEFT
704096
def map(self, coords):
        
        for tr in reversed(self.transforms):
            coords = tr.map(coords)
        return coords
29432
def parse_coordinates(self, coords_str):
        
        if coords_str.strip() == '':
            return (None, None)
        ra = '%s:%s:%s' % (coords_str[0:2], coords_str[2:4], coords_str[4:8])
        dec = '%s:%s:%s' % (coords_str[8:11], coords_str[11:13], coords_str[13:15])
        return (ra, dec)
511776
def raster_to_projection_coords(self, pixel_x, pixel_y):
        
        h_px_py = np.array([1, pixel_x, pixel_y])
        gt = np.array([[1, 0, 0], self.geotransform[0:3], self.geotransform[3:6]])
        arr = np.inner(gt, h_px_py)
        return arr[2], arr[1]
664268
def lattice(self, lattice):
        
        self._lattice = lattice
        self._coords = self._lattice.get_cartesian_coords(self._frac_coords)
146355
def coords(obj):
    
    # Handle recursive case first
    if 'features' in obj:
        for f in obj['features']:
            # For Python 2 compatibility
            # See https://www.reddit.com/r/learnpython/comments/4rc15s/yield_from_and_python_27/ # noqa: E501
            for c in coords(f):
                yield c
    else:
        if isinstance(obj, (tuple, list)):
            coordinates = obj
        elif 'geometry' in obj:
            coordinates = obj['geometry']['coordinates']
        else:
            coordinates = obj.get('coordinates', obj)
        for e in coordinates:
            if isinstance(e, (float, int)):
                yield tuple(coordinates)
                break
            for f in coords(e):
                yield f
883868
def clean_coordinates(coords, silent=False):
    
    l1 = len(coords)
    coords = coords[~N.isnan(coords).any(axis=1)] # remove NaN values
    l2 = len(coords)
    if not silent:
        msg = "{0} coordinates".format(l2)
        if l2 < l1:
            msg += " ({0} removed as invalid)".format(l1-l2)
        print(msg)
    return coords
994033
def quadrant(xcoord, ycoord):
    

    xneg = bool(xcoord < 0)
    yneg = bool(ycoord < 0)
    if xneg is True:
        if yneg is False:
            return 2
        return 3
    if yneg is False:
        return 1
    return 4
633242
def fractional_from_cartesian(coordinate, lattice_array):
    """"""
    deorthogonalisation_M = np.matrix(np.linalg.inv(lattice_array))
    fractional = deorthogonalisation_M * coordinate.reshape(-1, 1)
    return np.array(fractional.reshape(1, -1))
522827
def get_cartesian(self):
        
        coords = ['x', 'y', 'z']
        eq_sets = self._metadata['eq']['eq_sets']
        sym_ops = self._metadata['eq']['sym_ops']
        frame = pd.DataFrame(index=[i for v in eq_sets.values() for i in v],
                             columns=['atom', 'x', 'y', 'z'], dtype='f8')
        frame['atom'] = pd.Series(
            {i: self.loc[k, 'atom'] for k, v in eq_sets.items() for i in v})
        frame.loc[self.index, coords] = self.loc[:, coords]
        for i in eq_sets:
            for j in eq_sets[i]:
                frame.loc[j, coords] = np.dot(sym_ops[i][j],
                                              frame.loc[i, coords])
        return Cartesian(frame)
331056
def get_x(self, var, coords=None):
        
        if coords is None:
            coords = self.ds.coords
        # first we try the super class
        ret = super(UGridDecoder, self).get_x(var, coords)
        # but if that doesn't work because we get the variable name in the
        # dimension of `var`, we use the means of the triangles
        if ret is None or ret.name in var.dims:
            bounds = self.get_cell_node_coord(var, axis='x', coords=coords)
            if bounds is not None:
                centers = bounds.mean(axis=-1)
                x = self.get_nodes(self.get_mesh(var, coords), coords)[0]
                try:
                    cls = xr.IndexVariable
                except AttributeError:  # xarray < 0.9
                    cls = xr.Coordinate
                return cls(x.name, centers, attrs=x.attrs.copy())
601453
def to_int(self):
        
        coord = [int(round(x)) for x in self.xy_coord()]
        return self.from_xy(coord[0], coord[1], coord[2], coord[3])
837177
def _prepare_coords(lons1, lats1, lons2, lats2):
    
    lons1 = numpy.radians(lons1)
    lats1 = numpy.radians(lats1)
    assert lons1.shape == lats1.shape
    lons2 = numpy.radians(lons2)
    lats2 = numpy.radians(lats2)
    assert lons2.shape == lats2.shape
    return lons1, lats1, lons2, lats2
286849
def get_lons_from_cartesian(x__, y__):
    
    return rad2deg(arccos(x__ / sqrt(x__ ** 2 + y__ ** 2))) * sign(y__)
170990
def check_coordinates(co, xy=None):
    
    if isinstance(co, ndarray):
        co = co.tolist()
    if not (isinstance(co[0][0], list) or isinstance(co[0][0], tuple)):
        co = [co]
    if xy is not True:
        co = map(lambda p: asarray(p)[:, ::-1].tolist(), co)
    return co