Exemple #1
0
    def writeGEFDCGridextFile(self, outputdir, filename='gridext.inp', shift=2):
        """
        Writes to the nodes and I/J cell index as to a file for GEFDC.

        Parameters
        ----------
        outputdir : str, optional
            The path to where the should be saved.
        filename : str, optional
            The name of the output file.
        shift : int, optional
            The shift that should be applied to the I/J index. The
            default value to 2 means that the first cell is at (2, 2)
            instead of (0, 0).

        Returns
        -------
        df : pandas.DataFrame
            The dataframe of coordinates and I/J index.

        """
        outfile = iotools._outputfile(outputdir, filename)
        df = self.to_dataframe().stack(level='i', dropna=True).reset_index()
        df['i'] += shift
        df['j'] += shift
        iotools._write_gridext_file(df, outfile)
        return df
Exemple #2
0
    def writeGEFDCControlFile(self, outputdir=None, filename='gefdc.inp',
                              bathyrows=0, title='test'):
        """
        Generates the GEFDC control (gefdc.inp) file for the EFDC grid
        preprocessor.

        Parameters
        ----------
        outputdir : str, optional
            The path to where the should be saved.
        filename : str, optional
            The name of the output file.
        bathyrows : int, optional
            The number of rows in the grid's bathymetry data file.
        title : str, optional
            The title of the grid as portrayed in ``filename``.

        Returns
        -------
        gefdc : str
            The text of the output file.

        """

        outfile = iotools._outputfile(outputdir, filename)

        gefdc = iotools._write_gefdc_control_file(
            outfile,
            title,
            self.inodes + 1,
            self.jnodes + 1,
            bathyrows
        )
        return gefdc
Exemple #3
0
    def writeGEFDCCellFile(self, outputdir=None, filename='cell.inp',
                           triangles=False, maxcols=125):
        """
        Generates the cell definition/ASCII-art file for GEFDC.

        .. warning:
           This whole thing is probably pretty buggy.

        Parameters
        ----------
        outputdir : str, optional
            The path to where the should be saved.
        filename : str, optional
            The name of the output file.
        triangles : bool, optional
            Toggles the inclusion of triangular cells.

            .. warning:
               This is experimental and probably buggy if it has been
               implmented at all.

        maxcols : int, optional
            The maximum number of columns to write to each row. Cells
            beyond this number will be writted in separate section at
            the bottom of the file.

        Returns
        -------
        cells : str
            The text of the output file.

        """

        cells = misc.make_gefdc_cells(
            ~np.isnan(self.xn), self.cell_mask, triangles=triangles
        )
        outfile = iotools._outputfile(outputdir, filename)

        iotools._write_cellinp(cells, outputfile=outfile,
                               flip=True, maxcols=maxcols)
        return cells
Exemple #4
0
    def writeGEFDCGridFile(self, outputdir=None, filename='grid.out'):
        """
        Writes to the nodes as coordinate pairs for GEFDC.

        Parameters
        ----------
        outputdir : str, optional
            The path to where the should be saved.
        filename : str, optional
            The name of the output file.

        Returns
        -------
        df : pandas.DataFrame
            The dataframe of node coordinate pairs.

        """

        outfile = iotools._outputfile(outputdir, filename)
        df = iotools._write_gridout_file(self.xn, self.yn, outfile)
        return df
Exemple #5
0
 def test_withNone(self):
     nt.assert_equal(
         iotools._outputfile(None, 'that.txt'),
         os.path.join('.', 'that.txt')
     )
Exemple #6
0
 def test_basic(self):
     nt.assert_equal(
         iotools._outputfile('this', 'that.txt'),
         os.path.join('this', 'that.txt')
     )