|
|
|
@ -55,8 +55,8 @@ DESCRIPTORS = { |
|
|
|
"0 31 002": {"bits": 16, "scale": 0, "offset": 0, "type": "UINT","name": "EXTENDED DELAYED DESCRIPT.REPLIC.FACTOR"}, |
|
|
|
"0 31 002": {"bits": 16, "scale": 0, "offset": 0, "type": "UINT","name": "EXTENDED DELAYED DESCRIPT.REPLIC.FACTOR"}, |
|
|
|
"0 31 012": {"bits": 16, "scale": 0, "offset": 0, "type": "UINT","name": "EXT.DEL.DESCRIPT.AND DATA REPETIT.FACTOR"}, |
|
|
|
"0 31 012": {"bits": 16, "scale": 0, "offset": 0, "type": "UINT","name": "EXT.DEL.DESCRIPT.AND DATA REPETIT.FACTOR"}, |
|
|
|
"0 21 001": {"bits": 7, "scale": 0, "offset": -64, "type": "UINT", "name": "HORIZONTAL REFLECTIVITY"}, |
|
|
|
"0 21 001": {"bits": 7, "scale": 0, "offset": -64, "type": "UINT", "name": "HORIZONTAL REFLECTIVITY"}, |
|
|
|
"0 21 003": {"bits": 7, "scale": 1, "offset": -5, "type": "UINT", "name": "DIFFERENTIAL REFLECTIVITY"}, |
|
|
|
"0 21 003": {"bits": 7, "scale": -1, "offset": -5, "type": "UINT", "name": "DIFFERENTIAL REFLECTIVITY"}, |
|
|
|
"0 21 014": {"bits": 13, "scale": 1, "offset": -4096, "type": "UINT", "name": "DOPPLER MEAN VELOCITY RADIAL"}, |
|
|
|
"0 21 014": {"bits": 13, "scale": -1, "offset": -4096, "type": "UINT", "name": "DOPPLER MEAN VELOCITY RADIAL"}, |
|
|
|
"0 21 022": {"bits": 5, "scale": 0, "offset": 0, "type": "UINT", "name": "METEO [SFG NOTE: UNKNOWN]"}, |
|
|
|
"0 21 022": {"bits": 5, "scale": 0, "offset": 0, "type": "UINT", "name": "METEO [SFG NOTE: UNKNOWN]"}, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -64,6 +64,8 @@ SEQUENCES = { |
|
|
|
"3 01 024": ["0 05 002", "0 06 002", "0 07 001"], # LAT/LON/HEIGHT |
|
|
|
"3 01 024": ["0 05 002", "0 06 002", "0 07 001"], # LAT/LON/HEIGHT |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEBUG = False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ============================================================================ |
|
|
|
# ============================================================================ |
|
|
|
# BUFR Reader |
|
|
|
# BUFR Reader |
|
|
|
@ -137,14 +139,29 @@ class BitReader: |
|
|
|
bits, scale, offset = desc["bits"], desc["scale"], desc["offset"] |
|
|
|
bits, scale, offset = desc["bits"], desc["scale"], desc["offset"] |
|
|
|
dtype = desc["type"] |
|
|
|
dtype = desc["type"] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val = -9999999 |
|
|
|
|
|
|
|
raw_val = -9999999 |
|
|
|
if dtype == "IA5": |
|
|
|
if dtype == "IA5": |
|
|
|
val = self.read_ia5(bits) |
|
|
|
val = self.read_ia5(bits) |
|
|
|
elif dtype == "INT": |
|
|
|
elif dtype == "INT": |
|
|
|
val = (self.read_int(bits) + offset) * (10 ** scale) |
|
|
|
raw_val = self.read_int(bits) |
|
|
|
elif dtype == "UINT": |
|
|
|
elif dtype == "UINT": |
|
|
|
val = (self.read_uint(bits) + offset) * (10 ** scale) |
|
|
|
raw_val = self.read_uint(bits) |
|
|
|
else: |
|
|
|
|
|
|
|
val = None |
|
|
|
|
|
|
|
|
|
|
|
if dtype != "IA5": |
|
|
|
|
|
|
|
val = (raw_val + offset) * (10 ** scale) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if "DIFFERENTIAL" in desc["name"]: |
|
|
|
|
|
|
|
val = val - int(val > 6) * 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# hot fix from FK code |
|
|
|
|
|
|
|
if "DOPPLER" in desc["name"]: |
|
|
|
|
|
|
|
if val < -50: |
|
|
|
|
|
|
|
val = np.nan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if DEBUG: |
|
|
|
|
|
|
|
print(f"desc_code: {desc_code}, val: {val}") |
|
|
|
|
|
|
|
|
|
|
|
return val |
|
|
|
return val |
|
|
|
|
|
|
|
|
|
|
|
@ -281,13 +298,14 @@ def parse_bufr_block(bufr_data, data_type='dBz'): |
|
|
|
grid = np.full(10000, np.nan, dtype=np.float32) |
|
|
|
grid = np.full(10000, np.nan, dtype=np.float32) |
|
|
|
position = 0 |
|
|
|
position = 0 |
|
|
|
n_pixels_with_data = reader.read_descriptor("0 31 002") |
|
|
|
n_pixels_with_data = reader.read_descriptor("0 31 002") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for _ in range(n_pixels_with_data): |
|
|
|
for _ in range(n_pixels_with_data): |
|
|
|
n_skip = reader.read_descriptor("0 31 012") |
|
|
|
n_skip = reader.read_descriptor("0 31 012") |
|
|
|
marker = reader.read_descriptor(descriptor_code) |
|
|
|
marker = reader.read_descriptor(descriptor_code) |
|
|
|
|
|
|
|
|
|
|
|
# Заполняем пропущенные пиксели |
|
|
|
# Заполняем пропущенные пиксели |
|
|
|
if n_skip > 0 and position + n_skip <= 10000: |
|
|
|
if n_skip > 0: # and position + n_skip <= 10000: |
|
|
|
grid[position:position + n_skip] = marker |
|
|
|
grid[position:position + n_skip] = marker |
|
|
|
position += n_skip |
|
|
|
position += n_skip |
|
|
|
|
|
|
|
|
|
|
|
@ -306,7 +324,8 @@ def parse_bufr_block(bufr_data, data_type='dBz'): |
|
|
|
# поэтому здесь, в отличие от старого кода для DAT-файлов, нет необходимости применять их еще раз. |
|
|
|
# поэтому здесь, в отличие от старого кода для DAT-файлов, нет необходимости применять их еще раз. |
|
|
|
return grid |
|
|
|
return grid |
|
|
|
|
|
|
|
|
|
|
|
except Exception: |
|
|
|
except Exception as e: |
|
|
|
|
|
|
|
print(f"Error parsing BUFR block: {e}") |
|
|
|
return None |
|
|
|
return None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -542,7 +561,7 @@ def load_npz_data(npz_path): |
|
|
|
'dbz': data['dbz'], |
|
|
|
'dbz': data['dbz'], |
|
|
|
'dbzd': data['dbzd'], |
|
|
|
'dbzd': data['dbzd'], |
|
|
|
'doppler': data['doppler'], |
|
|
|
'doppler': data['doppler'], |
|
|
|
'meteo': data['meteo'], |
|
|
|
'meteo': data['meteo'] if 'meteo' in data else np.zeros((144, 100, 100)), |
|
|
|
'times': data['times'] if 'times' in data else None |
|
|
|
'times': data['times'] if 'times' in data else None |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|