resqpy.olio.load_data.load_array_from_ascii_file

resqpy.olio.load_data.load_array_from_ascii_file(file_name, extent=None, data_type='real', keyword=None, max_lines_for_keyword=None, comment_char=None, data_free_of_comments=False, skip_c_space=True, use_numbers_only=None)[source]

Returns a numpy array with data loaded from an ascii file.

Parameters
  • file_name – string holding name of the existing ascii data file, eg. ‘Cell_depth.dat’

  • extent – a python list of integers specifying the extent (shape) of the array, eg. [148, 270, 103]; if None, all data is read and returned as a ‘flat’ 1D array (data must be free from comments)

  • data_type – the type of individual data elements, one of ‘real’,’float’,’int’, ‘integer’, ‘bool’ or ‘boolean’

  • keyword – if present, an attempt is made to find the keyword before reading data, if keyword is None or is not found, data is read from the start of the file

  • max_lines_for_keyword – can be used to limit the search for keyword (for speed efficiency)

  • comment_char – a single character string being the character used to introduce a comment in the file

  • data_free_of_comments – if set to True, a faster load is used once any header line comments have been skipped

  • skip_c_space – if True then a line starting ‘C’ followed by white space is skipped as a comment

  • use_numbers_only – this argument is no longer in use and is ignored

Returns

a numpy array of shape specified in extent argument with dtype matching data_type

example call:

depth_array = load_data.load_array_from_ascii_file(‘Cell_depth.dat’, [148, 270, 103])

Notes

In all use cases, this function is designed to load a single array of data from an ascii file that DOES NOT CONTAIN OTHER ARRAYS as well, ie. data for a single simulation keyword in the file.

If skip_c_space is True, lines starting ‘C ‘ are also treated as comments. If data_free_of_comments is True, there must be at least one blank line before the data begins, and no further comments are permitted. (This format is designed to handle data files generated by a commonly used geomodelling package.)

Repeat counts must not be present in the ascii data.

The extent, if present, can contain any number of dimensions, typically 3 for reservoir modelling work. The total number of numbers in the file must match the number of elements in the given extent (ie. the product of the list of numbers in the extent argument). The order of indices in extent should be ‘slowest changing’ first, eg.: k,j,i

The data_type defaults to ‘real’ ‘real’ and ‘float’ are synonymous; ‘int’ and ‘integer’ are synonymous; ‘bool’ and ‘boolean’ are synonymous; default is ‘real’ The numpy data type will be the default 64 bit float or 64 bit int