コード例 #1
0
def unittest_timeToHourOfDay():
    print("unittest_timeToHourOfDay")

    date = "00:00"
    result = FeatureData.timeToHourOfDay(date)
    print(date + ": " + str(result))

    date = "12:00"
    result = FeatureData.timeToHourOfDay(date)
    print(date + ": " + str(result))

    date = "23:59"
    result = FeatureData.timeToHourOfDay(date)
    print(date + ": " + str(result))
コード例 #2
0
def unittest_dateToWeekOfYear():
    print("unittest_dateToWeekOfYear")

    date = "01.01.2020"
    result = FeatureData.dateToWeekOfYear(date)
    print(date + ": " + str(result))

    date = "04.01.2020"
    result = FeatureData.dateToWeekOfYear(date)
    print(date + ": " + str(result))

    date = "05.01.2020"
    result = FeatureData.dateToWeekOfYear(date)
    print(date + ": " + str(result))

    date = "06.01.2020"
    result = FeatureData.dateToWeekOfYear(date)
    print(date + ": " + str(result))

    date = "12.01.2020"
    result = FeatureData.dateToWeekOfYear(date)
    print(date + ": " + str(result))

    date = "13.01.2020"
    result = FeatureData.dateToWeekOfYear(date)
    print(date + ": " + str(result))

    date = "30.01.2020"
    result = FeatureData.dateToWeekOfYear(date)
    print(date + ": " + str(result))
コード例 #3
0
def unittest_dateToDay():
    print("unittest_dateToDay")

    date = "04.05.2020"
    result = FeatureData.dateToDay(date)
    print(date + ": " + str(result))

    date = "05.05.2020"
    result = FeatureData.dateToDay(date)
    print(date + ": " + str(result))

    date = "06.05.2020"
    result = FeatureData.dateToDay(date)
    print(date + ": " + str(result))

    date = "07.05.2020"
    result = FeatureData.dateToDay(date)
    print(date + ": " + str(result))

    date = "08.05.2020"
    result = FeatureData.dateToDay(date)
    print(date + ": " + str(result))

    date = "09.05.2020"
    result = FeatureData.dateToDay(date)
    print(date + ": " + str(result))

    date = "10.05.2020"
    result = FeatureData.dateToDay(date)
    print(date + ": " + str(result))
コード例 #4
0
def unittest_dateToIsWeekend():
    print("unittest_isWeekend")

    date = "04.05.2020"
    result = FeatureData.dateToIsWeekend(date)
    print(date + ": " + str(result))

    date = "05.05.2020"
    result = FeatureData.dateToIsWeekend(date)
    print(date + ": " + str(result))

    date = "06.05.2020"
    result = FeatureData.dateToIsWeekend(date)
    print(date + ": " + str(result))

    date = "07.05.2020"
    result = FeatureData.dateToIsWeekend(date)
    print(date + ": " + str(result))

    date = "08.05.2020"
    result = FeatureData.dateToIsWeekend(date)
    print(date + ": " + str(result))

    date = "09.05.2020"
    result = FeatureData.dateToIsWeekend(date)
    print(date + ": " + str(result))

    date = "10.05.2020"
    result = FeatureData.dateToIsWeekend(date)
    print(date + ": " + str(result))
コード例 #5
0
ファイル: temp.py プロジェクト: rohezal/buildings
def loadCSVDataAndFillCaches(csv_reader):
    lastdate = ""
    for row in csv_reader:
        row[0] = row[0].replace("\"", "")
        datalist.append(FeatureData(row))
        newdate = row[0].split()[0]

        if (newdate != lastdate):
            isTheSunShining(newdate, "0:00")
            lastdate = newdate
            #print (newdate)

    for datapoint in datalist:
        datapoint.calculateIfSunIsShining()
