## 2 Materials and Methods
### Retrieval Algorithms
#### 2.2.4 Cloud Detection and Flagging
Since cloud conditions within the field of view of a MAX-DOAS telescope usually vary on short time scales (except for stratiform cloud cover), rapid changes in any of the quantities listed above indicate the appearance or disappearance of clouds or a change in cloud properties. Cloud classification algorithms have been presented in different studies. [PERSON] et al. [41] use a simple criterion to screen cloudy scenes based on a CI, using the wavelengths 500 nm and 380 nm. A simple cloud flag is defined with a CI value above 1.5, whereby the SZA dependence of the CI for cloud-free sky is ignored. In addition, [PERSON] et al. [41] calculate a cloud-base height based on relative humidity derived from the H\({}_{2}\)O profiles retrieved with MAX-DOAS. [PERSON] et al. [42] present a \"simple and versatile cloud-screening method for MAX-DOAS retrievals\". Three different flags are derived:  
1. Sky condition flag, derived from the CI, classifies a 90\({}^{\circ}\) measurement as either \"good\", \"mediocre\" or \"bad\" (Figure 4). 2. A broken cloud flag, derived from rapid changes in the CI. 3. A multiple scattering flag, derived from rapid changes in the O\({}_{4}\) DSCD (30-90\({}^{\circ}\)), is needed to identify clouds in presence of high aerosol load. Figure 4: **Top**: Zenith CI values and frequency distribution for Xianghe. **Bottom**: the normalised CI values (points) versus SZA. The green, orange and red regions correspond to the “good”, “mediocre” and “bad” regions as defined by the sky flag. Figures taken from [42]. Generally, these flags can all identify clouded scenes, as demonstrated by comparisons with cloud cover determined in the thermal IR. The cloud flags were derived for three different instruments under different atmospheric conditions, and the CI was defined differently for all three instruments. The sky condition flag requires radiative transfer calculations for each CI definition to account for the SZA dependency, and the measured time series needs to be sufficiently long to be able to normalise the CI between the extremes (maximum: cloud-free; minimum: clouded). [PERSON] et al. [43] presented a multi-step cloud classification scheme to categorise the cloud conditions for individual MAX-DOAS elevation sequences. The classification identifies clear sky conditions based on the absolute value of the CI at zenith and uses its temporal variability to detect rapid changes in cloudiness, corresponding to clear sky between clouds or broken clouds. The variability of the CI with elevation angles is used to detect continuous clouds (low variability) or clear sky conditions with high aerosol load (high variability, while CI at zenith varies smoothly with time). In addition, in case of a low CI, the O4 SCD and its elevation angle dependency are used to detect thick clouds and fog, respectively. The full scheme is shown in Figure 5.  
This algorithm has been demonstrated to successfully classify various cloud conditions from the MAX-DOAS measurements themselves. However, the given thresholds for the CI have to be derived separately for each specific instrument. An application of the cloud classification scheme to measurements from a different instrument required several modifications [44]. As for the algorithm of [PERSON] et al. [42], and also for the algorithm by [PERSON] et al. [43], the measured time series needs to be sufficiently long in order to provide good statistics for the different cloud conditions. A few years later, [PERSON] et al. [45] presented an updated cloud classification scheme. It is generally based on the scheme presented in [43] but now includes absolute calibration procedures for the CI and the O4 SCDs based on Radiative Transport Model (RTM) calculations under well-defined atmospheric conditions and viewing geometries. With these calibrations, the cloud classification scheme is applicable to any MAX-DOAS measurement time series. Figure 5: Cloud classification scheme.