Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External Binary Arrays being written twice #1925

Closed
sharon92 opened this issue Aug 22, 2023 · 0 comments
Closed

External Binary Arrays being written twice #1925

sharon92 opened this issue Aug 22, 2023 · 0 comments
Assignees

Comments

@sharon92
Copy link

def write_binary_file(
self,
data,
fname,
text,
modelgrid=None,
modeltime=None,
stress_period=0,
precision="double",
write_multi_layer=False,
):
data = self._resolve_cellid_numbers_to_file(data)
fd = self._open_ext_file(fname, binary=True, write=True)
if write_multi_layer:
for layer, value in enumerate(data):
self._write_layer(
fd,
value,
modelgrid,
modeltime,
stress_period,
precision,
text,
fname,
layer + 1,
)
else:
self._write_layer(
fd,
data,
modelgrid,
modeltime,
stress_period,
precision,
text,
fname,
)
data.tofile(fd)
fd.close()
def _write_layer(
self,
fd,
data,
modelgrid,
modeltime,
stress_period,
precision,
text,
fname,
ilay=None,
):
header_data = self._get_header(
modelgrid, modeltime, stress_period, precision, text, fname, ilay
)
header_data.tofile(fd)
data.tofile(fd)

in this code snippet, data is first written via _write_layer and then via write_binary_file.

Creating an unnecessary large file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants