This is usually achieved by observing a bright, unresolved source which is called a calibrator. In the case of a synthesis array like, for e.g., the GMRT, the gain calibration amounts to estimating the gains of the individual antennas in the array. The gains of any given pair of antennas reflect in the visibility (or the cross correlation) of the calibrator measured by them. In an array with N antennas, there are N(N-1)/2 independent estimates of the calibrator (an unresolved bright source) visibility at any give instant of time. However, there are only 2N unknowns, viz., N amplitudes and N phases of the N antennas. Hence, the measured visibilities can be used in a set of simultaneous equations to solve for these 2N unknowns. In practice, a calibrator close (in direction) to the source is observed for a suitable length of time using the same setup as that for the spectral line observations towards the source. A suitable number of spectral channels are averaged to improve the signal-to-noise ratio on the calibrator which is then used to estimate the gains of the antennas. Apart from the instrumental part, the gains include atmospheric offsets/contributions also. The proximity of the calibrator to the source ensures that the atmospheric offsets/contributions are similar in both observations and hence get corrected for through the calibration process.
How often does one do the calibration depends on various factors, like for e.g., the observing frequency, the length of the baseline involved, the telescope characteristics, the time scale for variations in the atmospheric offsets/contributions, etc.. The frequency of calibration can vary from once in 10 minutes to once in an hour depending on these factors.