Reputation: 1
I used the code to read cbb file, and tried to extract data in a new txt file. But the program completes very quickly and the output txt file is empty.
import flopy
cbb_file = r'D:\ZFZ\TBW_Project\IHM_Sim\IHM\IHM_input\Calibration\MODFLOW\gv37.cbb'
cbb = flopy.utils.CellBudgetFile(cbb_file)
times = cbb.get_times()
output_file_baseflow = r'D:\ZFZ\TBW_Project\IHM_Sim\IHM\IHM_input\Calibration\MODFLOW\baseflow.txt'
with open(output_file_baseflow, 'w') as file:
file.write("Text Entry, Time, Row, Column, Layer, Flow Data\n")
for time_step, time in enumerate(times):
baseflow_data = cbb.get_data(totim=time)
for layer, data in enumerate(baseflow_data):
for row, cols in enumerate(data):
for col, baseflow in enumerate(cols):
file.write(f"{baseflow['text']}, {time}, {layer}, {row}, {col}, {baseflow['q']}\n")
print(f"Flow data with layers saved to {output_file_baseflow}")
Upvotes: 0
Views: 92
Reputation: 76
Can you verify that the size of the cbb file is as expected? If it is the expected size, can you experiment with the optional precision
argument to see if that will get the reader to appropriately process the binary records?
Upvotes: 0