File I/O

This module contains general grid readers and writers for programs like Surfer.

Esri Grid Reader

class PVGeo.grids.fileio.EsriGridReader(outputType='vtkImageData', **kwargs)[source]

Bases: DelimitedTextReader

See details: https://en.wikipedia.org/wiki/Esri_grid

RequestData(request, inInfo, outInfo)[source]

Used by pipeline to get data for current timestep and populate the output data object.

RequestInformation(request, inInfo, outInfo)[source]

Used by pipeline to set grid extents.

_extract_header(content)[source]

Internal helper to parse header information in ESRI Grid files

_file_contents_to_data_frame(contents)[source]

Creates a dataframe with a single array for the file data.

_get_raw_data(idx=0)[source]

This will return the proper data for the given timestep. This method handles Surfer’s NaN data values and checks the value range

description = 'PVGeo: Esri Grid'
extensions = 'asc dem txt'
get_data_name()[source]

Get the name of the data array

get_shape()[source]

Get the shape of the grid.

set_data_name(data_name)[source]

Set the name of the data array

Landsat XML Reader

class PVGeo.grids.fileio.LandsatReader(**kwargs)[source]

Bases: ReaderBaseBase

A reader that will handle ESPA XML files for Landsat Imagery. This reader uses the espatools package to read Landsat rasters (band sets) and creates vtkImageData with each band as point data

GetDataSelection()[source]

Used by ParaView GUI

Modified(read_again=False)[source]

Ensure default is overridden to be false so array selector can call.

RequestData(request, inInfo, outInfo)[source]

Used by pipeline to generate output

RequestInformation(request, inInfo, outInfo)[source]

Used by pipeline to set grid extents.

_build_image_data(output)[source]

Properly builds the output vtkImageData object

_get_file_contents(idx=None)[source]

Reads XML meta data, no data read.

_get_raw_data(idx=0)[source]

Performs the read for the selected bands

_read_up_front()[source]

Internal helper to read all data at start

description = 'PVGeo: Landsat ESPA XML Metadata'
extensions = 'xml'
static get_color_scheme_names()[source]

Get a list of the available color schemes

get_file_name()[source]

Super class has file names as a list but we will only handle a single project file. This provides a conveinant way of making sure we only access that single file. A user could still access the list of file names using get_file_names().

modified(read_again=False)[source]
set_cast_data_type(flag)[source]

A flag to cast all data arrays as floats/doubles. This will fill invalid values with nans instead of a fill value

set_color_scheme(scheme)[source]

Get an RGB scheme from the raster set. If no scheme is desired, pass any string that is not a defined scheme as the scheme argument.

Surfer Grid Reader

class PVGeo.grids.fileio.SurferGridReader(outputType='vtkImageData', **kwargs)[source]

Bases: ReaderBase

Read 2D ASCII/Binary Surfer grid files. The IO code was adopted from Seequent’s steno3d_surfer

Note

MIT License

Copyright (c) 2018 Seequent

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the β€œSoftware”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED β€œAS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

RequestData(request, inInfo, outInfo)[source]

Used by pipeline to get data for current timestep and populate the output data object.

RequestInformation(request, inInfo, outInfo)[source]

Used by pipeline to set grid extents.

_read_grids(idx=None)[source]

This parses the first file to determine grid file type then reads all files set.

_read_up_front()[source]

Should not need to be overridden.

static _surfer6ascii(filename)[source]

See class notes.

static _surfer6bin(filename)[source]

See class notes.

static _surfer7bin(filename)[source]

See class notes.

description = 'PVGeo: Surfer Grid'
extensions = 'grd GRD'
get_data_name()[source]

Get the name of the data array

set_data_name(data_name)[source]

Set the name of the data array

Write Cell Centers To CSV

class PVGeo.grids.fileio.WriteCellCenterData[source]

Bases: WriterBase

This writer will save a file of the XYZ points for an input dataset’s cell centers and its cell data. Use in tandom with ParaView’s native CSV writer which saves the PointData.

perform_write_out(input_data_object, filename, object_name)[source]

Writes the cell centers of the input data object to a file

set_delimiter(deli)[source]

The string delimiter to use

Write vtkImageData to Surfer Format

class PVGeo.grids.fileio.WriteImageDataToSurfer[source]

Bases: WriterBase

Write a 2D vtkImageData object to the Surfer grid format

SetInputArrayToProcess(idx, port, connection, field, name)[source]

Used to the inpput array / the data value (z-value) to write for the Surfer format.

Parameters:
  • idx (int) – the index of the array to process

  • port (int) – input port (use 0 if unsure)

  • connection (int) – the connection on the port (use 0 if unsure)

  • field (int) – the array field (0 for points, 1 for cells, 2 for field, and 6 for row)

  • name (int) – the name of the array

Write(input_data_object=None, array_name=None)[source]

Perform the write out.

apply(input_data_object, array_name)[source]

Run the algorithm on an input data object, specifying one data array to save out.

perform_write_out(input_data_object, filename, object_name)[source]

Writes an input vtkImageData object to a file

write(input_data_object=None, array_name=None)[source]

Perform the write out.