-
Notifications
You must be signed in to change notification settings - Fork 1
/
gfssi_b04_envi2hdf.py
52 lines (45 loc) · 2.08 KB
/
gfssi_b04_envi2hdf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019/9/29 16:16
# @Author : AnNing
import os
import numpy as np
from lib.lib_read_ssi import FY3DSSIENVI
from lib.lib_hdf5 import write_out_file
from lib.lib_constant import FULL_VALUE
from lib.lib_database import exist_result_data, add_result_data
def fy3d_envi2hdf(in_file, out_file, resultid, planid, datatime, resolution_type):
area_type = 'Full_DISK'
if os.path.isfile(out_file):
print('数据已经存在: {}'.format(out_file))
if not exist_result_data(resultid=resultid, datatime=datatime,
resolution_type=resolution_type,
area_type=area_type):
add_result_data(resultid=resultid, planid=planid, address=out_file, datatime=datatime,
resolution_type=resolution_type, area_type=area_type, element=None)
return
print('<<< fy3d_envi2hdf: {}'.format(in_file))
try:
in_file_gc = in_file
in_file_bc = in_file_gc.replace('Gc', 'Bc')
in_file_dc = in_file_gc.replace('Gc', 'Dc')
in_file_sz = in_file_gc.replace('Gc', 'Sz')
ssi = FY3DSSIENVI(in_file_gc)
dirssi = FY3DSSIENVI(in_file_bc)
difssi = FY3DSSIENVI(in_file_dc)
sz = FY3DSSIENVI(in_file_sz)
except Exception as why:
print(why)
return
result = {
'SSI': (ssi.get_data() / 1000., np.float),
'DirSSI': (dirssi.get_data() / 1000., np.float),
'DifSSI': (difssi.get_data() / 1000., np.float),
'Sz': (sz.get_data(), np.float)
}
write_out_file(out_file, result, full_value=FULL_VALUE)
if os.path.isfile(out_file) and not exist_result_data(resultid=resultid, datatime=datatime,
resolution_type=resolution_type,
area_type=area_type):
add_result_data(resultid=resultid, planid=planid, address=out_file, datatime=datatime,
resolution_type=resolution_type, area_type=area_type, element=None)