Circuitscape / Circuitscape.jl

Algorithms from circuit theory to predict connectivity in heterogeneous landscapes
https://circuitscape.org
MIT License
128 stars 35 forks source link

InexactError: Int64 #257

Closed slamander closed 4 years ago

slamander commented 4 years ago

Hello,

I am running CS v 5.7.0 on windows with Julia (through R using JuliaCall::Julia_command()). I've had no problems with analyses in the past. However, lately I've been receiving this error during a pairwise analysis which I have successfully ran in the past.

Could anyone explain this error to me, and--if possible--provide suggestions for fixing it? I've pasted the error message, as well as supplied my .ini specifications below. If necessary I can provide my habitat and point location rasters.

Thanks in advance for your help!

-alex.

Error: Error happens in Julia.
InexactError: Int64(0.7021852)
Stacktrace:
 [1] Int64 at .\float.jl:710 [inlined]
 [2] convert at .\number.jl:7 [inlined]
 [3] setindex! at .\array.jl:847 [inlined]
 [4] _unsafe_copyto!(::Array{Int64,2}, ::Int64, ::Array{Float32,2}, ::Int64, ::Int64) at .\array.jl:257
 [5] unsafe_copyto! at .\array.jl:311 [inlined]
 [6] _copyto_impl! at .\array.jl:335 [inlined]
 [7] copyto! at .\array.jl:321 [inlined]
 [8] copyto! at .\array.jl:347 [inlined]
 [9] copyto_axcheck! at .\abstractarray.jl:946 [inlined]
 [10] Array{Int64,2}(::Array{Float32,2}) at .\array.jl:562
 [11] Array at .\boot.jl:431 [inlined]
 [12] convert(::Type{Array{Int64,N} where N}, ::Array{Float32,2}) at .\array.jl:554
 [13] read_raster(::String, ::Type{T} where T) at C:\Users\jbaecher\.julia\packages\Circuitscape\XdJRQ\src\io.jl:472
 [14] _grid_reader(::Type{T} where T, ::String) at C:\Users\jbaecher\.julia\packages\Circuitscape\XdJRQ\src\io.jl:93
 [15] read_polymap(::Type{T} where T, ::String, :

My .ini file:

[Options for advanced mode]
ground_file_is_resistances = False
source_file = (Browse for a current source file)
remove_src_or_gnd = keepall
ground_file = (Browse for a ground point file)
use_unit_currents = False
use_direct_grounds = False
[Calculation options]
low_memory_mode = False
solver = cg+amg
print_timings = False
[Options for pairwise and one-to-all and all-to-one modes]
included_pairs_file = C:/Users/jbaecher/Dropbox (UFL)/UF/Scheffers lab/Projects/transboundary_connectivity/include_files/AZE_ARM.txt
use_included_pairs = True
point_file = C:/Users/jbaecher/Dropbox (UFL)/UF/Scheffers lab/Projects/transboundary_connectivity/node_files/AZE_ARM.asc
[Output options]
write_cum_cur_map_only = True
log_transform_maps = False
output_file = C:/Users/jbaecher/Dropbox (UFL)/UF/Scheffers lab/Projects/transboundary_connectivity/output_files/AZE_ARM.out
write_max_cur_maps = False
write_volt_maps = False
set_null_currents_to_nodata = False
set_null_voltages_to_nodata = False
compress_grids = False
write_cur_maps = True
[Short circuit regions (aka polygons)]
use_polygons = False
polygon_file = None
[Connection scheme for raster habitat data]
connect_four_neighbors_only = True
connect_using_avg_resistances = True
[Habitat raster or graph]
habitat_file = C:/Users/jbaecher/Dropbox (UFL)/UF/Scheffers lab/Projects/transboundary_connectivity/raster_files/AZE_ARM.asc
habitat_map_is_resistances = True
[Options for one-to-all and all-to-one modes]
use_variable_source_strengths = False
variable_source_file = None
[Version]
version = unknown
[Mask file]
use_mask = False
mask_file = None
[Circuitscape mode]
data_type = raster
scenario = pairwise
parallelize = True
max_parallel = 2
vlandau commented 4 years ago

Hi Alex, we can work on figuring out what's going on here. It would be very helpful if you could share the input raster files. You can send them to vincent(at)csp-inc.org if you prefer not to post them publicly. A dropbox or google drive link will work fine..

ViralBShah commented 4 years ago

I wonder if the dropbox folders linked in the .ini file are publicly accessible.

Edit: obviously they are local paths.

vlandau commented 4 years ago

@ViralBShah seems that this is a problem with read_raster. I wrote that function so I will try to debug and get it patched today once I get the input files.

slamander commented 4 years ago

Hey, thanks for the quick response! Let me know if this link works: https://drive.google.com/drive/folders/1lgoPAOV5ZsfJB_EyngiHFdx2mgPmQ4n-?usp=sharing habitat file: "AZI_ARM.asc" point locations: "node_AZI_ARM.asc" I'm also uploaded my include file, in case you need it.

vlandau commented 4 years ago

Thanks @slamander, I'll check it out now! Link works fine.

vlandau commented 4 years ago

Looks like this is actually nothing to do with read_raster, I jumped the gun on that since it was in the stack trace and we've had bugs in it before.

@slamander it looks like the problem may be simple. It appears that you have non-integer numbers in your node file. That file must have only integers, no decimals. It looks like that file is also identical to the resistance surface, so maybe it was just a simple error early on in the workflow?

vlandau commented 4 years ago

Running a test now. I'll post back here once I confirm that the node file is in fact the issue.

ViralBShah commented 4 years ago

We should ideally add an input validation pass so that we can give an error to the user.

vlandau commented 4 years ago

We should ideally add an input validation pass so that we can give an error to the user.

Agreed. Should be easy enough to add that.

vlandau commented 4 years ago

Okay -- got things working by replacing the node file with a dummy file with three manually-defined nodes. It was the decimal values in the node file that was causing this issue. @slamander just in case you haven't seen it, you can find more info on how to create/format a node file in the docs, at https://circuitscape.org/docs under "Focal node location and data type".

Closing this issue now and I'll open a new one to add that error you suggested @ViralBShah

slamander commented 4 years ago

@vlandau Thank you very much for your rapid solution!

Best, -Alex.

vlandau commented 4 years ago

Happy to help! I'm glad we were able to resolve it for you. Don't hesitate to open another issue if you run into more problems.