Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pygrt/pymod.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'):
'''
Expand All @@ -42,17 +42,17 @@ 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 allowLiquid: (deprecated) unused argument
:param topbound: boundary condition of the top layer
:param botbound: boundary condition of the bottom layer

'''
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,
Expand All @@ -72,7 +72,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:
Expand Down