  In this paper, we focus on the following question. Assume $\phi$ is a
discrete Gaussian free field (GFF) on $\Lambda \subset \frac 1 n \mathbb{Z}^2$
and that we are given $e^{iT \phi}$, or equivalently $\phi \pmod{\frac {2\pi}
T}$. Can we recover the macroscopic observables of $\phi$ up to $o(1)$
precision? We prove that this statistical reconstruction problem undergoes the
following Kosterlitz-Thouless type phase transition:
  -) If $T<T_{rec}^-$ , one can fully recover $\phi$ from the knowledge of
$\phi \pmod{\frac {2\pi} T}$. In this regime our proof relies on a new type of
Peierls argument which we call annealed Peierls argument and which allows us to
deal with an unknown quenched groundstate.
  -) If $T>T_{rec}^+$, it is impossible to fully recover the field $\phi$ from
the knowledge of $\phi \pmod{\frac {2\pi} T}$. To prove this result, we
generalise the delocalisation theorem by Fr\"ohlich-Spencer to the case of
integer-valued GFF in an inhomogeneous medium. This delocalisation result is of
independent interest and we give an application of our techniques to the {\em
random-phase Sine-Gordon model} in Appendix B. Also, an interesting connection
with Riemann-theta functions is drawn along the proof.
  This statistical reconstruction problem is motivated by the two-dimensional
XY and Villain models. Indeed, at low-temperature $T$, the large scale
fluctuations of these continuous spin systems are conjectured to be governed by
a Gaussian free field. It is then natural to ask if one can recover the
underlying macroscopic GFF from the observation of the spins of the XY or
Villain model.
  Another motivation for this work is that it provides us with an ``integrable
model'' (the GFF) that undergoes a KT transition.
