itle:Climate change now detectable from any single day of weather at global scale
标题:现在可以从全球范围内任何一天的天气中检测到气候变化
作者:Sebastian Sippel 1,2,3*, Nicolai Meinshausen 2, Erich M. Fischer1, Enikő Székelyg1, and Reto Knutti1
1 Institute for Atmospheric and Climate Science, ETH Zurich, Zurich, Switzerland.
2Seminar for Statistics, ETH Zurich, Zurich, Switzerland.
3Norwegian Institute of Bioeconomy Research, Ås, Norway.
4Swiss Data Science Center, ETH Zurich and EPFL, Lausanne, Switzerland.
E-mail: sebastian.sippel@env.ethz.ch[1]
杂志:Nature Climate Change, volume 10, pages35–41(2020)
DOI: https://doi.org/10.1038/s41558-019-0666-7[2]
原文摘要
长此以往,气候科学家传递给公众的都是“天气不是气候”的观念,气候变化也被框定为天气分布的变化缓慢地出现于这数十年里主要的气候变率中1-7。然而,现阶段考虑全球性的天气则是一个未知的领域。在这里我们基于全球观测的单日温度和水汽来检测外部驱动气候变化的“指纹”所得到的结论是:地球作为一个整体正在变暖。我们的检测方法通过统计学习和气候模型模拟来封装每日温度和湿度的空间模式与关键的气候变化指标(例如,全球年平均温度或地球的能量失衡之间)之间的关系。观测数据投影到这种关系中来检测气候变化。根据一年的数据,从2012年初和1999年以来观测到的全球记录中的任何一天都可以检测到气候变化的“指纹”。即便是忽略长期全球变暖的趋势,检测的结果也是很稳健可靠的。这是对传统气候变化检测的补充,但也为区域天气事件的交流打开了更广阔的视野,改变了气候变化的叙述方式:尽管几十年来局地的天气变化正在出现,但现在就能即时检测到全球气候变化。
Abstract
For generations, climate scientists have educated the public that ‘weather is not climate’, and climate change has been framed as the change in the distribution of weather that slowly emerges from large variability over decades1-7. However, weather when considered globally is now in uncharted territory. Here we show that on the basis of a single day of globally observed temperature and moisture, we detect the fingerprint of externally driven climate change, and conclude that Earth as a whole is warming. Our detection approach invokes statistical learning and climate model simulations to encapsulate the relationship between spatial patterns of daily temperature and humidity, and key climate change metrics such as annual global mean temperature or Earth’s energy imbalance. Observations are projected onto this relationship to detect climate change. The fingerprint of climate change is detected from any single day in the observed global record since early 2012, and since 1999 on the basis of a year of data. Detection is robust even when ignoring the long-term global warming trend. This complements traditional climate change detection, but also opens broader perspectives for the communication of regional weather events, modifying the climate change narrative: while changes in weather locally are emerging over decades, global climate change is now detected instantaneously.
数据、代码
数据[3]
All original CMIP5 data, reanalyses and observations used in this study are publicly available under the following URLs.
CMIP5 model data: https://esgf-node.llnl.gov/projects/cmip5/;
reanalysis:
ERA-Interim (https://www.ecmwf.int/en/forecasts/datasets/reanalysis-datasets/era-interim),
NCEP/NCAR Reanalysis 1 (https://www.esrl.noaa.gov/psd/data/gridded/data.ncep.reanalysis.html),
NCEP/NCAR Reanalysis 2 (https://www.esrl.noaa.gov/psd/data/gridded/data.ncep.reanalysis2.html),
Twentieth Century Reanalysis (https://www.esrl.noaa.gov/psd/data/20thC_Rean/);
observations (monthly): GISTEMP temperature dataset, version 3 (https://data.giss.nasa.gov/gistemp/),
Cowtan and Way (2014) temperature dataset, version 2 (https://www-users.york.ac.uk/~kdc3/papers/coverage2013/series.html),
Berkeley Earth Monthly Land+Ocean temperature dataset (http://berkeleyearth.org/data/), Met Office gridded land surface humidity dataset (HadISDH),
version 4.0.0.2017f (https://www.metoffice.gov.uk/hadobs/hadisdh/);
observations (daily): Berkeley Earth Daily Land temperature dataset (Experimental, http://berkeleyearth.org/data/),
NOAA Optimum Interpolation Sea Surface Temperature (OISST), AVHRR-Only (https://www.ncdc.noaa.gov/oisst).
All intermediate and derived data from these products (extracted CMIP5 fingerprints and daily/monthly time series of the test statistic (that is, obtained by projecting CMIP5 models, reanalyses and observations individually onto the fingerprints)) are available at https://data.iac.ethz.ch/Sippel_et_al_2019_DailyDetection/.
代码[4]
All computer code to reproduce the main results and all figures and Extended Data figures is available at https://data.iac.ethz.ch/Sippel_et_al_2019_DailyDetection/
图文
References
[1] sebastian.sippel@env.ethz.ch: mailto:sebastian.sippel@env.ethz.ch[2] https://doi.org/10.1038/s41558-019-0666-7: https://doi.org/10.1038/s41558-019-0666-7[3] 数据: https://www.nature.com/articles/s41558-019-0666-7#data-availability[4] 代码: https://data.iac.ethz.ch/Sippel_et_al_2019_DailyDetection/
. 目标网页
这是我们要获取内容的网页:
radar.itjuzi.com/investevent
这个网页需要先登录才能看到数据信息,登录界面如下:
可以看到,只需要输入账号和密码就可以登录,不用输验证码,比较简单。下面我们利用一个测试账号和密码,来实现模拟登录。
私信菜鸟007获取源码以及教程哦!
2. POST 提交请求登录
首先,我们要找到 POST 请求的 URL。
有两种方法,第一种是在网页 devtools 查看请求,第二种是在 Fiddler 软件中查看。
先说第一种方法。
在登录界面输入账号密码,并打开开发者工具,清空所有请求,接着点击登录按钮,这时便会看到有大量请求产生。哪一个才是 POST 请求的 URL呢?这个需要一点经验,因为是登录,所以可以尝试点击带有 「login」字眼的请求。这里我们点击第四个请求,在右侧 Headers 中可以看到请求的 URL,请求方式是 POST类型,说明 URL 找对了。
接着,我们下拉到 Form Data,这里有几个参数,包括 identify 和 password,这两个参数正是我们登录时需要输入的账号和密码,也就是 POST 请求需要携带的参数。
参数构造非常简单,接下来只需要利用 Requests.post 方法请求登录网站,然后就可以爬取内容了。
下面,我们尝试用 Fiddler 获取 POST 请求。
如果你对 Fiddler 还不太熟悉或者没有电脑上没有安装,可以先了解和安装一下。
Fiddler 是位于客户端和服务器端的 HTTP 代理,也是目前最常用的 HTTP 抓包工具之一 。 它能够记录客户端和服务器之间的所有 HTTP 请求,可以针对特定的 HTTP 请求,分析请求数据、设置断点、调试 web 应用、修改请求的数据,甚至可以修改服务器返回的数据,功能非常强大,是 web 调试的利器。
Fiddler 下载地址:
www.telerik.com/download/fi…
使用教程:
zhuanlan.zhihu.com/p/37374178
www.hangge.com/blog/cache/…
下面,我们就通过 Fiddler 截取登录请求。
当点击登录时,官场 Fiddler 页面,左侧可以看到抓取了大量请求。通过观察,第15个请求的 URL中含有「login」字段,很有可能是登录的 POST 请求。我们点击该请求,回到右侧,分别点击「inspectors」、「Headers」,可以看到就是 POST 请求,该 URL 和上面的方法获取的 URL 是一致的。
接着,切换到右侧的 Webforms 选项,可以看到 Body 请求体。也和上面方法中得到的一致。
获取到 URL 和请求体参数之后,下面就可以开始用 Requests.post 方法模拟登录了。
代码如下:
import requests headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36', } data = { 'identity':'irw27812@awsoo.com', 'password':'test2018', } url ='https://www.itjuzi.com/user/login?redirect=&flag=&radar_coupon=' session = requests.Session() session.post(url,headers = headers,data = data) # 登录后,我们需要获取另一个网页中的内容 response = session.get('http://radar.itjuzi.com/investevent',headers = headers) print(response.status_code) print(response.text) 复制代码
使用 session.post 方法提交登录请求,然后用 session.get 方法请求目标网页,并输出 HTML代码。可以看到,成功获取到了网页内容。
下面,介绍第 2 种方法。
3. 获取 Cookies,直接请求登录
上面一种方法,我们需要去后台获取 POST 请求链接和参数,比较麻烦。下面,我们可以尝试先登录,获取 Cookie,然后将该 Cookie 添加到 Headers 中去,然后用 GET 方法请求即可,过程简单很多。
代码如下:
import requests headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36', 'Cookie': '你的cookie', } url = 'https://www.itjuzi.com/user/login?redirect=&flag=&radar_coupon=' session = requests.Session() response = session.get('http://radar.itjuzi.com/investevent', headers=headers) print(response.status_code) print(response.text) 复制代码
可以看到,添加了 Cookie 后就不用再 POST 请求了,直接 GET 请求目标网页即可。可以看到,也能成功获取到网页内容。
下面介绍第 3 种方法。
4. Selenium 模拟登录
这个方法很直接,利用 Selenium 代替手动方法去自动输入账号密码然后登录就行了。
关于 Selenium 的使用,在之前的一篇文章中有详细介绍,如果你不熟悉可以回顾一下:
www.makcyun.top/web_scrapin…
代码如下:
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.wait import WebDriverWait browser = webdriver.Chrome() browser.maximize_window() # 最大化窗口 wait = WebDriverWait(browser, 10) # 等待加载10s def login(): browser.get('https://www.itjuzi.com/user/login') input = wait.until(EC.presence_of_element_located( (By.XPATH, '//*[@id="create_account_email"]'))) input.send_keys('irw27812@awsoo.com') input = wait.until(EC.presence_of_element_located( (By.XPATH, '//*[@id="create_account_password"]'))) input.send_keys('test2018') submit = wait.until(EC.element_to_be_clickable( (By.XPATH, '//*[@id="login_btn"]'))) submit.click() # 点击登录按钮 get_page_index() def get_page_index(): browser.get('http://radar.itjuzi.com/investevent') try: print(browser.page_source) # 输出网页源码 except Exception as e: print(str(e)) login() 复制代码
这里,我们在网页中首先定位了账号节点位置: '//*[@id="create_account_email"]' ,然后用 input.send_keys 方法输入账号,同理,定位了密码框位置并输入了密码。接着定位 登录 按钮的位置: //*[@id="login_btn"] ,然后用 submit.click() 方法实现点击登录按钮操作,从而完成登录。可以看到,也能成功获取到网页内容。
天做一个简单的检测进度条模拟,我们在很多平台都可以看到安全进度检测的进度条,实际是对我们的安全设置进行检查,当我们将对应的信息补全之后,就相当于完成了一项任务,其安全系数就会提升,这里我先整个最简单的进度条,下面是演示结果。
首先我们来定义HTML,这里我们主要有进度条背景,进度条,分值和检测按钮,这个前台比较简单,当然也可以哪来用,这样的话后台要操作的就比较多了,计算和检测的活都交给了后台,我们只需要把后台传回来的数据显示在这里即可。
接下来写CSS样式,这里我们还是喜欢使用响应式来布局我的设计,所以我用到了媒体查询功能,下面是CSS样式设置,pragressContainer控制整个进度条的样式,pragressbar则是进度条背景设置,pragress是进度条进度控制,这里绑定了一个动态的样式,来改变我们的进度。
这里我模拟一个点击事件,来改变progress的值,这样进度条就会随着progress的增长,来改变style的width值实现进度改变的视觉,这里我定义一个num=0,然后写个定时器,让其自增,到了100就停止,再把num重置为0就可以反复检测了。
这个progress 值是检测的进度显示,如果想直接用的话就要通过后台来实时的传递这个值了,而检测结果result也需要通过后台处理完之后检测信息之后返回对应的结果,这样就把大部分压力抛给了后端了,这个比较简单,后面来慢慢完善。
这里用到了display: flex;这是W3C提出了一种新的布局方案,可以简便、完整、响应式地实现各种页面布局,我给进度条设定了flex: 1;它会自动的获取剩余空间宽度,这样我们在改变网页宽度时就可以自动调整宽度了,align-items: center;设定垂直居中显示。
*请认真填写需求信息,我们会在24小时内与您取得联系。