Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InexactError while parsing nodata values #239

Closed
VLucet opened this issue Jun 9, 2020 · 9 comments · Fixed by #240
Closed

InexactError while parsing nodata values #239

VLucet opened this issue Jun 9, 2020 · 9 comments · Fixed by #240

Comments

@VLucet
Copy link
Contributor

VLucet commented Jun 9, 2020

I am running Julia 1.3.1 and circuitscape dev (adding my project and manifest file along with the ini and raster files).
The patches file only contains 1 pair. I will also add that the rasters were generated with GRASS GIS 7.6.

The ini file, the rasters and the toml files:
https://drive.google.com/drive/folders/1X_JmaWdS5OHvdNzyEcvv19VybhuMv74Z?usp=sharing

The error is:

julia> compute("sce_38_it_1_ts_0_BLBR_with_buffer_EW.ini")
[ Info: 2020-06-09 12:52:36 : Precision used: Double
[ Info: 2020-06-09 12:52:43 : Reading maps
ERROR: InexactError: UInt8(-1.0e10)
Stacktrace:
 [1] UInt8 at ./float.jl:688 [inlined]
 [2] convert(::Type{UInt8}, ::Float64) at ./number.jl:7
 [3] read_raster(::String, ::Type) at /opt/julia/dev/Circuitscape/src/io.jl:455
 [4] _grid_reader(::Type, ::String) at /opt/julia/dev/Circuitscape/src/io.jl:93
 [5] read_cellmap(::String, ::Bool, ::Type{Float64}) at /opt/julia/dev/Circuitscape/src/io.jl:70
 [6] load_raster_data(::Type, ::Type, ::Dict{String,String}) at /opt/julia/dev/Circuitscape/src/io.jl:384
 [7] raster_pairwise(::Type, ::Type, ::Dict{String,String}) at /opt/julia/dev/Circuitscape/src/raster/pairwise.jl:18
 [8] _compute(::Type, ::Type, ::Dict{String,String}) at /opt/julia/dev/Circuitscape/src/run.jl:42
 [9] macro expansion at ./util.jl:212 [inlined]
 [10] compute(::String) at /opt/julia/dev/Circuitscape/src/run.jl:31
 [11] top-level scope at REPL[17]:1
@vlandau
Copy link
Member

vlandau commented Jun 9, 2020

I know what's going on here. Basically -9999 isn't supported by UInt8 (and many other Int types), so I need to convert Integer rasters to something like Int64 right away. Will have this fixed today.

@VLucet
Copy link
Contributor Author

VLucet commented Jun 9, 2020

@vlandau thanks for your explanation. Does that mean it would work if the values in the input rasters were not integer but float?

@vlandau
Copy link
Member

vlandau commented Jun 9, 2020

Yep! If you need it to work immediately it should be fine if you convert your input rasters to Float32 for now.

@VLucet
Copy link
Contributor Author

VLucet commented Jun 9, 2020

Not that much in a rush - was just eager to understand. Thanks again.

@vlandau
Copy link
Member

vlandau commented Jun 9, 2020

The pull request linked above should fix it. Tests take about 30 minutes to complete, and once they do, I'll merge with master and you should be good to go. Thanks for testing out the new .tif reading capabilities and discovering this issue!

@ViralBShah
Copy link
Member

Should we make a new release?

@vlandau
Copy link
Member

vlandau commented Jun 9, 2020

It looks like we haven't released a version with tif reading at all yet, so anyone installing from the Julia registry won't face this bug (but also won't have tif reading supported). @ranjanan and I were talking about doing a new minor release though.

@VLucet
Copy link
Contributor Author

VLucet commented Jun 9, 2020

BTW, i've installed from your latest commit on your PR and it works fine now. I believe this can be closed.

@vlandau
Copy link
Member

vlandau commented Jun 9, 2020

I'm going to wait to close until I finalize the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants