File I/O¶
This module holds several methods for standard file I/O for the data formats that we work with regularly. Much of this regarding Grid objects in inherrited directly into the Grid class.
GridFileIO¶
-
class
wtools.fileio.
GridFileIO
[source]¶ Bases:
object
This class is inherrited by the
Grid
class and all these methods should be called fromGrid
. For example, If you have a file to read:Example
>>> import wtools >>> grid = wtools.Grid.read_sgems_grid('path/to/data/file.sgems') >>> grid.validate() True
-
classmethod
load_mesh
(filename)[source]¶ Open a json file and load the mesh into the
Grid
classParameters: filename (str) – name of file to read in
-
classmethod
read_sgems_grid
(fname, origin=[0.0, 0.0, 0.0], spacing=[1.0, 1.0, 1.0])[source]¶ Reads an SGeMS grid file where grid shape is defined in the header as three integers seperated by whitespace. Data arrays are treated as 3D and given in <x, y, z> indexing to a
Grid
object.Parameters: Returns: The SGeMS data loaded onto a
Grid
object.Return type:
-
classmethod
load_models¶
-
wtools.fileio.
load_models
(filename)[source]¶ Open a json file and loads the models into the target class As long as there are no namespace conflicts, the target __class__ will be stored on the properties.HasProperties registry and may be fetched from there. :param str filename: name of file to read in
read_gslib¶
-
wtools.fileio.
read_gslib
(filename)[source]¶ This will read a standard GSLib or GeoEAS data file to a pandas
DataFrame
.Parameters: filename (str) – the string file name of the data to load. This can be a relative or abslute file path. Returns: A table containing the all data arrays. Note that an attribute called header
is added to the data frame contianing the string header line of the file.Return type: pandas.DataFrame