I'm trying to access this element of the HourWeather retrieved from a call to weatherService. When I print in the debugger what is received, it's clear that there is an element there called precipitationAmount. Here is an example of everything retrieved in HourWeather for a particular hour: HourWeather(date: 2022-06-12 22:00:00 +0000, cloudCover: 0.46, condition: Breezy, symbolName: wind, dewPoint: 9.12 °C, humidity: 0.71, isDaylight: true, precipitation: rain, precipitationChance: 0.23, precipitationAmount: 0.21 mm, snowfallAmount: 0.0 mm, pressure: 997.65 mbar, pressureTrend: Rising, temperature: 14.34 °C, apparentTemperature: 13.74 °C, uvIndex: WeatherKit.UVIndex(value: 1, category: Low), visibility: 25915.82 m, wind: WeatherKit.Wind(compassDirection: Northwest, direction: 304.0 °, speed: 29.47 km/h, gust: Optional(41.56 km/h))) But when I try to access that element as part of a SwiftUI view in Xcode (14.0 beta), I get this error: Value of type 'HourWeather' has no member 'precipitationAmount
precipitationAmount
17 results found
Post
Replies
Boosts
Views
Activity
Incidentally, the WeatherKit REST API includes precipitationAmount for hourly weather conditions: https://developer.apple.com/documentation/weatherkitrestapi/hourweatherconditions so it seems odd and inconsistent that it is not included in the Structure definition for HourWeather: https://developer.apple.com/documentation/weatherkit/hourweather
So I've solved my own issue for now. It may not be pretty (haven't used strings much), but by defining this function I was able to extract the precipitation amount as a Measurement, just like other elements of the HourWeather struct. // Function to get precipitationAmount as a measurement from one instance of HourWeather // Written by Neil Gordon, 14 June 2022 - pending inclusion of precipitationAmount in the // WeatherKit definition of the Structure for HourWeather func precipitationAmount(hourWeatherElement: HourWeather) -> Measurement { var contents : String = var answer = Measurement(value: -9.9, unit: UnitLength.millimeters) // Default if problems print (hourWeatherElement, to: &contents) // Get the contents of the instance as a string if let firstRange = contents.range(of: precipitationAmount: ) { // Find where precip amount should be let startIndex = firstRange.upperBound // Drop everything before that contents = String(contents[startIndex...]) // Find posit
I've been getting at the precipitationAmount data using this hack from another thread. I've often found that the precip amount is 0mm for every hour of the day. Every entry for today has the same precipAmount of 0mm: HourWeather(date: 2022-06-27 22:00:00 +0000, cloudCover: 0.15, condition: Mostly Clear, symbolName: sun.max, dewPoint: 12.43 °C, humidity: 0.78, isDaylight: true, precipitation: , precipitationChance: 0.0, precipitationAmount: 0.0 mm However the iOS 16 beta 2 weather app is showing precip data for today at the same location. Is the iOS 16 Weather App using the same WeatherKit as I am? I'm finding the data in weatherkit to be pretty different than the data in the weather app.
woot! Looks like with got precipitationAmount in beta 3 :)
Hi, i've been playing with WeatherKit for the first 3 betas but each time I try to get the UV Index of a forecast I've got 0 as value. For example the hourly forecast of San Francisco at the time of writing is the following : Optional(WeatherKit.HourWeather(date: 2022-07-06 14:00:00 +0000, cloudCover: 0.98, condition: Drizzle, symbolName: cloud.moon.rain, dewPoint: 21.87 °C, humidity: 0.95, isDaylight: false, precipitation: rain, precipitationChance: 0.44, precipitationAmount: 0.44 mm, snowfallAmount: 0.0 mm, pressure: 1000.93 mbar, pressureTrend: Steady, temperature: 22.67 °C, apparentTemperature: 24.89 °C, uvIndex: WeatherKit.UVIndex(value: 0, category: Low), visibility: 8977.97 m, wind: WeatherKit.Wind(compassDirection: South Southeast, direction: 151.0 °, speed: 32.34 km/h, gust: Optional(48.66 km/h)))) While the UV Index at the time from The Weather Network is supposed to be 4. I've got this issue since beta 1 and it's happening on every location I try. Is this happening as well to other people
In XCode 14.1 beta 3, the HourWeather item precipitationAmount is missing. Is this a bug that will be fixed or a planned change? Without precipitationAmount, the API is almost unusable.
I'm in Changsha, China. get my current location from Apple Maps. but the WeatherKit result is not same with Weather App. request: GET /api/v1/weather/zh-CN/28.212151/112.955606?countryCode=cn&timeZone=Asia%2FShanghai&dataSets=forecastHourly&hourlyStart=2022-12-12T22%3A19%3A05Z&hourlyEnd=2022-12-17T22%3A19%3A05Z host: weatherkit.apple.com response: { forecastStart: 2022-12-17T22:00:00Z, cloudCover: 0.01, conditionCode: Clear, daylight: false, humidity: 0.65, precipitationAmount: 0.0, precipitationIntensity: 0.0, precipitationChance: 0.0, precipitationType: clear, pressure: 1036.48, pressureTrend: falling, snowfallIntensity: 0.0, snowfallAmount: 0.0, /// this is -2.83°C temperature: -2.83, temperatureApparent: -3.64, temperatureDewPoint: -8.47, uvIndex: 0, visibility: 18656.25, windDirection: 318, windGust: 9.61, windSpeed: 4.08 } Weather App temperature is 2°C
According to the documentation for precipitationAmount (https://developer.apple.com/documentation/weatherkit/hourweather/precipitationamount/): This value refers to the liquid equivalent of all precipitation amounts. A quick internet search told me that the liquid amount can vary drastically, but 10:1 (snow to water) is the usual rule of thumb. Under that assumption, the results you're getting look reasonable.
snowfallAmount gives the amount of precipitation that falls as snow measured as the depth of snow crystals with no melting, as opposed to precipitationAmount which is the amount of precipitation measured as depth of water after melting. The difference is usually around a factor of 10. Snow is mostly empty space, and how much empty space is in the snow--how fluffy it is--is partially a function of temperature. The snowfallAmount gives depth of snow if it were to fall on the ground with no melting, no change in its temperature, and no compression as layers of snow accumulate. precipitationAmount gives the depth water you would have if you let all the precipitation fall and then melted it with no evaporation. snowfallAmount may be greater than the observed snow accumulation since snow that falls on warm ground will melt rather than accumulate.
Just to clarify, I see https://developer.apple.com/weatherkit/get-started/ says that precipAccumulation from Dark Sky maps to precipitationAmount in WeatherKit. Is that correct, or are they describing different things? (I'm trying to map WeatherKit into a Dark Sky compatible format, so I want to make sure I'm using the most appropriate data point.) Thank you!
At the moment (8:30 PM), for a number of counties in my area, WeatherKit is indicating a conditionCode of WintryMix for overnightForecast. The low is above freezing, and according to the iPhone weather app there is zero percent chance of precipitation overnight. WeatherKit shows a 0.36 (36%) chance of precipitation but 0 precipitationAmount and 0 snowfallAmount. No other weather data I can find indicates any precipitation overnight in this area. In fact it's supposed to be clear overnight. For now, as an immediate fix, I'm using the restOfDayForecast to get me to midnight, as it seems to be correct. However this is extremely concerning, and my users are very concerned (we're in a fairly southern area) because of this totally false WintryMix conditionCode. I'm really not sure what to do about this. Maybe ignore the condition code if it indicates precipitation but with a 0 precipitationAmount? I'd also like to know why the iPhone weather widget is correct but this WeatherKit data is not. There
daytimeForecast: { forecastStart: 2023-04-03T11:00:00Z, forecastEnd: 2023-04-03T23:00:00Z, cloudCover: 0.9, conditionCode: Cloudy, humidity: 0.55, precipitationAmount: 0, precipitationAmountByType: {}, precipitationChance: 0, precipitationType: clear, snowfallAmount: 0, windDirection: 172, windSpeed: 8.91 }, overnightForecast: { forecastStart: 2023-04-03T23:00:00Z, forecastEnd: 2023-04-04T11:00:00Z, cloudCover: 0.49, conditionCode: WintryMix, humidity: 0.8, precipitationAmount: 0, precipitationAmountByType: {}, precipitationChance: 0.36, precipitationType: mixed, snowfallAmount: 0, windDirection: 185, windSpeed: 8.87 }, restOfDayForecast: { forecastStart: 2023-04-04T00:12:12Z, forecastEnd: 2023-04-04T04:00:00Z, cloudCover: 0.8, conditionCode: MostlyCloudy, humidity: 0.73, precipitationAmount: 0, precipitationAmountByType: {}, precipitationChance: 0, precipitationType: clear, snowfallAmount: 0, windDirection: 178, windSpeed: 10.86 } }
I don't think Apple uses kph for precipitation intensity, at least not currently / anymore. I ran a 240h hourly API request and the precipitation amount ranges from 0 to 1.9. The precipitation intensity is identical to the precipitation amount. Since it's hourly granularity, the unit of speed is definitely not per second so not m/s. also K/h is implausible because 1.9 kph = 75000 inches per hour. I would venture to guess that precipitation is cm and precipitation intensity is cm/h Has anyone found explicit confirmation of the units? I don't see it anywhere in Apple's documentation. cloudCover: % daylight: T/F humidity: % precipitationAmount: cm ? precipitationIntensity: cm/h ? precipitationChance:% pressure: hPa ? snowfallIntensity: cm/h snowfallAmount: cm temperature: C temperatureApparent: C temperatureDewPoint: C uvIndex: 0-10? visibility: m? windDirection: degrees ? windGust: m/s ? windSpeed: m/s ?
I've received a forecast with non-zero precipitationChance and zero precipitationIntensity. Is this expected? How should I interpret the data? { forecastStart: 2023-09-02T02:00:00Z, cloudCover: 0.55, conditionCode: PartlyCloudy, daylight: false, humidity: 0.92, precipitationAmount: 0, precipitationIntensity: 0, precipitationChance: 0.31, precipitationType: clear, pressure: 1017.56, pressureTrend: steady, snowfallIntensity: 0, snowfallAmount: 0, temperature: 12.56, temperatureApparent: 12.22, temperatureDewPoint: 11.26, uvIndex: 0, visibility: 23505.2, windDirection: 233, windGust: 6.17, windSpeed: 2.82 }