I understand that when we have a polynomial a semicircle is used because the poles are included in the contour when doing so but in the following example a rectangle has been used and I am struggling to understand how to come up with this i.e. what the reasoning behind it is.
10.3.2 Computing $\widehat{f}(\xi)$, and hence $\phi(\xi, x)$, by using the CRT:
Next we are going to show that the function $f: \mathbb{R}^{1} \rightarrow \mathbb{R}^{1}, f(x)=\operatorname{sech}(\pi x)$, has Fourier transform $$ \hat{f}(\xi)=\operatorname{sech}(\xi / 2), \quad \xi \in \mathbb{R}^{1} $$ To do that, consider the contour integral $$ \int_{\gamma_{n}} e^{i \xi z} \operatorname{sech}(\pi z) d z \quad \text { with } \xi>0 $$ around the finite rectangle $\gamma_{n}$ in $\mathbb{C}=\{x+i y\}$ bounded by the lines $$ y=0, \quad y=n+1, \quad x=-n-1, \quad x=n+1 $$ with $n$ a positive integer.


Fourier transform integrals are commonly treated using a rectangular contour, possibly with semicircular bumps to avoid poles on the real axis. The reason for a rectangular contour is that the factor $e^{i\xi z}$ is easily understood on such a contour. If we write $z = x+iy$, then on vertical lines $x = M$, $e^{i\xi z} = e^{i M\xi}e^{-i\xi y}$. Similarly on horizontal lines $y=N>0$ we have $e^{i\xi z} = e^{i\xi x}e^{-\xi N}$.
For reasonable choices of $f$ in the contour integral $\int e^{i\xi z}f(z)~dz$, you can control three of the pieces of the contour easily. On the vertical lines you will want to use decay of $f(x+iy)$ in the horizontal direction, as you let $M \to \pm\infty$. On the horizontal line $y=N>0$, you can use the exponential decay from $e^{-\xi N}$ to help you bound the integral.