Giter VIP home page Giter VIP logo

raster-tester's Introduction

raster-tester

PyPI Circle CI codecov.io

 _______________        _______________
|_|_|_|_|_|_|_|_|      |_|_|_|_|_|_|_|_|
|_|_|_|_|_|_|_|_| HIRU |_|_|_|_|_|_|_|_|
|_|_|_|_|_|_|_|_| DIFF |_|_|_|_|_|_|_|_|
|_|_|_|_|_|_|_|_| FROM |_|_|_|_|_|_|_|_|
|_|_|_|_|_|_|_|_| ===> |_|_|_|_|_|_|_|_|
|_|_|_|_|_|_|_|_|      |_|_|_|_|_|_|_|_|

raster-tester [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  compare
  crossesdateline
  isaligned
  isempty
  istiled

compare

Usage: raster-tester compare [OPTIONS] INPUT_1 INPUT_2

Options:
  -p, --pixel-threshold INTEGER  Threshold for pixel diffs [default=0]
  -d, --downsample INTEGER       Downsample via decimated read for faster
                                 comparison, and to handle variation in
                                 compression artifacts [default=1]
  -u, --upsample INTEGER         Upsample to handle variation in compression
                                 artifacts [default=1]
  --compare-masked               Only compare masks + unmasked areas of RGBA
                                 rasters
  --no-error                     Compare in non stderr mode: echos "(ok|not
                                 ok) - <input_1> is (within|not within)
                                 <pixel-threshold> pixels of <input 2>"
  --debug                        Print ascii preview of errors
  --flex-mode                    Allow comparison of masked RGB + RGBA
  --help                         Show this message and exit.

crossesdateline

Usage: raster-tester crossesdateline [OPTIONS] INPUT

Options:
  --help  Show this message and exit.

isaligned

Usage: raster-tester isaligned [OPTIONS] SOURCES...

Options:
  --help  Show this message and exit.

isempty

Usage: raster-tester isempty [OPTIONS] INPUT_1

Options:
  -b, --bidx INTEGER            Check one band
  --randomize                   Iterate through windows in a psuedorandom fashion
  --help                        Show this message and exit.

istiled

Usage: raster-tester istiled [OPTIONS] SOURCES...

Options:
  --blocksize / --no-blocksize  assert that sources are internally tiled
  --help                        Show this message and exit.

raster-tester's People

Contributors

dnomadb avatar jqtrde avatar perrygeo avatar vincentsarago avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

isabella232

raster-tester's Issues

test_4326_crossing fails

In the process of tweaking the code for Rasterio 1.0 and Python 3, I was hitting tests/test_dateline.py::test_4326_crossing FAILED

So reverted back to Python 2.7 and Rasterio 0.36, and I'm still hitting that same error locally and on travis CI.

_______________________________________________ test_4326_crossing ________________________________________________

    def test_4326_crossing():
        crs = {'init': 'epsg:4326'}

        boundsArr = densify(make_bounds_array(BoundingBox(170., 45., 190., 50.)))
        assert winding_order(boundsArr) == False

        transformedBounds = transform_bounds(boundsArr, crs)

