*Generate the survey cadence arrays for each filter*

    **Key Arguments:**
        - ``log`` -- logger
        - ``surveyCadenceSettings`` -- the survey cadence parameters as set in the simulation settings file
        - ``pathToOutputDirectory`` -- path to the output directory (provided by the user)
        - ``pathToOutputPlotDirectory`` -- path to add plots to
        - ``plot`` -- generate plot?

    **Return:**
        - ``cadenceDictionary`` -- a dictionary of { band : observedDayList }

def survey_cadence_arrays(
        log,
        surveyCadenceSettings,
        pathToOutputDirectory,
        pathToOutputPlotDirectory,
        plot=False):
    """
    *Generate the survey cadence arrays for each filter*

    **Key Arguments:**
        - ``log`` -- logger
        - ``surveyCadenceSettings`` -- the survey cadence parameters as set in the simulation settings file
        - ``pathToOutputDirectory`` -- path to the output directory (provided by the user)
        - ``pathToOutputPlotDirectory`` -- path to add plots to
        - ``plot`` -- generate plot?

    **Return:**
        - ``cadenceDictionary`` -- a dictionary of { band : observedDayList }
    """
    ################ > IMPORTS ################
    ## STANDARD LIB ##
    ## THIRD PARTY ##
    ## LOCAL APPLICATION ##
    import numpy as np
    import matplotlib.pyplot as plt

    ################ > VARIABLE SETTINGS ######
    lunarMonth = 29.3
    surveyYear = 12. * lunarMonth
    ################ >ACTION(S) ################
    cadenceDictionary = {}
    obsFraction = surveyCadenceSettings['Observable Fraction of Year']
    lossFraction = surveyCadenceSettings[
        'Fraction of Year Lost to Weather etc']
    for thisFilter in surveyCadenceSettings['Filters']:
        # READ THE CADENCE PARAMETERS
        band = thisFilter['band']
        firstDay = thisFilter['day of year of first scheduled observation']
        repeatEvery = thisFilter['repeat every ? days']
        moonFraction = thisFilter['Fraction of Lunar Month Lost to Moon']

        # DETERMINE DAYS LOST DUE TO MOON CYCLE
        finalObsDayOfMonth = lunarMonth * (1. - moonFraction)
        monthCount = 0
        day = 1
        monthDay = 1
        moonDayList = []
        while day < surveyYear:
            while monthDay < int(lunarMonth):
                if monthDay <= finalObsDayOfMonth:
                    moonDayList.append(day)
                monthDay += 1
                day += 1
            monthCount += 1
            day = int(lunarMonth * monthCount)
            # log.debug('month # %s starts on day %s' % (monthCount, day))
            monthDay = 0

        # DETERMINE THE DAYS THE TELESCOPE OBSERVES IN THIS FILTER
        day = firstDay
        nextObs = firstDay
        obsDaysList = []
        finalObsDayOfYear = obsFraction * surveyYear
        while day <= finalObsDayOfYear:
            randNum = np.random.rand()
            if day == nextObs:
                if day in moonDayList and randNum > lossFraction:
                    obsDaysList.append(day)
                nextObs = day + repeatEvery
            day += 1
            # log.debug('day # %s' % (day,))

        # ADD THE BAND & OBS ARRAY TO THE DICTIONARY
        cadenceDictionary[band] = obsDaysList

    if plot:
        fig = plt.figure(
            num=None,
            figsize=(8, 8),
            dpi=600,
            facecolor=None,
            edgecolor=None,
            frameon=True)

        ax = fig.add_axes(
            [0.1, 0.1, 0.8, 0.8],
            polar=True,
            frameon=False)
        # ax.set_xlabel('label')
        # ax.set_ylabel('label')
        # ax.set_title('title')
        # ax.set_xlim(0, 10)
        ax.set_ylim(0, 12)

        for k, v in cadenceDictionary.iteritems():
            # log.debug('k %s' % (k,))
            x = 2 * np.pi * np.array(v) / surveyYear
            y = np.ones(len(x)) * 10.

            if k in ['g', 'B']:
                color = '#268bd2'
            elif k in ['r', 'V']:
                color = '#859900'
            elif k in ['R', 'i']:
                color = '#cb4b16'
            elif k in ['I', 'z']:
                color = '#dc322f'
            # elif k in ['', '']
            #     color = ''
            else:
                color = '#b58900'

            plt.scatter(
                x,
                y,
                s=50,
                c=color,
                marker='o',
                cmap=None,
                norm=None,
                vmin=None,
                vmax=None,
                alpha=0.5,
                linewidths=None,
                edgecolor='w',
                verts=None,
                hold=True)

        circleTicks = np.arange(0, 350, 30)
        tickLabels = []
        for tick in circleTicks:
            tickLabels.append("%s days" % (tick,))

        plt.xticks(2 * np.pi * circleTicks / surveyYear, tickLabels)
        plt.yticks([])

        title = "Cadence Wheel for Simulated Survey"
        plt.title(title)
        fileName = pathToOutputPlotDirectory + title.replace(" ", "_") + ".png"
        plt.savefig(fileName)
        plt.clf()  # clear figure

    return cadenceDictionary