-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheck_ncwf_data.py
More file actions
55 lines (47 loc) · 1.92 KB
/
check_ncwf_data.py
File metadata and controls
55 lines (47 loc) · 1.92 KB
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
53
54
55
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import numpy as np
import os
# 检查NCWF数据文件内容
print("=== 检查NCWF数据文件 ===")
# 加载ncwf_info_file.npz
ncwf_info_path = 'data_sampled/NCWF/ncwf_info_file.npz'
if os.path.exists(ncwf_info_path):
print(f"加载文件: {ncwf_info_path}")
ncwf_info = np.load(ncwf_info_path)
print(f"文件中的键: {list(ncwf_info.keys())}")
# 检查start_time
if 'start_time' in ncwf_info:
start_time = ncwf_info['start_time']
print(f"start_time形状: {start_time.shape}")
print(f"start_time前10个条目:")
for i in range(min(10, len(start_time))):
print(f" {i}: {start_time[i]}")
# 生成对应的文件名
print("\n对应的NCWF文件名:")
for i in range(min(5, len(start_time))):
obj = start_time[i]
fname = '%d_%s_%s_%s00Z.npz'%(obj[0], str(obj[1]).zfill(2), str(obj[2]).zfill(2), str(obj[3]).zfill(2))
print(f" {fname}")
# 检查其他键
for key in ncwf_info.keys():
if key != 'start_time':
data = ncwf_info[key]
print(f"\n{key}: 形状={data.shape}, 类型={data.dtype}")
if len(data.shape) <= 2 and data.size <= 20:
print(f" 内容: {data}")
else:
print(f"文件不存在: {ncwf_info_path}")
# 检查gridded_storm.npz
gridded_storm_path = 'data_sampled/NCWF/gridded_storm.npz'
if os.path.exists(gridded_storm_path):
print(f"\n\n=== 检查 {gridded_storm_path} ===")
gridded_storm = np.load(gridded_storm_path)
print(f"文件中的键: {list(gridded_storm.keys())}")
for key in gridded_storm.keys():
data = gridded_storm[key]
print(f"\n{key}: 形状={data.shape}, 类型={data.dtype}")
if key == 'start_time' and len(data) > 0:
print(f" 前5个时间: {data[:5]}")
else:
print(f"\n文件不存在: {gridded_storm_path}")