  Context. Understanding the 3D magnetic field as well as the plasma in the
chromosphere and transition region is important. One way is to extrapolate the
magnetic field and plasma from the routinely measured vector magnetogram on the
photosphere based on the assumption of the magnetohydrostatic (MHS) state.
However, photospheric data may be inconsistent with the MHS assumption.
Therefore, we must study the restriction on the photospheric magnetic field,
which is required by the MHS system. Moreover, the data should be transformed
accordingly before MHS extrapolations can be applied.
  Aims. We aim to obtain a set of surface integrals as criteria for the MHS
system and use this set of integrals to preprocess a vector magnetogram.
  Methods. By applying Gauss' theorem and assuming an isolated active region on
the Sun, we related the magnetic energy and forces in the volume to the surface
integral on the photosphere. The same method was applied to obtain restrictions
on the photospheric magnetic field as necessary criteria for a MHS system. We
used an optimization method to preprocess the data to minimize the deviation
from the criteria as well as the measured value.
  Results. By applying the virial theorem to the active region, we find the
boundary integral that is used to compute the energy of a force-free field
usually underestimates the magnetic energy of a large active region. We also
find that the MHS assumption only requires the x-, y-component of net Lorentz
force and the z-component of net torque to be zero. These zero components are
part of Aly's criteria for a force-free field. However, other components of net
force and torque can be non-zero values. According to new criteria, we
preprocess the magnetogram to make it more consistent with the MHS system and,
at the same time close, to the original data.
