def create_intermittent_period_test_files(path, period_units, period_length, num_periods, start_datetime, prefix='',
                                          suffix='_.mrf', prototype_file=None, make_year_dirs=False, no_files=False):
    """
    Fills a directory structure with files that have an intermittent period
    using the specified parameters. Returns a list of all the date intervals
    that were created.
    Arguments:
        path -- base directory tree to populate.
        period_units -- unit size of each period in 'days', 'months', or 'years'.
        period_length -- the length of each period in the aforementioned units
        num_periods -- the number of interval pairs to create.
        start_date -- a datetime.date object with the desired start date
        prefix -- (optional) a string to append to the beginning of each filename.
        suffix -- (optional) a string to append to the end of each filename.
        prototype_file -- (optional) a prototype file to create each copy from (otherwise creates just empty files).
        make_year_dirs -- (optional) choose to create separate year dirs for the created files instead of dumping them all
            in one dir.
        no_files -- (optional) returns a list of dates but creates no files.
    """
    if not no_files:
        make_dir_tree(path)
    # Create a list of date intervals, each separated by the specified period length
    test_dates = []
    year_dir = ''
    for x in range(num_periods):
        # Create a new start date and end date for each interval requested
        interval_set = []
        for y in range(1, 5):
            date = start_datetime + relativedelta(**{period_units: period_length * y})
            interval_set.append(date)
        test_dates.append(interval_set)

        # Push the start time of the next interval to twice the period distance from the end of the last interval
        start_datetime = interval_set[-1] + relativedelta(**{period_units: period_length * 2})

        if not no_files:
            if any(unit in period_units for unit in ('hours', 'minutes', 'seconds')):
                subdaily = True
            else:
                subdaily = False

            # If this is the first date or it has a different year than the previous, create that dir
            if make_year_dirs and (not x or test_dates[-1][-1].year != date.year):
                year_dir = str(date.year)
                make_dir_tree(os.path.join(path, year_dir))
            for interval in interval_set:
                if subdaily is True:
                    time_string = str(interval.hour).zfill(2) + str(interval.minute).zfill(2) + str(interval.second).zfill(2)
                else:
                    time_string = ''
                filename = prefix + str(interval.year) + str(interval.timetuple().tm_yday).zfill(3) + time_string + suffix
                output_path = os.path.join(path, year_dir)
                output_file = os.path.join(output_path, filename)

                if prototype_file:
                    try:
                        copyfile(prototype_file, output_file)
                    except __HOLE__:
                        pass
                else:
                    open(output_file, 'a').close()
    return test_dates
dataset/ETHPy150Open nasa-gibs/onearth/src/test/oe_test_utils.py/create_intermittent_period_test_files