Example 3 (12th "Hope Cup" Senior High School Competition Question) The water depth $y$ (meters) at a certain port is a function of time $t(0 \leqslant t \leqslant 24$, unit: hours), and the following is the water depth table for the port:
\begin{tabular}{|c|c|c|c|c|c|c|c|c|}
\hline$t$ (hours) & 0 & $\cdots$ & 3 & $\cdots$ & 9 & $\cdots$ & 15 & $\cdots$ \\
\hline$y$ (meters) & 10 & $\cdots$ & 13 & $\cdots$ & 7 & $\cdots$ & 13 & $\cdots$ \\
\hline
\end{tabular}

After long-term observation, the drawn curve is shown in Figure 4-1-2. After fitting, the curve can be approximately regarded as the graph of the sine function $y=A \sin \omega t+B$.
(1) Try to find the expression of the function $y=A \sin \omega t+B$ based on the data table and the curve;
(2) Generally, it is safe for a ship to navigate when the distance between the ship's bottom and the seabed is not less than 4.5 meters. If a certain ship has a draft (the distance between the ship's bottom and the water surface) of 7 meters, at what time can the ship safely enter the port? If the ship wishes to leave the port safely on the same day, how long can it stay in the port at most? (Neglect the time required for leaving the port)


(1) From the conditions, we easily get
$A=3$, the smallest positive period $T=12, B=10$,

so $\omega=\frac{2 \pi}{T}=\frac{\pi}{6}$, thus $y=3 \sin \frac{\pi t}{6}+10$.
(2) Suppose $0 \leqslant t \leqslant 12$, for the ship to enter the port safely, it must satisfy
$$
3 \sin \frac{\pi t}{6}+10 \geqslant 7+4.5,
$$

so
$$
\sin \frac{\pi t}{6} \geqslant \frac{1}{2} \text {. }
$$

Since
$$
0 \leqslant \frac{\pi t}{6} \leqslant 2 \pi,
$$

we have $\frac{\pi}{6} \leqslant \frac{\pi t}{6} \leqslant \frac{5 \pi}{6}$, i.e., $1 \leqslant t \leqslant 5$.
Therefore, the ship can enter the port safely from 1:00 to 5:00 or from 13:00 to 17:00.
If the ship is to dock on the same day, it can enter the port at 1:00 and leave at 17:00 in the evening, so the maximum time it can stay in the port is 16 hours.