From 6dbc86f9e08afe54dbfb368832e349562e3c437d Mon Sep 17 00:00:00 2001 From: Dengda98 Date: Thu, 15 Jan 2026 21:41:11 +0800 Subject: [PATCH 1/3] FEAT: set default value `allowLiquid=True` in PyModel1D.__init__() --- pygrt/pymod.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygrt/pymod.py b/pygrt/pymod.py index 37398dc..e389d5f 100755 --- a/pygrt/pymod.py +++ b/pygrt/pymod.py @@ -33,7 +33,7 @@ class PyModel1D: - def __init__(self, modarr0:np.ndarray, depsrc:float, deprcv:float, allowLiquid:bool=False, + def __init__(self, modarr0:np.ndarray, depsrc:float, deprcv:float, allowLiquid:bool=True, topbound:Literal['free', 'rigid', 'halfspace']='free', botbound:Literal['free', 'rigid', 'halfspace']='halfspace'): ''' From 73a4d456bbf3f119283d5817c9b643a1dcd35654 Mon Sep 17 00:00:00 2001 From: Dengda98 Date: Thu, 15 Jan 2026 21:48:16 +0800 Subject: [PATCH 2/3] update --- pygrt/pymod.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pygrt/pymod.py b/pygrt/pymod.py index e389d5f..10e0a1b 100755 --- a/pygrt/pymod.py +++ b/pygrt/pymod.py @@ -33,7 +33,7 @@ class PyModel1D: - def __init__(self, modarr0:np.ndarray, depsrc:float, deprcv:float, allowLiquid:bool=True, + def __init__(self, modarr0:np.ndarray, depsrc:float, deprcv:float, topbound:Literal['free', 'rigid', 'halfspace']='free', botbound:Literal['free', 'rigid', 'halfspace']='halfspace'): ''' @@ -42,7 +42,6 @@ def __init__(self, modarr0:np.ndarray, depsrc:float, deprcv:float, allowLiquid:b :param modarr0: model array, in the format of [thickness(km), Vp(km/s), Vs(km/s), Rho(g/cm^3), Qp, Qs] :param depsrc: source depth (km) :param deprcv: receiver depth (km) - :param allowLiquid: whether liquid layers are allowed :param topbound: boundary condition of the top layer :param botbound: boundary condition of the bottom layer @@ -50,9 +49,9 @@ def __init__(self, modarr0:np.ndarray, depsrc:float, deprcv:float, allowLiquid:b self.depsrc:float = depsrc self.deprcv:float = deprcv self.c_mod1d:c_GRT_MODEL1D - self.hasLiquid:bool = allowLiquid # 传入的模型是否有液体层 self.topbound:str = topbound self.botbound:str = botbound + self.hasLiquid = False boundDct = { 'free': 0, @@ -72,7 +71,7 @@ def __init__(self, modarr0:np.ndarray, depsrc:float, deprcv:float, allowLiquid:b tmp_path = tmpfile.name # 获取临时文件路径 try: - c_mod1d_ptr = C_grt_read_mod1d_from_file(tmp_path.encode("utf-8"), depsrc, deprcv, allowLiquid) + c_mod1d_ptr = C_grt_read_mod1d_from_file(tmp_path.encode("utf-8"), depsrc, deprcv, True) self.c_mod1d = c_mod1d_ptr.contents # 这部分内存在C中申请,需由C函数释放。占用不多,这里跳过 C_grt_set_mod1d_boundary(self.c_mod1d, boundDct[topbound], boundDct[botbound]) finally: From 8b3c41be311e1aabfde815ae8b32d0ee56531a90 Mon Sep 17 00:00:00 2001 From: Dengda98 Date: Thu, 15 Jan 2026 21:50:46 +0800 Subject: [PATCH 3/3] update --- pygrt/pymod.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pygrt/pymod.py b/pygrt/pymod.py index 10e0a1b..da542f9 100755 --- a/pygrt/pymod.py +++ b/pygrt/pymod.py @@ -33,7 +33,7 @@ class PyModel1D: - def __init__(self, modarr0:np.ndarray, depsrc:float, deprcv:float, + def __init__(self, modarr0:np.ndarray, depsrc:float, deprcv:float, allowLiquid:bool=True, topbound:Literal['free', 'rigid', 'halfspace']='free', botbound:Literal['free', 'rigid', 'halfspace']='halfspace'): ''' @@ -42,6 +42,7 @@ def __init__(self, modarr0:np.ndarray, depsrc:float, deprcv:float, :param modarr0: model array, in the format of [thickness(km), Vp(km/s), Vs(km/s), Rho(g/cm^3), Qp, Qs] :param depsrc: source depth (km) :param deprcv: receiver depth (km) + :param allowLiquid: (deprecated) unused argument :param topbound: boundary condition of the top layer :param botbound: boundary condition of the bottom layer