crunchflow.output.spatial

Tools for loading, analyzing, and visualizing spatial profile output from CrunchFlow.

This module provides the SpatialProfile class and associated utility functions to work with CrunchFlow spatial output files (commonly .tec, .out, or .dat files). These files contain gridded data written at specified output times during a simulation, and typically include variables such as mineral saturation, aqueous species concentrations, porosity, and permeability across 1D, 2D, or 3D model domains.

Key Features

  • Automatically detects file format and loads output variables and metadata.

  • Supports plotting 2D images or contour maps for any output variable.

  • Enables comparison of results across time steps using plot_series.

  • Extracts outlines of zones sharing a common attribute (e.g., permeability zone boundaries).

  • Compatible with .tec, .out, and .dat formats written by CrunchFlow.

Classes

SpatialProfile

The SpatialProfile class for working with spatial_profile (.tec, .out and .dat) files.

Functions

isnumeric_scientific(s)

Check if a string is numeric.

read_output_times(fname)

Given a CrunchFlow input file, return the spatial_profile output times.

get_tec_metadata(file[, folder])

Return a list of the variables in a spatial_profile output file.

get_out_output_time(file)

Get the output time from a CrunchFlow .out file.

get_tec_output_times(crunch_log[, folder])

Given a CrunchFlow output log, get the spatial_profile output times.

Module Contents

crunchflow.output.spatial.isnumeric_scientific(s)[source]

Check if a string is numeric.

Return True if a string is an integer, float or in scientific notation, and False otherwise.

crunchflow.output.spatial.read_output_times(fname)[source]

Given a CrunchFlow input file, return the spatial_profile output times.

Parameters:
fnamestr

Name of the input file to read

Returns:
output_timeslist

Output times read from the input file

crunchflow.output.spatial.get_tec_metadata(file, folder='.')[source]

Return a list of the variables in a spatial_profile output file.

Given a crunch .tec output file, read it in and return a list of the variables (e.g., ‘X-Perm’, ‘Y-Perm’, etc) included in the output file.

Parameters:
filestr

Filename to read in

folderstr

Folder in which ‘file’ is located. The default is the current directory

Returns:
columnslist, str

ordered list of variables included in filename

titlestr

Value included in this file, as output by CrunchFlow

fmtstr

Format of the file, either ‘.tec’ or ‘.out’

crunchflow.output.spatial.get_out_output_time(file)[source]

Get the output time from a CrunchFlow .out file.

Given a CrunchFlow .out file, read it in and return the output time, which should be stored in the first line.

Parameters:
filestr

Filename to read in

Returns:
timefloat

output time of the file

crunchflow.output.spatial.get_tec_output_times(crunch_log, folder='.')[source]

Given a CrunchFlow output log, get the spatial_profile output times.

Search through a file containing all terminal output from a CrunchFlow run and return the spatial_profile output times. For example, during a simulation, CrunchFlow will print progress to the screen, including blocks that look like:

>>> WRITING OUTPUT FILES
>>> Time (days) =  9.000E+00
>>> File number  =            2

This function combs through that terminal output to create a list of times at which .tec files were written. Note that this function is no longer maintained and has been superseded by read_output_times.

Parameters:
crunch_logstr

Filename of the crunchflow terminal output

folderstr

Folder in which ‘crunch_log’ is located.The default is the current directory

Returns:
output_timeslist of float

Ordered list of the output times (in CrunchFlow time units) corresponding to each .tec file number.