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: PVGeo.readers.delimited.DelimitedTextReader

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

GetDataName()[source]
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.

SetDataName(dataName)[source]
_ExtractHeader(content)[source]

Override this. Removes header from single file’s content.

_FileContentsToDataFrame(contents)[source]

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

_GetRawData(idx=0)[source]

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

description = 'PVGeo: Esri Grid'
extensions = 'asc dem txt'

Landsat XML Reader

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

Bases: PVGeo.base.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

CastDataType(flag)[source]

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

static GetColorSchemeNames()[source]
GetDataSelection()[source]

Used by ParaView GUI

GetFileName()[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 GetFileNames().

Modified(readAgain=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.

SetColorScheme(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.

_BuildImageData(output)[source]

Properly builds the output vtkImageData object

_GetFileContents(idx=None)[source]

Reads XML meta data, no data read.

_GetRawData(idx=0)[source]

Perfroms the read for the selected bands

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

Surfer Grid Reader

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

Bases: PVGeo.base.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.

GetDataName()[source]
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.

SetDataName(dataName)[source]
_ReadGrids(idx=None)[source]

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

_ReadUpFront()[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'

Write Cell Centers To CSV

class PVGeo.grids.fileio.WriteCellCenterData[source]

Bases: PVGeo.base.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.

PerformWriteOut(inputDataObject, filename, objectName)[source]

This method must be implemented. This is automatically called by RequestData for single inputs or composite inputs.

SetDelimiter(delimiter)[source]

The string delimiter to use

Write vtkImageData to Surfer Format

class PVGeo.grids.fileio.WriteImageDataToSurfer[source]

Bases: PVGeo.base.WriterBase

Write a 2D vtkImageData object to the Surfer grid format

Apply(inputDataObject, arrayName)[source]

Update the algorithm and get the output data object

PerformWriteOut(inputDataObject, filename, objectName)[source]

This method must be implemented. This is automatically called by RequestData for single inputs or composite inputs.

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(inputDataObject=None, arrayName=None)[source]

Perfrom the write out.