From 2e4cc232e77257137510b6fb3bf74de36170a0ea Mon Sep 17 00:00:00 2001 From: Longtsing Date: Sat, 24 May 2025 22:26:53 +0800 Subject: [PATCH 1/2] Update read_graphydata.py to fix the bug 186 fix the bug https://github.com/nmcdev/meteva/issues/186 --- meteva/base/io/read_graphydata.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/meteva/base/io/read_graphydata.py b/meteva/base/io/read_graphydata.py index 4fe002ba..82428ba9 100644 --- a/meteva/base/io/read_graphydata.py +++ b/meteva/base/io/read_graphydata.py @@ -22,13 +22,19 @@ def read_micaps14(filename,time = None,dtime = 0,data_name = None): txt = None try: with open(filename, 'r', encoding=encoding) as f: - txt = f.read().replace('\n', ' ').split() + txt = f.read() except Exception: pass if txt is None: print("Micaps 14 file error: " + filename) return None + # fix the bug https://github.com/nmcdev/meteva/issues/186 + txtlines=txt.split('\n') + txtline1s=txtlines[0].split() + txtlines[0]=' '.join([txtline1s[0],txtline1s[1],'_'.join(txtline1s[2:])]) + txt=' '.join(txtlines).split() + # head information _ = txt[2] From b4f8fca521b5132f12923a04be1a397e146e71ff Mon Sep 17 00:00:00 2001 From: Longtsing Date: Sun, 25 May 2025 01:53:27 +0800 Subject: [PATCH 2/2] Update read_graphydata.py to fix the bug 188 Update read_graphydata.py to fix the bug https://github.com/nmcdev/meteva/issues/188 --- meteva/base/io/read_graphydata.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/meteva/base/io/read_graphydata.py b/meteva/base/io/read_graphydata.py index 82428ba9..373b0694 100644 --- a/meteva/base/io/read_graphydata.py +++ b/meteva/base/io/read_graphydata.py @@ -279,17 +279,19 @@ def read_micaps14(filename,time = None,dtime = 0,data_name = None): # get the start position idx = txt.index('STATION_SITUATION') + # fix the bug https://github.com/nmcdev/meteva/issues/188 # find data subscript end_idx = idx + 1 - while end_idx < len(txt): + while end_idx < len(txt) and not 'WEATHER_REGION' in txt[end_idx]: if txt[end_idx].isdigit(): end_idx += 1 else: try: f = float(txt[end_idx]) - end_idx += 1 except: - break + pass + finally: + end_idx += 1 if end_idx > idx + 1: stations = np.array(txt[(idx+1):(end_idx)])