hytools.io package

Submodules

hytools.io.envi module

HyTools: Hyperspectral image processing library Copyright (C) 2021 University of Wisconsin

Authors: Adam Chlus, Zhiwei Ye, Philip Townsend.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Functions for reading and writing ENVI formatted binary files

Todo

  • Implement opening of ENVI files with different byte order

class hytools.io.envi.WriteENVI(output_name, header_dict)[source]

Bases: object

Iterator class for writing to an ENVI data file.

close()[source]

Delete numpy memmap.

write_band(band, index)[source]
Parameters
  • band (numpy.ndarray) – Band array (lines,columns).

  • index (int) – Zero-based band index.

Returns

None.

write_chunk(chunk, line_index, column_index)[source]
Parameters
  • chunk (TYPE) – Chunks array (chunk lines,chunk columns,bands).

  • line_index (int) – Zero-based upper line index.

  • column_index (int) – Zero-based left column index.

Returns

None.

write_column(column, index)[source]
Parameters
  • column (numpy.ndarray) – Column array (lines,bands).

  • index (int) – Zero-based column index.

Returns

None.

write_line(line, index)[source]
Parameters
  • line (numpy.ndarray) – Line array (columns,bands).

  • index (int) – Zero-based line index.

Returns

None.

write_pixel(pixel, line_index, column_index)[source]
Parameters
  • pixel (TYPE) – pixel array (bands).

  • line_index (int) – Zero-based upper line index.

  • column_index (int) – Zero-based left column index.

Returns

None.

hytools.io.envi.envi_header_dict()[source]
Returns

Empty ENVI header dictionary.

Return type

dict

hytools.io.envi.envi_header_from_neon(hy_obj, interleave='bsq')[source]

Create an ENVI header dictionary from NEON metadata

Parameters
  • hy_obj (Hytools object) – Populated HyTools file object.

  • interleave (str, optional) – Date interleave type. Defaults to ‘bil’.

Returns

Populated ENVI header dictionary.

Return type

dict

hytools.io.envi.envi_read_band(data, index, interleave)[source]
Parameters
  • data (numpy.memmap) – Numpy memory-map.

  • index (int) – Zero-based line index.

  • interleave (str) – Data interleave type.

Returns

Band array (lines,columns).

Return type

numpy.ndarray

hytools.io.envi.envi_read_chunk(data, col_start, col_end, line_start, line_end, interleave)[source]
Parameters
  • data (numpy.memmap) – Numpy memory-map.

  • col_start (int) – Zero-based left column index.

  • col_end (int) – Non-inclusive zero-based right column index.

  • line_start (int) – Zero -ased top line index.

  • line_end (int) – Non-inclusive zero-based bottom line index.

  • interleave (str) – Data interleave type.

Returns

Chunk array (line_end-line_start,col_end-col_start,bands).

Return type

numpy.ndarray

hytools.io.envi.envi_read_column(data, index, interleave)[source]
Parameters
  • data (numpy.memmap) – Numpy memory-map.

  • index (int) – Zero-based column index.

  • interleave (str) – Data interleave type.

Returns

Column array (lines,bands).

Return type

numpy.ndarray

hytools.io.envi.envi_read_line(data, index, interleave)[source]
Parameters
  • data (numpy.memmap) – Numpy memory-map.

  • index (int) – Zero-based line index.

  • interleave (str) – Data interleave type.

Returns

Line array (columns, bands).

Return type

numpy.ndarray

hytools.io.envi.envi_read_pixels(data, lines, columns, interleave)[source]
Parameters
  • data (numpy.memmap) – Numpy memory-map.

  • lines (list) – List of zero-indexed line indices.

  • columns (list) – List of zero-indexed column indices.

  • interleave (str) – Data interleave type.

Returns

Pixel array (pixels,bands).

Return type

numpy.ndarray

hytools.io.envi.open_envi(hy_obj, anc_path={}, ext=False)[source]

Open ENVI formated image file and populate Hytools object.

Parameters
  • src_file (str) – Pathname of input ENVI image file, header assumed to be located in

  • directory. (same) –

  • anc_path (dict) – Dictionary with pathnames and band numbers of ancillary datasets.

  • ext – (bool) Input ENVI file has a file extension

Returns

Populated HyTools file object.

Return type

HyTools file object

hytools.io.envi.parse_envi_header(header_file)[source]
Parameters

header_file (str) – Header file pathname.

Returns

Populated header dictionary.

Return type

dict

hytools.io.envi.write_envi_header(output_name, header_dict, mode='w')[source]

Write ENVI header file to disk.

Parameters
  • output_name (str) – Header file pathname.

  • header_dict (dict) – Populated ENVI header dictionary.

  • mode (str) – File open mode. default: w

Returns

None.

hytools.io.neon module

HyTools: Hyperspectral image processing library Copyright (C) 2021 University of Wisconsin

Authors: Adam Chlus, Zhiwei Ye, Philip Townsend.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

NEON AOP HDF opener

hytools.io.neon.open_neon(hy_obj, no_data=-9999)[source]

Load and parse NEON formated HDF image into a HyTools file object.

Parameters
  • src_file (str) – pathname of input HDF file.

  • no_data (float, optional) – No data value. Defaults to -9999.

Returns

Populated HyTools file object.

Return type

HyTools file object

Module contents

HyTools: Hyperspectral image processing library Copyright (C) 2021 University of Wisconsin

Authors: Adam Chlus, Zhiwei Ye, Philip Townsend.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

The hytools.io module includes functions for reading from multiple file formats and writing to ENVI formatted binary files.