def read(self, filename, format='auto'):
        """Same as Structure.read, but update spcgr value in
        self.pdffit when parser can get spacegroup.

        Return instance of StructureParser used to load the data.
        See Structure.read() for more info.
        """
        p = Structure.read(self, filename, format)
        sg = getattr(p, 'spacegroup', None)
        if sg:  self.pdffit['spcgr'] = sg.short_name
        return p
    def read(self, filename, format='auto'):
        """Same as Structure.read, but update spcgr value in
        self.pdffit when parser can get spacegroup.

        Return instance of StructureParser used to load the data.
        See Structure.read() for more info.
        """
        p = Structure.read(self, filename, format)
        sg = getattr(p, 'spacegroup', None)
        if sg: self.pdffit['spcgr'] = sg.short_name
        return p
        # Discard atom if (x/a)**2 + (y/b)**2 + (z/c)**2 > 1
        if d > 1:
            delList.append(j)

    for i in delList:
        newS.pop(i)

    return newS

if __name__ == "__main__":

    import os.path
    datadir = "../../tests/testdata"
    S = Structure()
    S.read(os.path.join(datadir, "CdSe_bulk.stru"), "pdffit")
    newS = makeEllipsoid(S, 12)
    newS.write("CdSe_d24.stru", "pdffit")
    newS = makeEllipsoid(S, 20, 10, 10)
    newS.write("CdSe_a20_b10_c10.stru", "pdffit")
    newS = makeEllipsoid(S, 20, 15, 10)
    newS.write("CdSe_a20_b15_c10.stru", "pdffit")
    S = Structure()
    S.read(os.path.join(datadir, "Ni.stru"), "pdffit")
    newS = makeEllipsoid(S, 10)
    newS.write("Ni_d20.stru", "pdffit")
    newS = makeEllipsoid(S, 20, 4)
    newS.write("Ni_a20_b4_c20.stru", "pdffit")
    newS = makeEllipsoid(S, 20, 15, 10)
    newS.write("Ni_a20_b15_c10.stru", "pdffit")
    from geometry.composites import cuboctahedron
    from geometry.operations import translate, rotate
    c0 = translate(cuboctahedron(dist), lat.cartesian(newS[ncenter].xyz))

    # Cut out an octahedron
    from geometry import locate

    N = len(newS)
    j = N
    for i in xrange(N):

        xyz = lat.cartesian(newS[N - 1 - i].xyz)
        if locate(xyz, c0) == 1:
            newS.pop(N - 1 - i)

    return newS


if __name__ == "__main__":

    import os.path
    datadir = "../../../tests/testdata"
    S = Structure()
    S.read(os.path.join(datadir, "CdSe_bulk.stru"), "pdffit")
    newS = makeCuboctahedron(S, 12)
    newS.write("CdSe_cuboct24.stru", "pdffit")
    S = Structure()
    S.read(os.path.join(datadir, "Ni.stru"), "pdffit")
    newS = makeCuboctahedron(S, 10)
    newS.write("Ni_cuboct20.stru", "pdffit")