加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
visualize_composite.py 2.50 KB
一键复制 编辑 原始数据 按行查看 历史
pedevineau 提交于 2020-06-26 20:34 . Quick cleaning
from matplotlib.pyplot import imshow, show
from numpy import round
from get_data import get_features
from utils import *
from utils import typical_input
from visualize import get_bbox
def get_snow_composite(latitudes, longitudes, dfb_beginning, dfb_ending, slot_step):
visible_features = get_features('visible', latitudes, longitudes, dfb_beginning, dfb_ending, False, slot_step)
vis = visible_features[:, :, :, 1]
sir = visible_features[:, :, :, 0]
mir = get_features('infrared', latitudes, longitudes, dfb_beginning, dfb_ending, False, slot_step)[:, :, :, 1]
mir -= 250
mir /= 100
(nb_slots, nb_latitudes, nb_longitudes) = np.shape(vis)
vis[vis < 0] = 0
sir[sir < 0] = 0
mir[mir < 0] = 0
composite = np.empty((nb_slots, nb_latitudes, nb_longitudes, 3))
composite[:, :, :, 0] = vis
composite[:, :, :, 1] = sir
composite[:, :, :, 2] = mir
return 255 * composite
def infrared_low_cloud_composite(latitudes, longitudes, dfb_beginning, dfb_ending, slot_step):
infrared_features = get_features('infrared', latitudes, longitudes, dfb_beginning, dfb_ending, 'channel', slot_step)
(nb_slots, nb_latitudes, nb_longitudes) = np.shape(infrared_features)[0:3]
composite = np.zeros((nb_slots, nb_latitudes, nb_longitudes, 3))
try:
fir = infrared_features[:, :, :, 2]
fir = round(2 * (fir - 200))
composite[:, :, :, 0] = fir
except IndexError:
print 'Computing '
pass
lir = infrared_features[:, :, :, 1]
mir = infrared_features[:, :, :, 0]
mir = round(2 * (mir - 200))
lir = round(2 * (lir - 200))
composite[:, :, :, 1] = lir
composite[:, :, :, 2] = mir
composite[(lir <= 0) | (lir > 250)] = 0
return 255 * composite
if __name__ == '__main__':
slot_step = 1
beginning, ending, latitude_beginning, latitude_end, longitude_beginning, longitude_end = typical_input()
latitudes, longitudes = get_latitudes_longitudes(latitude_beginning, latitude_end, longitude_beginning,
longitude_end)
date_begin, date_end = print_date_from_dfb(beginning, ending)
composite = infrared_low_cloud_composite(latitudes, longitudes, beginning, ending, slot_step)
bbox = get_bbox(latitude_beginning, latitude_end, longitude_beginning, longitude_end)
start = 0
for slot in range(start, np.shape(composite)[0]):
if not np.all(composite[slot, :, :, 0] == 0):
print slot_step * slot
imshow(composite[slot])
show()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化