  Obtaining the magnetic field vector accurately in the solar atmosphere is
essential for studying changes in field topology during flares and to reliably
model space weather. We tackle this problem by applying various inversion
methods to a confined X2.2 flare in NOAA AR 12673 on September 6, 2017,
comparing the photospheric and chromospheric magnetic field vector with those
from two numerical models of this event. We obtain the photospheric field from
Milne-Eddington (ME) and (non-)local thermal equilibrium (non-LTE) inversions
of Hinode SOT/SP Fe I 6301.5{\AA} and 6302.5{\AA}. The chromospheric field is
obtained from a spatially-regularised weak field approximation (WFA) and
non-LTE inversions of Ca II 8542{\AA} observed with CRISP at the Swedish 1-m
Solar Telescope. The LTE- and non-LTE-inferred photospheric field components
are strongly correlated throughout the atmosphere, with stronger field and
higher temperatures in the non-LTE inversions. For the chromospheric field, the
non-LTE inversions correlate well with the spatially-regularised WFA. We find
strong-field patches of over 4.5 kG in the photosphere, co-located with similar
concentrations exceeding 3 kG in the chromosphere. The obtained field strengths
are up to 2-3 times higher than in the numerical models, with more concentrated
and structured photosphere-to-chromosphere shear close to the polarity
inversion line. The LTE and non-LTE Fe I inversions yield essentially the same
photospheric field, while ME inversions fail to reproduce the field vector
orientation where Fe I is in emission. Our inversions confirm the locations of
flux rope footpoints that are predicted by numerical models. However,
pre-processing and lower spatial resolution lead to weaker and smoother field
in the models than what the data indicate. This emphasises the need for higher
spatial resolution in the models to better constrain pre-eruptive flux ropes.
