예제 #1
0
    def update_pli_loc(self, boundaries, bnd):
        """
        make sure location of pli is readable and return an array of that pli
        and the updated boundaries, assigned to the boundaries attribute
        Arguments:
            boundaries {[type]} -- [description]
            bnd {[type]} -- [description]
        """

        pli_loc_key = 'pli_loc'
        # assume absolute path to begin with
        try:
            pli = utils.read_pli(boundaries[bnd][pli_loc_key])
        except (FileNotFoundError):
            # could be local, so look in same folder as ext
            pli_dir = os.path.split(self.ext)[0]
            try:
                boundaries[bnd][pli_loc_key] = os.path.join(
                    pli_dir, boundaries[bnd][pli_loc_key])
                pli = utils.read_pli(boundaries[bnd][pli_loc_key])
            except (FileNotFoundError):
                print(
                    'No absolute path to pli provided and pli not located in local folder. Please copy the pli to the local folder'
                )
                raise

        return boundaries, pli
예제 #2
0
    def __init__(self, path, coords, pli, out):
        """
        Tide class
        
        Arguments:
            path {str} -- path to folder containin fes data
            coords {list} -- [xmin, xmax, ymin, ymax]
            pli {str} -- path to *.pli file
            out {path} -- path for output
        """

        self.path = path
        print(self.path)

        print(os.listdir(os.path.abspath(self.path)))

        self.coords = coords
        self.out = out

        self.const = [
            '2N2', 'Mf', 'P1', 'M2', 'MKS2', 'Mu2', 'Q1', 'T2', 'J1', 'M3',
            'Mm', 'N2', 'R2', 'K1', 'M4', 'MN4', 'S1', 'K2', 'M6', 'MS4',
            'Nu2', 'S2', 'L2', 'M8', 'MSf', 'O1', 'S4'
        ]

        XY = utils.read_pli(pli)

        self.pli = pli
        self.X = XY[:, 0]
        self.Y = XY[:, 1]

        self.check_coords()

        self.name = os.path.split(
            self.pli)[1][:utils.find_last(os.path.split(self.pli)[1], '.') - 1]

        self.ext = os.path.join(self.out, '%s.ext' % self.name)

        try:

            self.representative = glob.glob(
                os.path.abspath(os.path.join(self.path, '*SLEV.nc')))[0]
        except (IndexError):
            print('ERROR: NO DATA FOUND IN FES PATH, NOT VALID TIDE OBJECT')
            self.representative = None
            raise