modify get_fy_awx function.
This commit is contained in:
parent
d5169f2483
commit
bded9aa8d8
@ -529,7 +529,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.7"
|
||||
"version": "3.9.12"
|
||||
},
|
||||
"widgets": {
|
||||
"application/vnd.jupyter.widget-state+json": {
|
||||
|
122
examples/retrieve_satellite.ipynb
Normal file
122
examples/retrieve_satellite.ipynb
Normal file
@ -0,0 +1,122 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a4641c58-14f3-4e58-af01-3ed5cd2b8867",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"source": [
|
||||
"# 读取风云卫星数据"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "3b5bee50-0cae-47c6-9244-144ed1748708",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# set up things\n",
|
||||
"%matplotlib inline\n",
|
||||
"%load_ext autoreload\n",
|
||||
"%autoreload 2\n",
|
||||
"\n",
|
||||
"import warnings\n",
|
||||
"warnings.filterwarnings('ignore')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"id": "1d813531-0813-4747-8066-c9cccad38773",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import numpy as np\n",
|
||||
"\n",
|
||||
"from nmc_met_io.read_satellite import read_awx_cloud"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"id": "642923ce-9879-4599-83dc-de3b051aeac8",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"headinfo, data = read_awx_cloud(\"./samples/ANI_IR1_R04_20220331_2100_FY2G.AWX\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"id": "2e4b15c0-73fc-4df0-98fc-c974778c2334",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"68"
|
||||
]
|
||||
},
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"np.min(data)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"id": "0c0fe240-f92b-429d-b7c1-479d00b1537b",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"array([1], dtype=int16)"
|
||||
]
|
||||
},
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"headinfo['productCategory']"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Meteorology with Python",
|
||||
"language": "python",
|
||||
"name": "met"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.12"
|
||||
},
|
||||
"widgets": {
|
||||
"application/vnd.jupyter.widget-state+json": {
|
||||
"state": {},
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
BIN
examples/samples/ANI_IR1_R04_20220331_2100_FY2G.AWX
Normal file
BIN
examples/samples/ANI_IR1_R04_20220331_2100_FY2G.AWX
Normal file
Binary file not shown.
@ -880,12 +880,12 @@ def get_fy_awx(directory, filename=None, suffix="*.AWX", units='', cache=True, c
|
||||
('dataRecordNumber', 'i2'), # 产品数据占用记录数
|
||||
('productCategory', 'i2'), # 产品类别, 1:静止, 2:极轨, 3:格点定量, 4:离散, 5: 图形和分析
|
||||
('compressMethod', 'i2'), # 压缩方式, 0: 未压缩; 1 行程编码压缩; 2 LZW方式压缩; 3 特点方式压缩
|
||||
('formatString', 'S8'), # 格式说明字符串, 'SAT2004'
|
||||
('formatString', 'S8'), # 格式说明字符串, 'SAT2004', 'SAT98'为早期版本(不支持)
|
||||
('qualityFlag', 'i2')] # 产品数据质量标记, 1 完全可靠; 2 基本可靠; 3 有缺值, 可用; 4 不可用
|
||||
head1_info = np.frombuffer(byteArray[0:40], dtype=head1_dtype)
|
||||
ind = 40
|
||||
|
||||
if head1_info['productCategory']:
|
||||
if head1_info['productCategory'] == 1:
|
||||
# the second class file head 二级文件头采用不定长方式,内容依据产品的不同而不同.
|
||||
head2_dtype = [
|
||||
('satelliteName', 'S8'), # 卫星名
|
||||
@ -927,15 +927,16 @@ def get_fy_awx(directory, filename=None, suffix="*.AWX", units='', cache=True, c
|
||||
table_B = np.frombuffer(byteArray[ind:(ind + 256)], dtype='u1')
|
||||
ind += 256
|
||||
|
||||
# calibration table
|
||||
# calibration table 定标数据块
|
||||
calibration_table = None
|
||||
if head2_info['dataLengthOfCalibration'] != 0:
|
||||
calibration_table = np.frombuffer(byteArray[ind:(ind + 2048)], dtype='i2')
|
||||
calibration_table = np.frombuffer(byteArray[ind:(ind + 2048)], dtype='u2')
|
||||
calibration_table = calibration_table * 0.01
|
||||
if (np.array_equal(calibration_table[0::4], calibration_table[1::4]) and
|
||||
np.array_equal(calibration_table[0::4], calibration_table[2::4]) and
|
||||
np.array_equal(calibration_table[0::4], calibration_table[3::4])):
|
||||
#if (np.array_equal(calibration_table[0::4], calibration_table[1::4]) and
|
||||
# np.array_equal(calibration_table[0::4], calibration_table[2::4]) and
|
||||
# np.array_equal(calibration_table[0::4], calibration_table[3::4])):
|
||||
# This is a trick, refer to http://bbs.06climate.com/forum.php?mod=viewthread&tid=89296
|
||||
# calibration_table = calibration_table[0::4]
|
||||
calibration_table = calibration_table[0::4]
|
||||
ind += 2048
|
||||
|
||||
@ -1036,6 +1037,8 @@ def get_fy_awx(directory, filename=None, suffix="*.AWX", units='', cache=True, c
|
||||
else:
|
||||
return None
|
||||
|
||||
directory = "SATELLITE/FY2G/L1/IR1/EQUAL/"
|
||||
data = get_fy_awx(directory, cache=False)
|
||||
|
||||
def get_fy_awxs(directory, filenames, allExists=True, pbar=False, **kargs):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user