コード例 #6
0
def unittest_getLastSundayOfMonth():
    print("unittest_getLastSundayOfMonth")

    date = "04.05.2020"
    result = FeatureData.getLastSundayOfMonth(date)
    print(date + ": " + str(result))

    date = "05.05.2020"
    result = FeatureData.getLastSundayOfMonth(date)
    print(date + ": " + str(result))

    date = "16.05.2020"
    result = FeatureData.getLastSundayOfMonth(date)
    print(date + ": " + str(result))

    date = "17.05.2020"
    result = FeatureData.getLastSundayOfMonth(date)
    print(date + ": " + str(result))

    date = "24.05.2020"
    result = FeatureData.getLastSundayOfMonth(date)
    print(date + ": " + str(result))

    date = "30.05.2020"
    result = FeatureData.getLastSundayOfMonth(date)
    print(date + ": " + str(result))

    date = "31.05.2020"
    result = FeatureData.getLastSundayOfMonth(date)
    print(date + ": " + str(result))

    date = "29.04.2020"
    result = FeatureData.getLastSundayOfMonth(date)
    print(date + ": " + str(result))

    date = "27.02.2020"
    result = FeatureData.getLastSundayOfMonth(date)
    print(date + ": " + str(result))
コード例 #7
0
ファイル: temp.py プロジェクト: rohezal/buildings
def temperature_test():
    with open('converted_BRICS.csv') as csv_file_brics:
        csv_reader_brics = csv.reader(csv_file_brics,
                                      delimiter=',',
                                      quoting=csv.QUOTE_NONNUMERIC)
        loadCSVDataAndFillCaches(csv_reader_brics)
        FeatureData.calculateFeatures(datalist)

    with open('yearly.csv') as csv_file:
        csv_reader = csv.reader(csv_file, delimiter=',')
        counter = 0

        temp_germany = []

        for row in csv_reader:
            if counter == 0:
                #print(row[-1])
                counter = counter + 1
                continue
            #print (row[-1])
            temp_germany.append(float(row[-1]))

        temp_germany.sort()
        offset = int(len(temp_germany) / 50)

        avg = average(temp_germany)
        med = statistics.median(temp_germany)
        med_lower = temp_germany[offset]
        med_upper = temp_germany[-offset]

        avg2median = avg / med
        max2min = med_upper / med_lower
        med2max = med / med_upper
        med2min = med / med_lower
        max_minus_min = abs(med_upper - med_lower)

        print(temp_germany)
        print(avg)
        print(med)
        print(med_lower)
        print(med_upper)

        print(avg2median)
        print(max2min)
        print(med2max)
        print(med2min)
        print(max_minus_min)

        #isTheSunShining("2012/1/1", "07:30")
        print("======================================================")
        print(isTheSunShining("2020/3/12", "4:30"))
        print(isTheSunShining("2020/3/12", "7:30"))
        print(isTheSunShining("2020/3/12", "20:30"))
        print(isTheSunShining("2012/1/1", "7:30"))
        print(isTheSunShining("2012/1/1", "6:20"))

        print("======================================================")

        print(FeatureData.cachedIsTheSunShining("2020/3/12", "4:30"))
        print(FeatureData.cachedIsTheSunShining("2020/3/12", "7:30"))
        print(FeatureData.cachedIsTheSunShining("2020/3/12", "20:30"))

        print(
            str(SunAndCalendarData.sunrises["2020/3/12"]) + " " +
            str(SunAndCalendarData.sunsets["2020/3/12"]))

        print("======================================================")
        SunAndCalendarData.sunrises['big'] = datetime.datetime.strptime(
            "8:00", '%H:%M').time()
        SunAndCalendarData.sunrises['small'] = datetime.datetime.strptime(
            "7:00", '%H:%M').time()
        print("Test")
        print(SunAndCalendarData.sunrises["2012/1/1"] <
              SunAndCalendarData.sunrises['big'])
        print(SunAndCalendarData.sunrises["2012/1/1"] <
              SunAndCalendarData.sunrises['small'])
コード例 #8
0
ファイル: temp.py プロジェクト: rohezal/buildings
number_of_arguments = len(sys.argv)
if (number_of_arguments == 2):
    filename = sys.argv[1]

else:
    print(
        "usage: main.py name_of_the_file.csv. Using now converted_BRICS.csv as a default file"
    )
    filename = 'converted_BRICS.csv'

