Exemple #1
0
    def calculate_number_of_available_data(self):
        """
        | Calculate number of available data for every months

        :return: {"temp": temp, "tempDist": tempDist, "rhDist": rhDist, "prec": prec, "windDist": windDist, "sign": sign }
        """
        temp = Climate.number(
            self.collect_monthly_data('tempMin')) > 0 and Climate.number(
                self.collect_monthly_data('tempMinAvg')) > 0
        tempDist = Climate.number2(self.generate_temperature_distribution(),
                                   strict=True) > 0
        rhDist = Climate.number2(self.generate_rh_distribution(),
                                 strict=True) > 0
        prec = Climate.number(
            self.collect_monthly_data('precipitation')) > 0 and Climate.sum(
                self.collect_monthly_data('precipitation')) > 0
        windDist = Climate.number2(self.generate_wind_distribution(),
                                   strict=True) > 0
        sign = False
        for m in self.monthObjs:
            if Climate.sum([
                    self.monthObjs[0].significants.get(i)
                    for i in self.monthObjs[0].significants
            ]) > 0:
                sign = True
                break

        return {
            "temp": temp,
            "tempDist": tempDist,
            "rhDist": rhDist,
            "prec": prec,
            "windDist": windDist,
            "sign": sign
        }
Exemple #2
0
    def calculate_number_of_available_data(self):
        """
        | Calculate number of available data

        :return: {"temp": temp, "tempDist": tempDist, "rhDist": rhDist, "prec": prec, "windDist": windDist, "sign": sign, "snowDepth": snowDepth}
        """
        temp = Climate.number(self.tempMins) > 0 and Climate.number(
            self.tempMaxs) > 0
        tempDist = Climate.number2(self.generate_temp_distribution()) > 0
        rhDist = Climate.number2(self.generate_rh_distribution()) > 0
        prec = Climate.number(
            self.collect_daily_precipitation()) > 0 and Climate.sum(
                self.collect_daily_precipitation()) > 0
        windDist = Climate.number2(self.generate_wind_distribution(), True) > 0
        sign = Climate.sum([
            self.monthObjs[0].significants.get(i)
            for i in self.monthObjs[0].significants
        ]) > 0
        snowDepth = Climate.number(
            self.collect_snow_depth()) > 0 and Climate.sum(
                self.collect_snow_depth()) > 0
        return {
            "temp": temp,
            "tempDist": tempDist,
            "rhDist": rhDist,
            "prec": prec,
            "windDist": windDist,
            "sign": sign,
            "snowDepth": snowDepth,
        }
Exemple #3
0
 def test_num_only_null(self):
     self.assertEqual(Climate.number([None, None]), 0)
Exemple #4
0
 def test_num_with_null(self):
     self.assertEqual(Climate.number([None, 2.1, "abc", -11]), 3)
Exemple #5
0
 def test_num_empty(self):
     self.assertEqual(Climate.number([]), 0)