  Inversion techniques applied to the radiative transfer equation for polarized
light are capable of inferring the physical parameters in the solar atmosphere
(temperature $T$, magnetic field ${\bf B}$, and line-of-sight velocity $v_{\rm
los}$) from observations of the Stokes vector (i.e., spectropolarimetric
observations) in spectral lines. Inferences are usually performed in the
$(x,y,\tau_c)$ domain, where $\tau_c$ refers to the optical-depth scale.
Generally, their determination in the $(x,y,z)$ volume is not possible due to
the lack of a reliable estimation of the gas pressure, particularly in regions
of the solar surface harboring strong magnetic fields. We aim to develop a new
inversion code capable of reliably inferring the physical parameters in the
$(x,y,z)$ domain. We combine, in a self-consistent way, an inverse solver for
the radiative transfer equation (Firtez-DZ) with a solver for the
magneto-hydrostatic (MHS) equilibrium, which derives realistic values of the
gas pressure by taking the magnetic pressure and tension into account. We test
the correct behavior of the newly developed code with spectropolarimetric
observations of two sunspots recorded with the spectropolarimeter (SP)
instrument on board the Hinode spacecraft, and we show how the physical
parameters are inferred in the $(x,y,z)$ domain, with the Wilson depression of
the sunspots arising as a natural consequence of the force balance. In
particular, our approach significantly improves upon previous determinations
that were based on semiempirical models. Our results open the door for the
possibility of calculating reliable electric currents in three dimensions,
${\bf j}(x,y,z)$, in the solar photosphere. Further consistency checks would
include a comparison with other methods that have recently been proposed and
which achieve similar goals.