>       assert winding_order(transformedBounds) == True
E       assert False == True
E        +  where False = winding_order(array([[ 170.  ,   45.  ],\n       [ 175.  ,   45.  ],\n       [ 180.  ,   45.  ...     [ 170.  ,   48.75],\n       [ 170.  ,   47.5 ],\n       [ 170.  ,   46.25]]))

tests/test_dateline.py:23: AssertionError

@dnomadb can you shed some light on what's being tested here and why it's no longer working as expected?

Additional commands for all pxm boolean

Right now pxm has bash scripts, python scripts, external python commands and bash functions to assert various things about raster data. All of these methods have slightly different modes of operation (some raise exceptions, some return a special value, some use exit codes, etc) and are not very easy to test.

I'd like to move all the boolean tests from pxm to subcommands of raster-tester. Basically anytime we need to ask a yes/no question about a raster or set of rasters, this command should be the place to go.

So far we have

  • compare
  • isempty

But we could pull in

  • aligned
  • crosses-dateline
  • is_evil
  • is_lossy
  • validate

This would also give us an opportunity to define and standardize exactly what a Yes/No response should look like and how the bash scripts should handle them

  • exit codes
  • what gets output to stdout/stderr

difference in pixel counts between GDAL versions

When using GDAL 2.1, we get pixel counts that differ enough to cause some tests to fail:

_______________________________________________ test_cli_okcompare ________________________________________________

    def test_cli_okcompare():
        runner = CliRunner()
        result = runner.invoke(cli, ['compare', 'tests/expected/blobby.tif', 'tests/fixtures/notblobby.tif', '--upsample', '8', '--compare-masked', '--downsample', '64'])
>       assert result.exit_code == 0
E       assert -1 == 0
E        +  where -1 = <Result ValueError('Mask has 2 pixels that vary by more than 16',)>.exit_code

tests/test_cli.py:40: AssertionError
_________________________________________ test_cli_okcompare_bad_no_error _________________________________________

    def test_cli_okcompare_bad_no_error():
        runner = CliRunner()
        result = runner.invoke(cli, ['compare', 'tests/expected/blobby.tif', 'tests/fixtures/notblobby.tif', '--upsample', '8', '--downsample', '64', '--no-error'])
        assert result.exit_code == 0
>       assert result.output == 'not ok - Band 1 has 363 pixels that vary by more than 16\n'
E       assert 'not ok - Ban...ore than 16\n' == 'not ok - Band...ore than 16\n'
E         - not ok - Band 1 has 436 pixels that vary by more than 16
E         ?                     -
E         + not ok - Band 1 has 363 pixels that vary by more than 16
E         ?                       +

tests/test_cli.py:53: AssertionError
_____________________________________________ test_cli_okcompare_rgb ______________________________________________

    def test_cli_okcompare_rgb():
        runner = CliRunner()
        result = runner.invoke(cli, ['compare', 'tests/expected/blobby_rgb.tif', 'tests/fixtures/notblobby_rgb.tif', '--upsample', '8', '--compare-masked', '--downsample', '64', '--flex-mode'])
>       assert result.exit_code == 0
E       assert -1 == 0
E        +  where -1 = <Result ValueError('Band 1 has 128 pixels that vary by more than 16',)>.exit_code

tests/test_cli.py:59: AssertionError
___________________________________________ test_cli_okcompare_rgb_rev ____________________________________________

    def test_cli_okcompare_rgb_rev():
        runner = CliRunner()
        result = runner.invoke(cli, ['compare', 'tests/fixtures/notblobby_rgb.tif', 'tests/expected/blobby_rgb.tif', '--upsample', '8', '--compare-masked', '--downsample', '64', '--flex-mode'])
>       assert result.exit_code == 0
E       assert -1 == 0
E        +  where -1 = <Result ValueError('Band 1 has 128 pixels that vary by more than 16',)>.exit_code

tests/test_cli.py:65: AssertionError

None of these failures occur when using GDAL 1.11. This is the first GDAL 2 regression I've seen but I guess it had to happen sometime.

cc @dnomadb @sgillies

I haven't dug into the reason behind the differences - perhaps some difference in the way the upsampling is performed in GDAL 2? In any case, we'll want to make raster-tester robust under both GDAL versions.

segfault when using --compare-masked

This might be a packaging issue with rasterio wheels on OSX but it only affects this repo so ticketing here...

When install raster-tester locally with the rasterio==0.36 wheels, the tests segfault

tests/test_cli.py::test_cli_okcompare Segmentation fault: 11

Specifically, this command segfaults

$ raster-tester compare tests/expected/blobby.tif tests/fixtures/notblobby.tif --upsample 8 --compare-masked --downsample 64
Segmentation fault: 11

But this command works fine (dropping the --compare-masked)

$ raster-tester compare tests/expected/blobby.tif tests/fixtures/notblobby.tif --upsample 8 --downsample 64
...

If I install rasterio from source ($ pip uninstall -y rasterio && pip install --no-binary :all: rasterio) the segfault no longer occurs. Nor does it occur on local linux containers or the circleci box.

I haven't dug into why the --compare-mask flag would trigger this yet. ๐Ÿ˜• Any ideas @sgillies ?

python 3 and rasterio 1.0 compatibility

currently raster_tester doesn't run on python 3 or against rasterio 1.0 - need to investigate why and fix things, preferably in a backwards-compatible way.

Tolerance for bounds comparison

Running pxm tests and there is some floating point drift causing failures with this error

File "/Users/mperry/venv/lib/python2.7/site-packages/raster_tester/utils.py", line 11, in exception_raiser
    raise ValueError(message)
ValueError: [{'bounds': {
'src2': BoundingBox(left=15419488.8419, bottom=-4109254.64063, right=15458624.6004, top=-4070118.8821299993),
'src1': BoundingBox(left=15419488.8419, bottom=-4109254.6406300003, right=15458624.6004, top=-4070118.88213)}
}]

One potential solution: modify compare_properties to do more lenient comparisons w/in a tolerance when a and b are floats
/cc @dnomadb

coverage is broken

Switching to tox for multi-python testing has broken pytest-coverage

Coverage.py warning: No data was collected.

segfault on downsample read of band 4 with GDAL 2

See rasterio/rasterio#679 (comment)

problem: If you have a 4-band RGBA tiff with JPEG compression, doing a downsample read on band 4 causes a segfault.

solution:
don't read band 4 with downsampling, use a different GDAL version, or use config vars in your rasterio env

GTIFF_IMPLICIT_JPEG_OVR=NO

The GDAL version 2.0.0 through 2.0.2 and 2.1.0 are affected. GDAL 1.X, 2.1.1 and 2.0.3 will be ๐Ÿ‘Œ So the risk is pretty minimal. @dnomadb you can close this whenevs, mostly just a PSA

Modify "not ok" behavior

The purpose of raster-tester is to ask yes/no questions about raster data. If the answer is no, that's not an exception, it's just one of the possible expected outcomes. We should specify this behavior in more detail to standardize it.

The following is just a proposal, would love to get feedback/discussion before we start implementing.

If the answer to the question is no:

  • the function should return a tuple with boolean and a message like (False, "These rasters are bad and they should feel bad")
  • the click command should print the message (to stderr or stdout?), along with the rasters that were being evaluated, not ok: a.tif vs b.tif (These rasters are bad and they should feel bad)
  • the click command should exit with code 1

If the answer to the question is yes:

  • the function should return a tuple with boolean and a message like (True, "These rasters are perfect in every way")
  • the click command should print the message to stdout, along with the rasters that were being evaluated, ok: a.tif vs b.tif (These rasters are perfect in every way)
  • the click command should exit with code 0

cc @sgillies @dnomadb

Make repo public

It's already on pypi: https://pypi.python.org/pypi/raster-tester

Any reason we shouldn't make it public?

The only one I can think of is that we have references to pxm and other proprietary stuff in the issues and comments. Maybe we can rename it, make it a rio plugin, clean it up a bit and put in a fresh repo?

Test for upload issues

Ultimately we want something hooked into the upload process that will check for red flags and report meaningful errors to the user.

As a first step, we could add a command to this repo which checked for:

  • projection
  • tiling
  • format
  • compression
  • nodata/alpha issues
  • ???

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.