示例#1
0
def save_count_per_day_to_file(h_list, hyrax_dict):
    date_times = h.initialize_specific_range()

    for i in h_list:

        for j in h_list:
            if i != j:
                if os.path.isfile(list_prefix.format('day', str(i), str(j))):
                    continue
                days_count = [0] * 61
                night_count = [0] * 61
                mtx_a = h.load_lil(h.get_npz_file_name(i, j))
                non_zero = mtx_a.nonzero()[1]

                for v in non_zero:
                    date, time, night = h.get_time_of_day(date_times, v)
                    delta = date - start_date
                    if night == 1:
                        night_count[delta.days] += 1
                    else:
                        days_count[delta.days] += 1

                save_list(list_prefix.format('day', str(i), str(j)),
                          days_count)
                save_list(list_prefix.format('night', str(i), str(j)),
                          night_count)
示例#2
0
def save_count_per_hour_to_file(h_list):
    date_times = h.initialize_specific_range()
    for i in h_list:
        for j in h_list:
            if i != j:
                if os.path.isfile(list_hours_prefix.format(i, j)):
                    continue
                days_count = []
                for e in range(61):
                    days_count.append([0] * 24)
                # days_count = [[0] * 24] * 61
                # days_count[2][4] = 5
                mtx_a = h.load_lil(h.get_npz_file_name(i, j))
                non_zero = mtx_a.nonzero()[1]
                for v in non_zero:
                    date, time, night = h.get_time_of_day(date_times, v)
                    delta_days = date - start_date
                    days_count[delta_days.days][time.hour] += 1
                save_list(list_hours_prefix.format(i, j), days_count)