thank you for the details,
Just a technical question, they opened a big hole to replace the sonar, but when they re-weld the section back, would it have the same strength as the original hull?
It can if done properly, sometimes the weld is even stronger.
But the sonar dome is not part of the pressure hull, and there is little or no pressure differential across is. That is why the material in the pictures looks so thin, strength is not as much of a problem. But the welding has to be done exactly right or you get irregularities in the sonar reception.
The pressure hull is much thicker and has reinforcing stiffener rings. Welding it, because of the thickness and criticality, is one of the trickiest, and most inspected, parts of building the submarine, and will frequently require a weld to be redone several times to get it right. Generally, if it becomes necessary to gain access, you go in through a prearranged hard patch on the hull, there is generally one over the engine room and sometimes another one over the torpedo room. The most common alternative is radial cut dividing the submarine into 2 pieces perpendicular to the long access, which also required you to generally cut or remove everything (and that means EVERYTHING -- plumbing, controls, wiring, and anything else) that passes through the plane of the cut. This avoid the stiffener rings and allows the pressure hull to be reassembled with a single, continuous, inspectable, weld. Then you rebuild everything outside the pressure hull. And finally you have to go through a series of acceptance trials, just like for a new submarine, to confirm you put everything back together right. It is only probably only 40% to 60% cheaper than buying a new submarine. But if you want (and if you are going to go through that much work already it is a minor addition), and the original design permits, you can lengthen the hull at the same time by inserting a section.