# Path: polyadcirc/pyADCIRC/fort13_management.py
# def write_manningsn(fid, node, value):
#     """
#     Write out a formated node value line to fid
# 
#     :type fid: :class:`file`
#     :param fid: the file object to be written to
#     :type node: int
#     :param node: the node number
#     :type value: float
#     :param value: the nodal value
#     :rtype: string
#     :return: formatted string for a line in a ``fort.13`` formatted file
# 
#     """
#     return fid.write('{:<8d} {:17.15g}\n'.format(int(node), value))
# 
# def read_manningsn(fid):
#     """
#     Reads in a node value line from fid
# 
#     
#     :type fid: :class:`file`
#     :param fid: the file object to be read from we might want to re write this
#         as the fromstring method returns an array :rtype: :class:`numpy.ndarray`
#     :return: Returns an array([node, value])
# 
#     """
#     return np.fromstring(fid.readline(), sep=' ')


import re, os, glob
import numpy as np
from polyadcirc.pyADCIRC.fort13_management import write_manningsn,\
        read_manningsn
            if attribute_name_present == 1:
                line = fid_read.readline()
                fid_write.write(line)
                tline_indice = re.match(r"mannings_n_at_sea_floor",
                                        line.strip())
                if tline_indice != None:
                    # read the original number of non-default values in
                    # the fort.13
                    attr_num = np.fromstring(fid_read.readline(), dtype=int,
                                             sep=' ')
                    attribute_name_present = 2
                    tmp = np.fromstring(fid_read514.readline(), dtype=int,
                                        sep=' ')
                    node_num = tmp[1]
                    read_target_nodes = 0

                    if keep_flags == 1:
                        # write out the number of non-default nodes
                        fid_write.write('{:d}\n'.format(node_num))
                    elif keep_flags == 2:
                        # read in and write out the non-default values while
                        # keeping track of missing values
                        missing_val = 0
                        for i in xrange(node_num): # pylint: disable=W0612
                            a = read_manningsn(fid_read514)
                            b = read_manningsn(fid_read)
                            read_target_nodes += 1
                            # add a simple loop to keep in check
                            # with fid_read514
                            while read_target_nodes < attr_num and b[0] < a[0]:

# Path: polyadcirc/pyADCIRC/fort13_management.py
# def write_manningsn(fid, node, value):
#     """
#     Write out a formated node value line to fid
# 
#     :type fid: :class:`file`
#     :param fid: the file object to be written to
#     :type node: int
#     :param node: the node number
#     :type value: float
#     :param value: the nodal value
#     :rtype: string
#     :return: formatted string for a line in a ``fort.13`` formatted file
# 
#     """
#     return fid.write('{:<8d} {:17.15g}\n'.format(int(node), value))
# 
# def read_manningsn(fid):
#     """
#     Reads in a node value line from fid
# 
#     
#     :type fid: :class:`file`
#     :param fid: the file object to be read from we might want to re write this
#         as the fromstring method returns an array :rtype: :class:`numpy.ndarray`
#     :return: Returns an array([node, value])
# 
#     """
#     return np.fromstring(fid.readline(), sep=' ')


# Path: polyadcirc/pyADCIRC/convert_fort14_to_fort13.py
import re, os, glob
import numpy as np
from polyadcirc.pyADCIRC.fort13_management import write_manningsn,\
        read_manningsn

            if attribute_name_present == 1:
                line = fid_read.readline()
                fid_write.write(line)
                tline_indice = re.match(r"mannings_n_at_sea_floor",
                                        line.strip())
                if tline_indice != None:
                    # read the original number of non-default values in
                    # the fort.13
                    attr_num = np.fromstring(fid_read.readline(), dtype=int,
                                             sep=' ')
                    attribute_name_present = 2
                    tmp = np.fromstring(fid_read514.readline(), dtype=int,
                                        sep=' ')
                    node_num = tmp[1]
                    read_target_nodes = 0

                    if keep_flags == 1:
                        # write out the number of non-default nodes
                        fid_write.write('{:d}\n'.format(node_num))
                    elif keep_flags == 2:
                        # read in and write out the non-default values while
                        # keeping track of missing values
                        missing_val = 0
                        for i in xrange(node_num): # pylint: disable=W0612
                            a = read_manningsn(fid_read514)
                            b = read_manningsn(fid_read)
                            read_target_nodes += 1
                            # add a simple loop to keep in check
                            # with fid_read514
                            while read_target_nodes < attr_num and b[0] < a[0]:

                                b = read_manningsn(fid_read)