Circuitscape / Circuitscape.jl

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

Cannot 'convert' an object of type SubString{String} to an object of type Float64 #146

Closed dlecourstessier closed 5 years ago

dlecourstessier commented 6 years ago

Hi !

Fist of all, sorry if I do some spelling of grammatical mistakes, English is not my first language. Second of all, I am a new beginner with Circuitscape on Julia and it seems that I have some issue with the convertion of some files.

I want to do a current map, in advanced mode with 8 neighbours. I am currently working on Linux, so I created the initiation file on a Windows computer and I modified the file thereafter.

However, when I run my script, I get the following error : ERROR: LoadError: MethodError: Cannot convert an object of type SubString{String} to an object of type Float64 This may have arisen from a call to the constructor Float64(...), since type constructors fall back to convert methods.

The problem is that when I check the properties of the file in the system it is defined as text, when I check with gdalinfo in the terminal it is defined as Float32 and when I check it in Qgis, it is defined as Float64.

Does anyone have an idea of what is happening or what can I do to get my script to run properly ? Thank you very much !

richardurs commented 6 years ago

I'm was running in the same error with rasters as .txt files. Converting my rasters to .asc Format solved the error.

ranjanan commented 6 years ago

@dlecourstessier no problem, would you mind sharing a small example uploaded to a Google Drive or Dropbox link? That would help me test and fix this.

ranjanan commented 6 years ago

@richardurs you are welcome to as well. :-)

dlecourstessier commented 6 years ago

Hi everyone !

Thanks for your answers ! I already use raster in .asc format, which is why I don't understand the issue.

The google document is the code I use in Julia to start the analyse with Circuitscape, and I have put the initiation file as well.

https://docs.google.com/document/d/1fNczuvy-pEzCgsk0EtzqbMrEx_a9LFjVpHstjXwgrVs/edit?usp=sharing

Note that I do the analyse on the Compute Canada Cedar system, as my raster are too big for my own computer.... I don't think this changes everything, but just in case...

Once again, thank you for your time !

Daphnée

dlecourstessier commented 6 years ago

This is my initation files ! Hope it does help you, to help me.. !


[Options for advanced mode] ground_file_is_resistances = True remove_src_or_gnd = keepall ground_file = /home/dlt1/scratch/Nord.asc use_unit_currents = False source_file = /home/dlt1/scratch/Sud.asc use_direct_grounds = False

[Mask file] mask_file = None use_mask = False

[Calculation options] low_memory_mode = True parallelize = True solver = cg+amg print_timings = False preemptive_memory_release = False print_rusages = False *max_parallel = 16

[Short circuit regions (aka polygons)] *polygon_file = none use_polygons = False

[Options for one-to-all and all-to-one modes] use_variable_source_strengths = False *variable_source_file = None

[Output options] set_null_currents_to_nodata = False set_focal_node_currents_to_zero = False set_null_voltages_to_nodata = False *compress_grids = True write_cur_maps = 1 write_volt_maps = 1 output_file = /home/dlt1/scratch/Connectivite_LG.asc write_cum_cur_map_only = False log_transform_maps = False write_max_cur_maps = False

[Version] version = 4.0.5

[Options for reclassification of habitat data] *reclass_file = None use_reclass_table = False

[Logging Options] log_level = DEBUG log_file = /home/dlt1/scratch/connectiviteTotal.log profiler_log_file = None screenprint_log = False

[Options for pairwise and one-to-all and all-to-one modes] included_pairs_file = None use_included_pairs = False point_file = None

[Connection scheme for raster habitat data] connect_using_avg_resistances = True connect_four_neighbors_only = False

[Habitat raster or graph] habitat_map_is_resistances = True habitat_file = /home/dlt1/scratch/Resistance_LG.asc

[Circuitscape mode] data_type = raster scenario = advanced


Do you guys, see any errors ?

Thanks a lot !

eddiemyers commented 5 years ago

I'm running into the same error as above. When I try running Circuitscape, I get the following:

ERROR: MethodError: Cannot convert an object of type SubString{String} to an object of type Float64 This may have arisen from a call to the constructor Float64(...), since type constructors fall back to convert methods.

Was this ever resolved? Thanks!

ranjanan commented 5 years ago

@eddiemyers which version of Julia are you using? could you upload a simple example to a Google Drive link so I can look into it?

ViralBShah commented 5 years ago

