# VIIRS Day/Night Band--Correcting Striping and Nonuniformity over a Very Large Dynamic Range
## 2 Materials and Methods
### Histogram Matching Method Destriping Algorithm Description
Determining the uniformity by comparing adjacent detectors would not work because the striping itself causes nonuniformity and such a test would exclude out-of-family detectors more often than in-family detectors. So instead, the detector radiance is subtracted from the radiance in the next scan, and the ratio is taken relative to their mean value. If the ratio is too large, then both of the pixel's radiances are excluded from the ensemble. This test creates a problem with very dark scenes, so there is a minimum radiance at which this test is applied. However, as explained above, in order to avoid excluding some detectors more than others, if any of the detectors is below a threshold radiance, then the uniformity test is not applied. If the DNB SDR product is used, there is no information in it regarding gain stage for a given pixel, but this information is available from the Raw Data Record that contains the digital counts and a flag indicating gain stage. The gain stage flag could be determined and used as a filter, but the problem is the same as with using a radiance threshold as explained above. However, if the same threshold criteria are used as with the radiance threshold then this is a valid filter. We have found that the most useful filtering is by solar zenith angle. This method is detector agnostic, and is available as part of the geolocation in the SDR. Solar zenith angle clearly divides daytime, twilight and nighttime into separate ensembles and therefore limits the dynamic range of each ensemble. We divide the twilight into four solar zenith angle ranges in order to limit the dynamic range of each ensemble to about two orders of magnitude. We can also use the lunar zenith angle as a filter. Lunar phase does not change much over a single day, and we have not produced ensembles using data from multiple days. However, the lunar phase is important when corrections from one month are used at the same lunar phase in other months. We found that these corrections are stable enough to perform well for one lunar month before or after the date on which the ensemble is collected. Once the filtered ensemble has been assembled, we create a cumulative histogram for each detector in each aggregation zone. We also create a cumulative distribution function of the combined ensemble of all detectors within an aggregation zone. These are actually inverse cumulative histograms in that they provide a radiance at a specific cumulative level. For example, if we specify the number of histogram levels is 6, then to create the cumulative distribution function, the radiances are sorted into five quintiles, and the cumulative distribution function is the set of six radiance values at the boundaries of the quintiles. The radiance at each cumulative level for each detector is compared with the radiance of the distribution function for the combined ensemble at that same level. The difference is the error that needs to be corrected in order to destripe the image. Using this combined approach guarantees that the overall radiometric error for all detectors does not increase due to destriping. The success or failure of this method depends on the exact filtering processes that are done as well as specific parameters such as the number of levels to use in the cumulative distribution function. These details were worked out through a process of trial and error until the best combination of filter parameters and levels was found. In the _Results_ section we show the results of this trial-and-error process.