def _writeCrossSectionLink(self, link, fileObject, replaceParamFile):
        """
        Write Cross Section Link to File Method
        """
        linkType = link.type

        # Write cross section link header
        dx = vwp(link.dx, replaceParamFile)
        try:
            fileObject.write('DX             %.6f\n' % dx)
        except:
            fileObject.write('DX             %s\n' % dx)

        fileObject.write('%s\n' % linkType)
        fileObject.write('NODES          %s\n' % link.numElements)

        for node in link.nodes:
            # Write node information
            fileObject.write('NODE %s\n' % node.nodeNumber)
            fileObject.write('X_Y  %.6f %.6f\n' % (node.x, node.y))
            fileObject.write('ELEV %.6f\n' % node.elevation)

            if node.nodeNumber == 1:
                # Write cross section information after first node
                fileObject.write('XSEC\n')

                # Cases
                if 'TRAPEZOID' in linkType or 'TRAP' in linkType:
                    # Retrieve cross section
                    xSec = link.trapezoidalCS

                    # Write cross section properties
                    mannings_n = vwp(xSec.mannings_n, replaceParamFile)
                    bottomWidth = vwp(xSec.bottomWidth, replaceParamFile)
                    bankfullDepth = vwp(xSec.bankfullDepth, replaceParamFile)
                    sideSlope = vwp(xSec.sideSlope, replaceParamFile)

                    try:
                        fileObject.write('MANNINGS_N     %.6f\n' % mannings_n)
                    except:
                        fileObject.write('MANNINGS_N     %s\n' % mannings_n)

                    try:
                        fileObject.write('BOTTOM_WIDTH   %.6f\n' % bottomWidth)
                    except:
                        fileObject.write('BOTTOM_WIDTH   %s\n' % bottomWidth)

                    try:
                        fileObject.write('BANKFULL_DEPTH %.6f\n' % bankfullDepth)
                    except:
                        fileObject.write('BANKFULL_DEPTH %s\n' % bankfullDepth)

                    try:
                        fileObject.write('SIDE_SLOPE     %.6f\n' % sideSlope)
                    except:
                        fileObject.write('SIDE_SLOPE     %s\n' % sideSlope)

                    # Write optional cross section properties
                    self._writeOptionalXsecCards(fileObject=fileObject, xSec=xSec, replaceParamFile=replaceParamFile)

                elif 'BREAKPOINT' in linkType:
                    # Retrieve cross section
                    xSec = link.breakpointCS

                    # Write cross section properties
                    mannings_n = vwp(xSec.mannings_n, replaceParamFile)
                    try:
                        fileObject.write('MANNINGS_N     %.6f\n' % mannings_n)
                    except:
                        fileObject.write('MANNINGS_N     %s\n' % mannings_n)

                    fileObject.write('NPAIRS         %s\n' % xSec.numPairs)
                    fileObject.write('NUM_INTERP     %s\n' % vwp(xSec.numInterp, replaceParamFile))


                    # Write optional cross section properties
                    self._writeOptionalXsecCards(fileObject=fileObject, xSec=xSec, replaceParamFile=replaceParamFile)

                    # Write breakpoint lines
                    for bp in xSec.breakpoints:
                        fileObject.write('X1   %.6f %.6f\n' % (bp.x, bp.y))
                else:
                    log.error('OOPS: MISSED A CROSS SECTION TYPE. CIF LINE 580. {0}'.format(linkType))
def _writeCrossSectionLink ( self , link , fileObject , replaceParamFile ) : linkType = link . type dx = vwp ( link . dx , replaceParamFile ) try : fileObject . write ( 'DX             %.6f\n' % dx ) except : fileObject . write ( 'DX             %s\n' % dx ) fileObject . write ( '%s\n' % linkType ) fileObject . write ( 'NODES          %s\n' % link . numElements ) for node in link . nodes : fileObject . write ( 'NODE %s\n' % node . nodeNumber ) fileObject . write ( 'X_Y  %.6f %.6f\n' % ( node . x , node . y ) ) fileObject . write ( 'ELEV %.6f\n' % node . elevation ) if node . nodeNumber == 1 : fileObject . write ( 'XSEC\n' ) if 'TRAPEZOID' in linkType or 'TRAP' in linkType : xSec = link . trapezoidalCS mannings_n = vwp ( xSec . mannings_n , replaceParamFile ) bottomWidth = vwp ( xSec . bottomWidth , replaceParamFile ) bankfullDepth = vwp ( xSec . bankfullDepth , replaceParamFile ) sideSlope = vwp ( xSec . sideSlope , replaceParamFile ) try : fileObject . write ( 'MANNINGS_N     %.6f\n' % mannings_n ) except : fileObject . write ( 'MANNINGS_N     %s\n' % mannings_n ) try : fileObject . write ( 'BOTTOM_WIDTH   %.6f\n' % bottomWidth ) except : fileObject . write ( 'BOTTOM_WIDTH   %s\n' % bottomWidth ) try : fileObject . write ( 'BANKFULL_DEPTH %.6f\n' % bankfullDepth ) except : fileObject . write ( 'BANKFULL_DEPTH %s\n' % bankfullDepth ) try : fileObject . write ( 'SIDE_SLOPE     %.6f\n' % sideSlope ) except : fileObject . write ( 'SIDE_SLOPE     %s\n' % sideSlope ) self . _writeOptionalXsecCards ( fileObject = fileObject , xSec = xSec , replaceParamFile = replaceParamFile ) elif 'BREAKPOINT' in linkType : xSec = link . breakpointCS mannings_n = vwp ( xSec . mannings_n , replaceParamFile ) try : fileObject . write ( 'MANNINGS_N     %.6f\n' % mannings_n ) except : fileObject . write ( 'MANNINGS_N     %s\n' % mannings_n ) fileObject . write ( 'NPAIRS         %s\n' % xSec . numPairs ) fileObject . write ( 'NUM_INTERP     %s\n' % vwp ( xSec . numInterp , replaceParamFile ) ) self . _writeOptionalXsecCards ( fileObject = fileObject , xSec = xSec , replaceParamFile = replaceParamFile ) for bp in xSec . breakpoints : fileObject . write ( 'X1   %.6f %.6f\n' % ( bp . x , bp . y ) ) else : log . error ( 'OOPS: MISSED A CROSS SECTION TYPE. CIF LINE 580. {0}' . format ( linkType ) )
Write Cross Section Link to File Method