with open(filename) as csv_file_brics:
    csv_reader_brics = csv.reader(csv_file_brics,
                                  delimiter=',',
                                  quoting=csv.QUOTE_NONNUMERIC)
    loadCSVDataAndFillCaches(csv_reader_brics)
    FeatureData.calculateFeatures(datalist)
    print("starting exporter")
    start = time.time()
    FeatureData.exportToCSV(datalist)
    end = time.time()
    print("exporter time " + "%.2f" % (end - start) + " seconds")

    print("starting cached exporter")
    start = time.time()
    #FeatureData.exportToCSVCached(datalist)
    end = time.time()
    print("cached exporter time " + "%.2f" % (end - start) + " seconds")

#=================USER ADJUSTABLE PART END==============================================
コード例 #9
0
def unittest_dateToMonth():
    print("unittest_dateToMonth")
    date = "09.01.2020"
    result = FeatureData.dateToMonth(date)
    print(date + ": " + str(result))

    date = "09.02.2020"
    result = FeatureData.dateToMonth(date)
    print(date + ": " + str(result))

    date = "09.03.2020"
    result = FeatureData.dateToMonth(date)
    print(date + ": " + str(result))

    date = "09.04.2020"
    result = FeatureData.dateToMonth(date)
    print(date + ": " + str(result))

    date = "09.05.2020"
    result = FeatureData.dateToMonth(date)
    print(date + ": " + str(result))

    date = "09.06.2020"
    result = FeatureData.dateToMonth(date)
    print(date + ": " + str(result))

    date = "09.07.2020"
    result = FeatureData.dateToMonth(date)
    print(date + ": " + str(result))

    date = "09.08.2020"
    result = FeatureData.dateToMonth(date)
    print(date + ": " + str(result))

    date = "09.09.2020"
    result = FeatureData.dateToMonth(date)
    print(date + ": " + str(result))

    date = "09.10.2020"
    result = FeatureData.dateToMonth(date)
    print(date + ": " + str(result))

    date = "09.11.2020"
    result = FeatureData.dateToMonth(date)
    print(date + ": " + str(result))

    date = "09.12.2020"
    result = FeatureData.dateToMonth(date)
    print(date + ": " + str(result))
コード例 #10
0
def unittest_dateToSeason():
    print("unittest_dateToSeason")

    date = "01.01.2019"
    result = FeatureData.dateToSeason(date)
    print(date + ": " + str(result))

    date = "01.03.2019"
    result = FeatureData.dateToSeason(date)
    print(date + ": " + str(result))

    date = "19.03.2019"
    result = FeatureData.dateToSeason(date)
    print(date + ": " + str(result))

    date = "20.03.2019"
    result = FeatureData.dateToSeason(date)
    print(date + ": " + str(result))

    date = "21.03.2019"
    result = FeatureData.dateToSeason(date)
    print(date + ": " + str(result))

    date = "01.05.2019"
    result = FeatureData.dateToSeason(date)
    print(date + ": " + str(result))

    date = "20.06.2019"
    result = FeatureData.dateToSeason(date)
    print(date + ": " + str(result))

    date = "21.07.2019"
    result = FeatureData.dateToSeason(date)
    print(date + ": " + str(result))

    date = "01.08.2019"
    result = FeatureData.dateToSeason(date)
    print(date + ": " + str(result))

    date = "01.09.2019"
    result = FeatureData.dateToSeason(date)
    print(date + ": " + str(result))

    date = "01.10.2019"
    result = FeatureData.dateToSeason(date)
    print(date + ": " + str(result))

    date = "01.11.2019"
    result = FeatureData.dateToSeason(date)
    print(date + ": " + str(result))

    date = "01.12.2019"
    result = FeatureData.dateToSeason(date)
    print(date + ": " + str(result))
