shancx 1.9.33.170__tar.gz → 1.9.33.172__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {shancx-1.9.33.170 → shancx-1.9.33.172}/PKG-INFO +1 -1
- {shancx-1.9.33.170 → shancx-1.9.33.172}/setup.py +1 -1
- shancx-1.9.33.172/shancx/NN/__init__.py +161 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx.egg-info/PKG-INFO +1 -1
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx.egg-info/SOURCES.txt +0 -4
- shancx-1.9.33.170/shancx/H9/__init__.py +0 -126
- shancx-1.9.33.170/shancx/H9/ahi_read_hsd.py +0 -877
- shancx-1.9.33.170/shancx/H9/ahisearchtable.py +0 -298
- shancx-1.9.33.170/shancx/H9/geometry.py +0 -2439
- shancx-1.9.33.170/shancx/NN/__init__.py +0 -93
- {shancx-1.9.33.170 → shancx-1.9.33.172}/README.md +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/setup.cfg +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/3D/__init__.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Algo/Class.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Algo/CudaPrefetcher1.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Algo/Fake_image.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Algo/Hsml.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Algo/L2Loss.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Algo/MetricTracker.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Algo/Normalize.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Algo/OptimizerWScheduler.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Algo/Rmageresize.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Algo/Savemodel.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Algo/SmoothL1_losses.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Algo/Tqdm.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Algo/__init__.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Algo/checknan.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Algo/dsalgor.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Algo/iouJU.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Algo/mask.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Algo/psnr.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Algo/ssim.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Algo/structural_similarity.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Algo/tool.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Calmetrics/__init__.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Calmetrics/calmetrics.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Calmetrics/calmetricsmatrixLib.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Calmetrics/rmseR2score.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Clip/__init__.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Cmd.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Df/DataFrame.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Df/__init__.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Df/tool.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Diffm/Psamples.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Diffm/__init__.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Diffm/test.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Doc/__init__.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/E/__init__.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Fillmiss/__init__.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Fillmiss/imgidwJU.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Fillmiss/imgidwLatLonJU.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Gpu/__init__.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Hug/__init__.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Inst.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Lib.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Mos/__init__.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Path1.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Plot/GlobMap.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Plot/Gray2RGB.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Plot/__init__.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Plot/border.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Plot/draw_day_CR_PNG.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Plot/exam.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Plot/radarNmc.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Plot/single_china_map.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Point.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/QC.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/RdPzl/__init__.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Read.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/SN/__init__.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Time/GetTime.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Time/__init__.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Time/timeCycle.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Time/tool.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Train/__init__.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Train/makelist.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Train/multiGpu.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Train/prepare.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/Train/renet50.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/ZR.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/__init__.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/args.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/bak.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/cmp.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/df2database.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/getResponse.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/info.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/netdfJU.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/sendM.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/tensBoard/__init__.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/tool.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx/wait.py +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx.egg-info/dependency_links.txt +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx.egg-info/requires.txt +0 -0
- {shancx-1.9.33.170 → shancx-1.9.33.172}/shancx.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
#!/usr/bin/python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
import os
|
|
4
|
+
def start():
|
|
5
|
+
print("import successful")
|
|
6
|
+
# constants
|
|
7
|
+
__author__ = 'shancx'
|
|
8
|
+
__author_email__ = 'shanhe12@163.com'
|
|
9
|
+
__time__ = '20251028 21:16'
|
|
10
|
+
import logging
|
|
11
|
+
from logging.handlers import RotatingFileHandler
|
|
12
|
+
import os
|
|
13
|
+
from shancx import crDir
|
|
14
|
+
def _loggers(logger_name="loggers", root="./logs", phase="project", level=logging.INFO, screen=True, max_bytes=10*1024*1024, backup_count=5, overwrite=False,handlersflag=False):
|
|
15
|
+
'''set up logger with rotating file handler'''
|
|
16
|
+
l = logging.getLogger(logger_name)
|
|
17
|
+
if handlersflag:
|
|
18
|
+
if l.handlers:
|
|
19
|
+
return l
|
|
20
|
+
formatter = logging.Formatter(
|
|
21
|
+
"%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s", datefmt='%Y-%m-%d %H:%M:%S')
|
|
22
|
+
log_file = os.path.join(root, '{}.log'.format(phase))
|
|
23
|
+
crDir(log_file)
|
|
24
|
+
# Use RotatingFileHandler with 'w' mode to overwrite log file if needed
|
|
25
|
+
mode = 'w' if overwrite else 'a'
|
|
26
|
+
fh = RotatingFileHandler(log_file, mode=mode, maxBytes=max_bytes, backupCount=backup_count)
|
|
27
|
+
fh.setFormatter(formatter)
|
|
28
|
+
l.setLevel(level)
|
|
29
|
+
l.addHandler(fh)
|
|
30
|
+
if screen:
|
|
31
|
+
sh = logging.StreamHandler()
|
|
32
|
+
sh.setFormatter(formatter)
|
|
33
|
+
l.addHandler(sh)
|
|
34
|
+
return l
|
|
35
|
+
|
|
36
|
+
"""
|
|
37
|
+
logger = _loggers(logger_name="test_logger", root=curpathplus, phase="test_log", overwrite=True, screen=True)
|
|
38
|
+
# 测试日志输出
|
|
39
|
+
for i in range(5):
|
|
40
|
+
logger.info(f"这是日志消息 {i+1}")
|
|
41
|
+
time.sleep(1)
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
import logging
|
|
45
|
+
def setlogger(level=logging.INFO):
|
|
46
|
+
|
|
47
|
+
logging.basicConfig(
|
|
48
|
+
level=level, # 动态接受级别参数
|
|
49
|
+
format="%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s",
|
|
50
|
+
handlers=[logging.StreamHandler()],
|
|
51
|
+
force=True # 强制覆盖现有配置(Python 3.8+)
|
|
52
|
+
)
|
|
53
|
+
return logging.getLogger()
|
|
54
|
+
'''
|
|
55
|
+
# 使用示例
|
|
56
|
+
if __name__ == "__main__":
|
|
57
|
+
logger = setlogger(level=logging.DEBUG) # 设置为DEBUG级别
|
|
58
|
+
logger.debug("这条日志会显示") # 默认情况下DEBUG不显示,但因为我们设置了级别,现在会显示
|
|
59
|
+
logger.info("这是一条INFO日志")
|
|
60
|
+
'''
|
|
61
|
+
|
|
62
|
+
import os
|
|
63
|
+
import glob
|
|
64
|
+
import logging
|
|
65
|
+
from datetime import datetime
|
|
66
|
+
from shancx import loggers as logger
|
|
67
|
+
def cleanupLogs(log_dir='/mnt/wtx_weather_forecast/scx/SATH9SEAStest/logs', keep_count=10,
|
|
68
|
+
pattern='*.log', recursive=False, dry_run=False):
|
|
69
|
+
stats = {'total_dirs': 0, 'deleted_files': 0, 'errors': []}
|
|
70
|
+
def _cleanup_dir(directory):
|
|
71
|
+
stats['total_dirs'] += 1
|
|
72
|
+
if not os.path.exists(directory):
|
|
73
|
+
logging.warning(f"目录不存在: {directory}")
|
|
74
|
+
return
|
|
75
|
+
file_paths = glob.glob(os.path.join(directory, pattern))
|
|
76
|
+
log_files = [(path, os.path.getmtime(path)) for path in file_paths]
|
|
77
|
+
log_files.sort(key=lambda x: x[1], reverse=True)
|
|
78
|
+
if len(log_files) <= keep_count:
|
|
79
|
+
logging.info(f"目录 {directory} 中的文件数量 ({len(log_files)}) 不超过保留数量 ({keep_count}),无需清理")
|
|
80
|
+
return
|
|
81
|
+
files_to_delete = log_files[keep_count:]
|
|
82
|
+
for file_path, mtime in files_to_delete:
|
|
83
|
+
try:
|
|
84
|
+
if dry_run:
|
|
85
|
+
logging.info(f"[试运行] 将删除: {file_path} (修改时间: {datetime.fromtimestamp(mtime).strftime('%Y-%m-%d %H:%M:%S')})")
|
|
86
|
+
else:
|
|
87
|
+
os.remove(file_path)
|
|
88
|
+
logging.info(f"已删除: {file_path} (修改时间: {datetime.fromtimestamp(mtime).strftime('%Y-%m-%d %H:%M:%S')})")
|
|
89
|
+
stats['deleted_files'] += 1
|
|
90
|
+
except Exception as e:
|
|
91
|
+
error_msg = f"删除失败 {file_path}: {str(e)}"
|
|
92
|
+
logging.error(error_msg)
|
|
93
|
+
stats['errors'].append(error_msg)
|
|
94
|
+
if recursive:
|
|
95
|
+
for root, _, _ in os.walk(log_dir):
|
|
96
|
+
_cleanup_dir(root)
|
|
97
|
+
else:
|
|
98
|
+
_cleanup_dir(log_dir)
|
|
99
|
+
return stats
|
|
100
|
+
"""
|
|
101
|
+
if __name__ == "__main__":
|
|
102
|
+
dir = "/mnt/wtx_weather_forecast/scx/SATH9SEAStest/logs/H9SEAS/"
|
|
103
|
+
stats = cleanupLogs(dir,3, '*.log', False, False)
|
|
104
|
+
logging.info(f"清理完成: 处理目录数={stats['total_dirs']}, 删除文件数={stats['deleted_files']}, 错误数={len(stats['errors'])}")
|
|
105
|
+
if stats['errors']:
|
|
106
|
+
logging.error(f"错误详情: {stats['errors']}")
|
|
107
|
+
"""
|
|
108
|
+
|
|
109
|
+
from itertools import product
|
|
110
|
+
from concurrent.futures import ProcessPoolExecutor as PoolExecutor, as_completed
|
|
111
|
+
import sys
|
|
112
|
+
from tqdm import tqdm
|
|
113
|
+
def validate_param_list(param_list):
|
|
114
|
+
if len(param_list) == 0:
|
|
115
|
+
raise ValueError("param_list cannot be empty.")
|
|
116
|
+
for sublist in param_list:
|
|
117
|
+
if len(sublist) == 0:
|
|
118
|
+
raise ValueError("Sub-lists in param_list cannot be empty.")
|
|
119
|
+
def Mul_sub(task, param_list, num=6):
|
|
120
|
+
print(f"Pro num {num}")
|
|
121
|
+
validate_param_list(param_list)
|
|
122
|
+
if len(param_list) == 1:
|
|
123
|
+
product_list = [(x,) for x in param_list[0]]
|
|
124
|
+
else:
|
|
125
|
+
product_list = list(product(*param_list))
|
|
126
|
+
with PoolExecutor(max_workers=num) as executor:
|
|
127
|
+
try:
|
|
128
|
+
futures = [executor.submit(task, item) for item in product_list]
|
|
129
|
+
for future in tqdm(as_completed(futures), total=len(futures), desc="Processing tasks", unit="task"):
|
|
130
|
+
future.result()
|
|
131
|
+
except KeyboardInterrupt:
|
|
132
|
+
sys.exit(1)
|
|
133
|
+
print("All tasks completed")
|
|
134
|
+
|
|
135
|
+
# import os
|
|
136
|
+
# from datetime import datetime
|
|
137
|
+
# from shancx.NN import _loggers
|
|
138
|
+
# from shancx import lock_file
|
|
139
|
+
# from shancx.wait import check_lock
|
|
140
|
+
# from shancx import crDir
|
|
141
|
+
# logger =_loggers()
|
|
142
|
+
# def check_process_data(UTC, sat_cd,basepath ="/mnt/wtx_weather_forecast/scx/test/lock_files" ):
|
|
143
|
+
# try:
|
|
144
|
+
# UTCStr = UTC.strftime("%Y%m%d%H%M")
|
|
145
|
+
# file = f"/mnt/wtx_weather_forecast/scx/test/lock_files/{sat_cd}/{UTCStr[:4]}/{UTCStr[:8]}/File_{UTCStr}.lock"
|
|
146
|
+
# crDir(file)
|
|
147
|
+
# if not lock_file(file):
|
|
148
|
+
# if check_lock(file):
|
|
149
|
+
# logger.info("data is making or maked")
|
|
150
|
+
# return True ,file
|
|
151
|
+
# return False,file
|
|
152
|
+
# except Exception as e:
|
|
153
|
+
# logger.error(f"Error in check_and_process_data: {str(e)}")
|
|
154
|
+
# return False,file
|
|
155
|
+
# """
|
|
156
|
+
# flag1,file = check_process_data(UTC, "H9SEAS" )
|
|
157
|
+
# if flag1:
|
|
158
|
+
# sys.exit()
|
|
159
|
+
# if os.path.exists(output_path): #配合使用
|
|
160
|
+
# sys.exit()
|
|
161
|
+
# """
|
|
@@ -64,10 +64,6 @@ shancx/Fillmiss/__init__.py
|
|
|
64
64
|
shancx/Fillmiss/imgidwJU.py
|
|
65
65
|
shancx/Fillmiss/imgidwLatLonJU.py
|
|
66
66
|
shancx/Gpu/__init__.py
|
|
67
|
-
shancx/H9/__init__.py
|
|
68
|
-
shancx/H9/ahi_read_hsd.py
|
|
69
|
-
shancx/H9/ahisearchtable.py
|
|
70
|
-
shancx/H9/geometry.py
|
|
71
67
|
shancx/Hug/__init__.py
|
|
72
68
|
shancx/Mos/__init__.py
|
|
73
69
|
shancx/NN/__init__.py
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
from shancx.H9.ahisearchtable import ahisearchtable
|
|
2
|
-
from shancx.H9.ahi_read_hsd import ahi_read_hsd
|
|
3
|
-
from tqdm import tqdm
|
|
4
|
-
import os
|
|
5
|
-
import numpy as np
|
|
6
|
-
import datetime
|
|
7
|
-
import time
|
|
8
|
-
import warnings
|
|
9
|
-
warnings.filterwarnings("ignore", category=UserWarning)
|
|
10
|
-
class AHIScene(ahi_read_hsd, ahisearchtable) :
|
|
11
|
-
def __init__(self, subpoint=140.7, resolution=0.02):
|
|
12
|
-
super().__init__(subpoint=subpoint, resolution=resolution)
|
|
13
|
-
self.Tempfile = []
|
|
14
|
-
def hsdBlock(self, srcHSDfiles, tmppath, fillvalue=65535) :
|
|
15
|
-
''' 对H8、H9的HSD文件进行解析、拼接成NOM '''
|
|
16
|
-
# HS_H09_20230115_0400_B01_FLDK_R10_S0110.DAT.bz2
|
|
17
|
-
BandID, BlockIDMin, BlockIDMax, SegmentTotal = self.setHSDInfo(srcHSDfiles)
|
|
18
|
-
outdata = None
|
|
19
|
-
BlockIDs = []
|
|
20
|
-
with tqdm(total=len(srcHSDfiles), iterable='iterable',
|
|
21
|
-
desc = '正在进行第%i波段块合成' %(BandID), mininterval=1) as pbar:
|
|
22
|
-
for hsdname in srcHSDfiles :
|
|
23
|
-
if not os.path.isfile(hsdname):
|
|
24
|
-
print('文件不存在【%s】' %(hsdname))
|
|
25
|
-
pbar.update(1)
|
|
26
|
-
continue
|
|
27
|
-
|
|
28
|
-
# 获取文件名信息
|
|
29
|
-
nameinfo = self.getHSDNameInfo(hsdname)
|
|
30
|
-
if nameinfo is None :
|
|
31
|
-
pbar.update(1)
|
|
32
|
-
continue
|
|
33
|
-
SegmentNum = nameinfo['SegmemtID']
|
|
34
|
-
|
|
35
|
-
# print('正在解压bz2文件【%s】' %(hsdname))
|
|
36
|
-
self._unzipped = self.unzip_file(hsdname, tmppath)
|
|
37
|
-
if self._unzipped:
|
|
38
|
-
self.is_zipped = True
|
|
39
|
-
filename = self._unzipped
|
|
40
|
-
|
|
41
|
-
self.Tempfile.append(filename)
|
|
42
|
-
else:
|
|
43
|
-
filename = hsdname
|
|
44
|
-
|
|
45
|
-
if filename.endswith('.bz2') :
|
|
46
|
-
print('解压bz2文件失败【%s】' %(filename))
|
|
47
|
-
pbar.update(1)
|
|
48
|
-
continue
|
|
49
|
-
|
|
50
|
-
# 根据块号对数据进行拼接
|
|
51
|
-
data = self.readhsd(filename, SegmentNum)
|
|
52
|
-
if data is None :
|
|
53
|
-
pbar.update(1)
|
|
54
|
-
continue
|
|
55
|
-
|
|
56
|
-
if outdata is None :
|
|
57
|
-
line, pixel = data.shape
|
|
58
|
-
outdata = np.full(shape=(line*SegmentTotal, pixel),
|
|
59
|
-
fill_value=fillvalue, dtype=np.uint16)
|
|
60
|
-
|
|
61
|
-
data[np.isnan(data)] = fillvalue/100.0
|
|
62
|
-
outdata[(SegmentNum-BlockIDMin)*line:(SegmentNum-BlockIDMin+1)*line, :] \
|
|
63
|
-
= np.array(data*100.0, dtype=np.uint16)
|
|
64
|
-
BlockIDs.append(SegmentNum)
|
|
65
|
-
pbar.update(1)
|
|
66
|
-
pbar.close()
|
|
67
|
-
self.__del__()
|
|
68
|
-
return outdata
|
|
69
|
-
|
|
70
|
-
def setHSDInfo(self, filelist):
|
|
71
|
-
|
|
72
|
-
BandID = None
|
|
73
|
-
BlockIDs = []
|
|
74
|
-
for filename in filelist :
|
|
75
|
-
nameinfo = self.getHSDNameInfo(filename)
|
|
76
|
-
if nameinfo is None :
|
|
77
|
-
continue
|
|
78
|
-
|
|
79
|
-
if BandID is None :
|
|
80
|
-
BandID = nameinfo['BandID']
|
|
81
|
-
elif BandID != nameinfo['BandID'] :
|
|
82
|
-
raise Exception('输入的文件列表中有多个波段的块数据文件【%s】' %(filename))
|
|
83
|
-
BlockIDs.append(nameinfo['SegmemtID'])
|
|
84
|
-
|
|
85
|
-
BlockIDMin = np.nanmin(BlockIDs)
|
|
86
|
-
BlockIDMax = np.nanmax(BlockIDs)
|
|
87
|
-
|
|
88
|
-
SegmentTotal = int(BlockIDMax-BlockIDMin+1)
|
|
89
|
-
|
|
90
|
-
return BandID, BlockIDMin, BlockIDMax, SegmentTotal
|
|
91
|
-
|
|
92
|
-
def getHSDNameInfo(self, filename):
|
|
93
|
-
|
|
94
|
-
basename = os.path.basename(filename)
|
|
95
|
-
basename = basename.split('.')[0]
|
|
96
|
-
if len(basename) != 39 :
|
|
97
|
-
print('非标准文件名,需要输入文件名【HS_H09_YYYYMMDD_HHMM_BXX_FLDK_R20_S0810】')
|
|
98
|
-
return None
|
|
99
|
-
|
|
100
|
-
nameinfo = {}
|
|
101
|
-
namelist = basename.split('_')
|
|
102
|
-
|
|
103
|
-
nameinfo['SatID'] = namelist[1]
|
|
104
|
-
nameinfo['StartTime'] = datetime.datetime.strptime('%s %s' %(namelist[2], namelist[3]), '%Y%m%d %H%M')
|
|
105
|
-
nameinfo['BandID'] = int(namelist[4][1:]) # 2-digit band number (varies from "01" to "16");
|
|
106
|
-
nameinfo['ObsType'] = namelist[5]
|
|
107
|
-
nameinfo['Resolution'] = float(namelist[6][1:])/10.0/100 # spatial resolution ("05": 0.5km, "10": 1.0km, "20": 2.0km);
|
|
108
|
-
nameinfo['SegmemtID'] = int(namelist[7][1:3])
|
|
109
|
-
nameinfo['SegmemtTotal'] = int(namelist[7][3:5]) # total number of segments (fixed to "10")
|
|
110
|
-
|
|
111
|
-
return nameinfo
|
|
112
|
-
|
|
113
|
-
def __del__(self):
|
|
114
|
-
# pass
|
|
115
|
-
for filename in self.Tempfile :
|
|
116
|
-
if os.path.isfile(filename) :
|
|
117
|
-
try:
|
|
118
|
-
os.remove(filename)
|
|
119
|
-
except BaseException as e :
|
|
120
|
-
time.sleep(1)
|
|
121
|
-
try:
|
|
122
|
-
fp = open(filename, 'r')
|
|
123
|
-
fp.close()
|
|
124
|
-
os.remove(filename)
|
|
125
|
-
except BaseException as e :
|
|
126
|
-
pass
|