Python-图标生成

分析文件
:Predicted_Sunspot_Numbers_and_Radio_Flux: Predict.txt
:Created: 2019 Jan 07 0500 UTC
# Prepared by the U.S. Dept. of Commerce, NOAA, Space Weather Prediction Center (SWPC).
# Please send comments and suggestions to swpc.webmaster@noaa.gov
#
# Sunspot Number: S.I.D.C. Brussels International Sunspot Number.
# 10.7cm Radio Flux value: Penticton, B.C. Canada.
# Predicted values are based on the consensus of the Solar Cycle 24 Prediction Panel.
#
# See the README3 file for further information.
#
# Missing or not applicable data:  -1
#
#         Predicted Sunspot Number And Radio Flux Values
#                     With Expected Ranges
#
#         -----Sunspot Number------  ----10.7 cm Radio Flux----
# YR MO   PREDICTED    HIGH    LOW   PREDICTED    HIGH    LOW
#--------------------------------------------------------------
2018 07         4.5     5.5     3.5       69.8    70.8    68.8
2018 08         4.7     6.7     2.7       69.4    70.4    68.4
2018 09         5.1     8.1     2.1       69.1    71.1    67.1
2018 10         5.4    10.4     0.4       68.8    71.8    65.8
2018 11         5.5    10.5     0.5       68.4    72.4    64.4
2018 12         5.3    11.3     0.0       67.8    71.8    63.8
2019 01         5.4    12.4     0.0       67.2    72.2    62.2
2019 02         5.6    12.6     0.0       66.8    72.8    60.8
2019 03         5.7    13.7     0.0       66.3    73.3    60.0
2019 04         5.9    14.9     0.0       65.9    73.9    60.0
2019 05         6.1    15.1     0.0       65.4    73.4    60.0
2019 06         6.2    16.2     0.0       64.8    73.8    60.0
2019 07         6.1    16.1     0.0       64.3    73.3    60.0
2019 08         5.5    15.5     0.0       63.8    72.8    60.0
2019 09         5.1    15.1     0.0       63.4    72.4    60.0
2019 10         4.8    14.8     0.0       63.1    72.1    60.0
2019 11         4.4    14.4     0.0       62.8    71.8    60.0
2019 12         4.1    14.1     0.0       62.5    71.5    60.0
2020 01         3.8    13.8     0.0       62.2    71.2    60.0
2020 02         3.6    13.6     0.0       62.0    71.0    60.0
2020 03         3.3    13.3     0.0       61.7    70.7    60.0
2020 04         3.0    13.0     0.0       61.5    70.5    60.0
2020 05         2.8    12.8     0.0       61.3    70.3    60.0
2020 06         2.6    12.6     0.0       61.1    70.1    60.0
2020 07         2.4    12.4     0.0       60.9    69.9    60.0
2020 08         2.2    12.2     0.0       60.7    69.7    60.0
2020 09         2.0    12.0     0.0       60.6    69.6    60.0
2020 10         1.9    11.9     0.0       60.4    69.4    60.0
2020 11         1.7    11.7     0.0       60.3    69.3    60.0
2020 12         1.6    11.6     0.0       60.2    69.2    60.0
2021 01         1.5    11.5     0.0       60.0    69.0    60.0
2021 02         1.3    11.3     0.0       59.9    68.9    60.0
2021 03         1.2    11.2     0.0       59.8    68.8    60.0
2021 04         1.1    11.1     0.0       59.7    68.7    60.0
2021 05         1.0    11.0     0.0       59.6    68.6    60.0
2021 06         0.9    10.9     0.0       59.6    68.6    60.0
2021 07         0.9    10.9     0.0       59.5    68.5    60.0
2021 08         0.8    10.8     0.0       59.4    68.4    60.0
2021 09         0.7    10.7     0.0       59.4    68.4    60.0
2021 10         0.7    10.7     0.0       59.3    68.3    60.0
2021 11         0.6    10.6     0.0       59.2    68.2    60.0
2021 12         0.5    10.5     0.0       59.2    68.2    60.0
2022 01         0.5    10.5     0.0       59.2    68.2    60.0
2022 02         0.4    10.4     0.0       59.1    68.1    60.0
2022 03         0.4    10.4     0.0       59.1    68.1    60.0
2022 04         0.4    10.4     0.0       59.0    68.0    60.0
2022 05         0.3    10.3     0.0       59.0    68.0    60.0
2022 06         0.3    10.3     0.0       59.0    68.0    60.0
2022 07         0.3    10.3     0.0       59.0    68.0    60.0
2022 08         0.2    10.2     0.0       58.9    67.9    60.0
2022 09         0.2    10.2     0.0       58.9    67.9    60.0
2022 10         0.2    10.2     0.0       58.9    67.9    60.0
2022 11         0.2    10.2     0.0       58.9    67.9    60.0
2022 12         0.2    10.2     0.0       58.9    67.9    60.0
Resource

hello_report.py

#!/usr/bin/python
# -*- coding: UTF-8 -*-

from reportlab.graphics.shapes import Drawing, String
from reportlab.graphics import renderPDF

d = Drawing(100, 100)
s = String(50, 50, 'Hello, world', textAnchor='middle')

d.add(s)

renderPDF.drawToFile(d, 'hello.pdf', 'A simple PDF file')

sunspots.py

#!/usr/bin/python
# -*- coding: UTF-8 -*-

from urllib import urlopen
from reportlab.graphics.shapes import *
from reportlab.graphics.charts.lineplots import LinePlot
from reportlab.graphics import renderPDF

URL = 'ftp://ftp.swpc.noaa.gov/pub/weekly/Predict.txt'
COMMENT_CHARS = '#:'

drawing = Drawing(400, 200)
data = []
for line in urlopen(URL).readlines():
    line = line.decode()
    if not line.isspace() and line[0] not in COMMENT_CHARS:
        data.append([float(n) for n in line.split()])

pred = [row[2] for row in data]
high = [row[3] for rwo in data]
low = [row[4] for row in data]
times = [row[0] + row[1]/12.0 for row in data]

lp = LinePlot()
lp.x = 50
lp.y = 50
lp.height = 125
lp.width = 300
lp.data = [list(zip(times, pred)),
           list(zip(times, high)),
           list(zip(times, low))]
lp.lines[0].strokeColor = colors.blue
lp.lines[1].strokeColor = colors.red
lp.lines[2].strokeColor = colors.green

drawing.add(lp)

drawing.add(String(250, 150, 'Sunsports', fontSize = 14, fillColor = colors.red))

renderPDF.drawToFile(drawing, 'report.pdf', 'Sunspots')
生成结果

在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值