コード例 #11
0
def unittest_dateToQuarter():
    print("unittest_dateToQuarter")

    date = "01.01.2020"
    result = FeatureData.dateToQuarter(date)
    print(date + ": " + str(result))

    date = "01.03.2020"
    result = FeatureData.dateToQuarter(date)
    print(date + ": " + str(result))

    date = "28.03.2020"
    result = FeatureData.dateToQuarter(date)
    print(date + ": " + str(result))

    date = "29.03.2020"
    result = FeatureData.dateToQuarter(date)
    print(date + ": " + str(result))

    date = "30.03.2020"
    result = FeatureData.dateToQuarter(date)
    print(date + ": " + str(result))

    date = "01.05.2020"
    result = FeatureData.dateToQuarter(date)
    print(date + ": " + str(result))

    date = "29.06.2020"
    result = FeatureData.dateToQuarter(date)
    print(date + ": " + str(result))

    date = "15.07.2020"
    result = FeatureData.dateToQuarter(date)
    print(date + ": " + str(result))

    date = "29.09.2020"
    result = FeatureData.dateToQuarter(date)
    print(date + ": " + str(result))

    date = "30.10.2020"
    result = FeatureData.dateToQuarter(date)
    print(date + ": " + str(result))

    date = "30.11.2020"
    result = FeatureData.dateToQuarter(date)
    print(date + ": " + str(result))

    date = "31.12.2020"
    result = FeatureData.dateToQuarter(date)
    print(date + ": " + str(result))

    date = "29.01.2021"
    result = FeatureData.dateToQuarter(date)
    print(date + ": " + str(result))

    date = "30.12.2021"
    result = FeatureData.dateToQuarter(date)
    print(date + ": " + str(result))
コード例 #12
0
def unittest_isDaylightSavingTime():
    print("unittest_isDaylightSavingTime")

    date = "01.01.2020"
    result = FeatureData.isDaylightSavingTime(date)
    print(date + ": " + str(result))

    date = "01.03.2020"
    result = FeatureData.isDaylightSavingTime(date)
    print(date + ": " + str(result))

    date = "28.03.2020"
    result = FeatureData.isDaylightSavingTime(date)
    print(date + ": " + str(result))

    date = "29.03.2020"
    result = FeatureData.isDaylightSavingTime(date)
    print(date + ": " + str(result))

    date = "30.03.2020"
    result = FeatureData.isDaylightSavingTime(date)
    print(date + ": " + str(result))

    date = "24.05.2020"
    result = FeatureData.isDaylightSavingTime(date)
    print(date + ": " + str(result))

    date = "30.08.2020"
    result = FeatureData.isDaylightSavingTime(date)
    print(date + ": " + str(result))

    date = "23.10.2020"
    result = FeatureData.isDaylightSavingTime(date)
    print(date + ": " + str(result))

    date = "24.10.2020"
    result = FeatureData.isDaylightSavingTime(date)
    print(date + ": " + str(result))

    date = "25.10.2020"
    result = FeatureData.isDaylightSavingTime(date)
    print(date + ": " + str(result))

    date = "26.10.2020"
    result = FeatureData.isDaylightSavingTime(date)
    print(date + ": " + str(result))

    date = "25.12.2020"
    result = FeatureData.isDaylightSavingTime(date)
    print(date + ": " + str(result))
コード例 #13
0
def unittest_dateToIsHeatingPeriod():
    print("unittest_dateToIsHeatingPeriod")
    date = "09.01.2020"
    result = FeatureData.dateToIsHeatingPeriod(date)
    print(date + ": " + str(result))

    date = "09.02.2020"
    result = FeatureData.dateToIsHeatingPeriod(date)
    print(date + ": " + str(result))

    date = "09.03.2020"
    result = FeatureData.dateToIsHeatingPeriod(date)
    print(date + ": " + str(result))

    date = "09.04.2020"
    result = FeatureData.dateToIsHeatingPeriod(date)
    print(date + ": " + str(result))

    date = "09.05.2020"
    result = FeatureData.dateToIsHeatingPeriod(date)
    print(date + ": " + str(result))

    date = "09.06.2020"
    result = FeatureData.dateToIsHeatingPeriod(date)
    print(date + ": " + str(result))

    date = "09.07.2020"
    result = FeatureData.dateToIsHeatingPeriod(date)
    print(date + ": " + str(result))

    date = "09.08.2020"
    result = FeatureData.dateToIsHeatingPeriod(date)
    print(date + ": " + str(result))

    date = "09.09.2020"
    result = FeatureData.dateToIsHeatingPeriod(date)
    print(date + ": " + str(result))

    date = "09.10.2020"
    result = FeatureData.dateToIsHeatingPeriod(date)
    print(date + ": " + str(result))

    date = "09.11.2020"
    result = FeatureData.dateToIsHeatingPeriod(date)
    print(date + ": " + str(result))

    date = "09.12.2020"
    result = FeatureData.dateToIsHeatingPeriod(date)
    print(date + ": " + str(result))