Skip to content

Commit

Permalink
Cherry picks of recent PRs to 1.9 (#1056)
Browse files Browse the repository at this point in the history
* Fix TIFF statistics in case WCS output has NaNs (#1054)

* Fix TIFF statistics in case WCS output has NaNs

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

(cherry picked from commit b287167)

* [pre-commit.ci] pre-commit autoupdate (#1029)

updates:
- [github.com/PyCQA/flake8: 7.0.0 → 7.1.1](PyCQA/flake8@7.0.0...7.1.1)
- [github.com/PyCQA/pylint: v3.2.3 → v3.2.6](pylint-dev/pylint@v3.2.3...v3.2.6)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
(cherry picked from commit e3ff31c)

---------

Co-authored-by: Christoph Friedrich <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 9, 2024
1 parent 91e0f89 commit 78648aa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
rev: 7.1.1
hooks:
- id: flake8
args: ["--ignore=E501", "--select=F401,E201,E202,E203,E502,E241,E225,E306,E231,E226,E123,F811"]
Expand All @@ -15,7 +15,7 @@ repos:
# hooks:
# - id: bandit
- repo: https://github.com/PyCQA/pylint
rev: v3.2.3
rev: v3.2.6
hooks:
- id: pylint
args: ["--disable=C,R,W,E1136"]
8 changes: 4 additions & 4 deletions datacube_ows/wcs1_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,10 @@ def get_tiff(req, data):
dst.write(data[band].values, idx)
dst.set_band_description(idx, req.layer.band_idx.band_label(band))
if cfg.wcs_tiff_statistics:
dst.update_tags(idx, STATISTICS_MINIMUM=data[band].values.min())
dst.update_tags(idx, STATISTICS_MAXIMUM=data[band].values.max())
dst.update_tags(idx, STATISTICS_MEAN=data[band].values.mean())
dst.update_tags(idx, STATISTICS_STDDEV=data[band].values.std())
dst.update_tags(idx, STATISTICS_MINIMUM=numpy.nanmin(data[band].values))
dst.update_tags(idx, STATISTICS_MAXIMUM=numpy.nanmax(data[band].values))
dst.update_tags(idx, STATISTICS_MEAN=numpy.nanmean(data[band].values))
dst.update_tags(idx, STATISTICS_STDDEV=numpy.nanstd(data[band].values))
return memfile.read()


Expand Down
9 changes: 5 additions & 4 deletions datacube_ows/wcs2_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import collections
import logging

import numpy
from dateutil.parser import parse
from odc.geo.geobox import GeoBox
from ows.wcs.v20 import ScaleAxis, ScaleExtent, ScaleSize, Slice, Trim
Expand Down Expand Up @@ -382,10 +383,10 @@ def get_tiff(request, data, crs, product, width, height, affine):
dst.write(data[band].values, idx)
dst.set_band_description(idx, product.band_idx.band_label(band))
if cfg.wcs_tiff_statistics:
dst.update_tags(idx, STATISTICS_MINIMUM=data[band].values.min())
dst.update_tags(idx, STATISTICS_MAXIMUM=data[band].values.max())
dst.update_tags(idx, STATISTICS_MEAN=data[band].values.mean())
dst.update_tags(idx, STATISTICS_STDDEV=data[band].values.std())
dst.update_tags(idx, STATISTICS_MINIMUM=numpy.nanmin(data[band].values))
dst.update_tags(idx, STATISTICS_MAXIMUM=numpy.nanmax(data[band].values))
dst.update_tags(idx, STATISTICS_MEAN=numpy.nanmean(data[band].values))
dst.update_tags(idx, STATISTICS_STDDEV=numpy.nanstd(data[band].values))
return memfile.read()


Expand Down

0 comments on commit 78648aa

Please sign in to comment.