def _load_skin(filename: str, endian: str = '>'):
"""
The structure of skin file: header, mid, tail
header: ncells, (i1seed, i2seed, i3seed)(new version), int32
mid: [z, y, x, likelihood, strike, dip, ...] * ncells, float32
tail: [above, below, left, right] * ncells, int32
load a skin file into two parts: mid and tail
Parameters
-----------
filename : str
skin file name
endian : str
little endian is '<', big endian is '>'
Returns
--------
mid : array-like
shape is [ncells, 12] or [ncells, 9] (old version)
tail : array-like
shape is [ncells, 12] or [ncells, 4] (old version)
"""
d = np.fromfile(filename, dtype=np.int32)
if endian == '>':
d = d.byteswap()
if (d[0] * 24 + 4) == len(d) or (d[0] * 13 + 1) == len(d):
ncell = d[0]
nele = (len(d) - 4) // ncell
if nele == 24:
nattr = 12
nnigb = 12
mid = d[4:4 + ncell * nattr].view(np.float32).reshape(ncell, nattr)
tail = d[4 + ncell * nattr:].reshape(ncell, nnigb)
else:
nattr = 9
nnigb = 4
mid = d[1:1 + ncell * nattr].view(np.float32).reshape(ncell, nattr)
tail = d[1 + ncell * nattr:].reshape(ncell, nnigb)
elif (2 + d[0] * 6 + d[1] * 10) == len(d):
""".cig format"""
nctrl = d[0]
ncell = d[1]
start = 2 + nctrl * 6
mid = d[start:start + ncell * 6].view(np.float32).reshape(ncell, 6)
tail = d[start + ncell * 6:].reshape(ncell, 4)
else:
raise RuntimeError("Unknow file type")
return mid, tail
Let me know if this implementation make sense, will create PR to integrate this changes
Current implementation of the function
_load_skinonly enable new fault skin to be loaded since old fault skin only have 1 header.The function need to be modified as follows:
Let me know if this implementation make sense, will create PR to integrate this changes