## 3 Establishment of the Flow Prediction Model  
### Traditional Water Measurement Method  
Traditional water measurement methods are basically empirical formula methods. Based on the specific situation of the main canals in various plain irrigation areas, Reference [13] re-determined the relationship between water level and flow rate and obtained a suitable method for determining the water flow pattern in plain irrigation areas and corresponding flow calculation formulas. In the practical application of gates in plain irrigation areas, there are relatively few states of the free outflow with the gate fully open and submerged outflow with the gate fully open; therefore, they are collectively referred to as weir flow. The main flow pattern includes free outflow with gate control (FOG), submerged outflow with gate control (SOG), and weir flow (WF). The traditional water measurement method uses the least-squares method mentioned for flow calculation in the Reference [13], which includes two steps: selecting the flow calculation formula and determining the flow coefficient. The first step is to determine the flow pattern based on the gate opening (\(E\)), upstream water level (\(H\)), and downstream water level (\(h\)). The second step is to substitute the known parameters into the calculation formulas for different flow patterns and use the least-squares method to fit the flow coefficient. The flow calculation formula for free outflow with gate control and submerged outflow with gate control is as follows:  
\[Q=MBE\sqrt{Z} \tag{1}\]  
where \(B\) is the gate width; \(E\) is the gate opening; \(Z\) is the difference between the upstream water level and the downstream water level; and \(M\) is the flow coefficient. The flow coefficient \(M\) in Equation (1) can be expressed as a higher-order polynomial, and it takes the form:  
\[M(X)=k_{1}X^{n}+k_{2}X^{n-1}+k_{3}X^{n-2}+\cdots+k_{n}X+k_{0} \tag{2}\]  
where \(k_{1}\), \(k_{2}\), \(k_{3}\), and \(k_{\mathrm{n}}\) are the undetermined coefficients and \(k_{0}\) is the undetermined constant, \(X=E/Z\). By fitting the \(M\)-\(X\) curve, each undetermined coefficient can be obtained. The flow calculation formula for weir flow can be expressed as  
\[Q=aH^{n} \tag{3}\]  
where \(a\) and \(n\) are the undetermined coefficients, which can be obtained by directly fitting the \(Q\)-\(H\) curve. The division of some flow patterns in the training samples is shown in Table 1. The fitting of different flow patterns using the least-squares method is shown in Figure 3. Due to the large number of training samples, we only selected 5 sets of data for each flow pattern and presented them in Table 1. In Figure 3, the data for all flow patterns are presented. The calculation formula for the flow coefficient of the free outflow with gate control is as follows:  
\[M=0.0004X^{6}-0.0028X^{5}+0.0085X^{4}-0.013X^{3}+0.0101X^{2}-0.0034X+0.0007 \tag{4}\]  
The calculation formula for the flow coefficient of the submerged outflow with gate control is as follows:  
\[M=9\times 10^{-8}X^{6}+10^{-6}X^{5}-7\times 10^{-5}X^{4}+0.0009X^{3}-0.0046X^{ 2}+0.0109X-0.0088 \tag{5}\]The flow calculation formula for weir flow is as follows:  
\[Q = 10^{-6}H^{3.0769} \tag{6}\]