- def describe_weather(
- self,
- high: float,
- low: float,
- wind: List[float],
- conditions: List[str],
- rain: List[float],
- snow: List[float],
- ) -> str:
- # High temp: 65
- # Low temp: 44
- # -onight------ -morning----- -afternoon-- -evening----
- # 12a-3a 3a-6a 6a-9a 9a-12p 12p-3p 3p-6p 6p-9p 9p-12p
- # Wind: [12.1 3.06 3.47 4.12 3.69 3.31 2.73 2.1]
- # Conditions: [Clouds Clouds Clouds Clouds Clouds Clouds Clear Clear]
- # Rain: [0.4 0.2 0 0 0 0 0 0]
- # Snow: [0 0 0 0 0 0 0 0]
- high = int(high)
- low = int(low)
- count = min(len(wind), len(conditions), len(rain), len(snow))
- descr = ""
-
- lcondition = ""
- lwind = ""
- lprecip = ""
- ltime = ""
- for x in range(0, count):
- time = self.describe_time(x)
- current = ""
- chunks = 0
-
- txt = conditions[x]
- if txt == "Clouds":
- txt = "cloudy"
- elif txt == "Rain":
- txt = "rainy"
-
- if txt != lcondition:
- if txt != "Snow" and txt != "Rain":
- current += txt
- chunks += 1
- lcondition = txt
-
- txt = self.describe_wind(wind[x])
- if txt != lwind:
- if len(current) > 0:
- current += " with "
- current += txt + " winds"
- lwind = txt
- chunks += 1
-
- txt = self.describe_precip(rain[x], snow[x])
- if txt != lprecip:
- if len(current) > 0:
- if chunks > 1:
- current += " and "
- else:
- current += " with "
- chunks += 1
- current += txt
- lprecip = txt
-
- if len(current):
- if ltime != time:
- if random.randint(0, 3) == 0:
- if time != "overnight":
- descr += current + " in the " + time + ". "
- descr += current + " overnight. "
- else:
- if time != "overnight":
- descr += "In the "
- descr += time + ", " + current + ". "
- else:
- current = current.replace("cloudy", "clouds")
- descr += current + " developing. "
- ltime = time
- if ltime == "overnight" or ltime == "morning":
- descr += "Conditions continuing the rest of the day. "
- descr = descr.replace("with breezy winds", "and breezy")
- descr = descr.replace("Clear developing", "Skies clearing")
- descr = self.fix_caps(descr)
- return descr
-