Good to have which Circuitscape version this is on, and if not the latest, try with the latest release.

dlecourstessier commented 5 years ago

On my side, I have found that I had some issues with the format of some files that haven’t successfully convert to ASC format and that my resistance file was to heavy to run.

I changed the resolution of the map and arranged the format and then, everything worked!

I hope it help a bit!

Daphnee

Le 3 janv. 2019 à 19:02, Viral B. Shah notifications@github.com<mailto:notifications@github.com> a écrit :

Good to have which Circuitscape version this is on, and if not the latest, try with the latest release.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Circuitscape/Circuitscape.jl/issues/146#issuecomment-451317276, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AWPOSFf2cm5_wY8XyLO7nNuJ8yb4jHbFks5u_poogaJpZM4WT8qB.

eddiemyers commented 5 years ago

I updated both Julia (I now have Version 1.0.3) and Circuitscape (v5.4.0), and I now get this error message: ERROR: UndefVarError: DefaultFormatter not defined Stacktrace: [1] update_logging!(::Dict{String,String}) at /Users/edmyers/.julia/packages/Circuitscape/coCa3/src/logging.jl:23 [2] compute(::String) at /Users/edmyers/.julia/packages/Circuitscape/coCa3/src/run.jl:16 [3] top-level scope at none:0

The files I am working with are here https://drive.google.com/open?id=1D1IWjPRJXKPFuk56AL9ZJxPKVpSPTaAl

Thanks!

ranjanan commented 5 years ago

@eddiemyers can you try doing ]add Circuitscape#master and checking if the error persists?

eddiemyers commented 5 years ago

I added the above and although the Pkg.test works fine, I get an new error:

[ Info: 2019-01-10 11:45:22 : Precision used: Double [ Info: 2019-01-10 11:45:26 : Reading maps ERROR: MethodError: no method matching Float64(::SubString{String}) Closest candidates are: Float64(::Int8) at float.jl:60 Float64(::Int16) at float.jl:60 Float64(::Int32) at float.jl:60 ... Stacktrace: [1] iterate at ./generator.jl:47 [inlined] [2] collect_to!(::Array{Float64,2}, ::Base.Generator{Array{Any,2},Type{Float64}}, ::Int64, ::Int64) at ./array.jl:656 [3] collect_to_with_first!(::Array{Float64,2}, ::Float64, ::Base.Generator{Array{Any,2},Type{Float64}}, ::Int64) at ./array.jl:643 [4] _collect(::Array{Any,2}, ::Base.Generator{Array{Any,2},Type{Float64}}, ::Base.EltypeUnknown, ::Base.HasShape{2}) at ./array.jl:637 [5] collect_similar(::Array{Any,2}, ::Base.Generator{Array{Any,2},Type{Float64}}) at ./array.jl:561 [6] map(::Type, ::Array{Any,2}) at ./abstractarray.jl:1987 [7] _ascii_grid_reader(::Type, ::String) at /Users/edmyers/.julia/packages/Circuitscape/4wOUs/src/io.jl:102 [8] read_cellmap(::String, ::Bool, ::Type{Float64}) at /Users/edmyers/.julia/packages/Circuitscape/4wOUs/src/io.jl:68 [9] load_raster_data(::Type, ::Type, ::Dict{String,String}) at /Users/edmyers/.julia/packages/Circuitscape/4wOUs/src/io.jl:377 [10] raster_pairwise(::Type, ::Type, ::Dict{String,String}) at /Users/edmyers/.julia/packages/Circuitscape/4wOUs/src/raster/pairwise.jl:18 [11] _compute(::Type, ::Type, ::Dict{String,String}) at /Users/edmyers/.julia/packages/Circuitscape/4wOUs/src/run.jl:41 [12] macro expansion at ./util.jl:213 [inlined] [13] compute(::String) at /Users/edmyers/.julia/packages/Circuitscape/4wOUs/src/run.jl:30 [14] top-level scope at none:0

Any thoughts?

ranjanan commented 5 years ago

I see. Could you link me to your project files so I can take a look?

eddiemyers commented 5 years ago

Yep, here they are: https://drive.google.com/open?id=18MzghO-N1PZfz8HXnG06lf0xLyYW5yJz

I appreciate your help!

ranjanan commented 5 years ago

@eddiemyers In your ascii file there are strange values like "0.00.99". These are definitely error-prone files and even the previous version did not read them. I think I can put a more helpful error message out though.