【问题标题】:How to convert temperature to celcius?如何将温度转换为摄氏度?
【发布时间】:2021-07-21 09:44:05
【问题描述】:

我是 openweather 的绝对新手。当我尝试他们的示例并向下滚动信息时,墨尔本的温度是 297.42。我可以确认它肯定不是,所以我的问题是我是否必须以某种方式格式化温度,因为它不是很传统(因为它是一个 3 位数字),我认为这是错误的。

{
"temp":297.42,
"feels_like":298.33,
"temp_min":295.91,
"temp_max":299.24,

}

以上只是截图

【问题讨论】:

  • 这可能是开尔文,在这种情况下,您将减去 270.something 以获得摄氏温度。可能有一个比例设置。
  • 根据文档,温度的默认值确实是开尔文:openweathermap.org/current。减去 273.15。

标签: openweathermap


【解决方案1】:

openweather api 中默认使用开尔文温度。您需要将 ?units=metric 添加到您的 api 调用中以获取摄氏度。

温度有华氏、摄氏和开尔文单位。

For temperature in Fahrenheit use units=imperial
For temperature in Celsius use units=metric
Temperature in Kelvin is used by default, no need to use units parameter in API call

所有 API 参数列表,单位为 openweathermap.org/weather-data。 您可以指定要为临时返回的格式。提供standardmetricimperial 单位。 http://api.openweathermap.org/data/2.5/weather?q=London&mode=json&units=metric 或者 http://api.openweathermap.org/data/2.5/weather?q=London&mode=json&units=imperial

只是传递单位是api中的参数。

对于转化 -

Kelvin to Fahrenheit is:

(( kelvinValue - 273.15) * 9/5) + 32

kelvin to celsius:

Just subtract 273.15.

【讨论】:

  • 另一个问题,温度有多近,因为当我转换它们时,结果与实际温度有很大不同
  • 我不认为它会是实时的,因为很明显,它只是从全球和当地的气象模型、卫星、雷达和庞大的气象站网络中获取数据。这肯定需要时间来更新!我试图搜索 openweathermap 的更新时间段,但遗憾的是找不到任何链接。然而,只是为了比较,有关于 AERISWEATHER API 的信息,它每隔 15 分钟更新一次数据aerisweather.com/support/kb/api/…
  • 随便猜一猜,可能是15mins/30mins/1hr肯定是他们的更新间隔。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-02-08
  • 1970-01-01
  • 2021-10-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多