update: fix rotation
This commit is contained in:
parent
e1b44ed2f9
commit
9a4efca7c2
5
.gitignore
vendored
5
.gitignore
vendored
@ -4,4 +4,7 @@
|
||||
__pycache__
|
||||
result
|
||||
staged
|
||||
res.md
|
||||
res.md
|
||||
dist
|
||||
*.spec
|
||||
build
|
||||
@ -1,11 +1,15 @@
|
||||
from flask import Flask
|
||||
|
||||
from flask_cors import CORS
|
||||
import src
|
||||
|
||||
import os
|
||||
|
||||
app = Flask(__name__)
|
||||
CORS(app)
|
||||
|
||||
app.register_blueprint(src.tc_module, url_prefix='/tc')
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True, port=35000)
|
||||
# get port from env 'VERTEX_PORT'
|
||||
port = os.getenv('VERTEX_PORT', 35000)
|
||||
app.run(debug=True, host='0.0.0.0', port=port)
|
||||
|
||||
@ -22,7 +22,7 @@ def render():
|
||||
data_this_day = data["data"][:, :, int(day)]
|
||||
|
||||
map = create_heatmap(data_this_day, shift=(
|
||||
0, 180), colormap='hot', rotate_90=1)
|
||||
0, -180), colormap='hot', rotate_90=3)
|
||||
|
||||
buff = BytesIO()
|
||||
map.save(buff, format="PNG")
|
||||
|
||||
13
src/plot.py
13
src/plot.py
@ -80,12 +80,21 @@ def create_heatmap(data,
|
||||
# 创建颜色映射
|
||||
if colormap == 'hot':
|
||||
# 红色到黄色的渐变
|
||||
# 非线性变换,使得低值更容易区分。 使用 sqrt(x) 作为映射函数
|
||||
def get_color(value):
|
||||
# 首先把原value从0~0.1映射到0~1。如果value大于0.1,就直接取1
|
||||
value = min(value / 0.4, 1)
|
||||
if np.isnan(value):
|
||||
return (0, 0, 0, 0)
|
||||
r = int(min(255, value * 510))
|
||||
g = int(max(0, min(255, value * 510 - 255)))
|
||||
r = int(min(255, np.sqrt(value) * 256))
|
||||
g = int(max(0, min(255, np.sqrt(value) * 256 - 256)))
|
||||
return (r, g, 0, int(value * 255))
|
||||
# def get_color(value):
|
||||
# if np.isnan(value):
|
||||
# return (0, 0, 0, 0)
|
||||
# r = int(min(255, value * 510))
|
||||
# g = int(max(0, min(255, value * 510 - 255)))
|
||||
# return (r, g, 0, int(value * 255))
|
||||
|
||||
# 填充像素
|
||||
pixels = image.load()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user