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

Fix indexing while reading source and ground files #378

Merged
merged 1 commit into from
Mar 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ function read_source_and_ground_maps(T, V, source_file, ground_file, habitatmeta
elseif filetype == FILE_TYPE_TXTLIST
rc = _txt_list_reader(ground_file, T, habitatmeta)
ground_map = -9999 * ones(T, habitatmeta.nrows, habitatmeta.ncols)
ground_map[V.(rc[:,2]), V.(rc[:,3])] = rc[:,1]
for (x,y,v) in zip(rc[:,2], rc[:,3], rc[:,1])
ground_map[V(x), V(y)] = v
end
else
throw(ErrorException("Cannot recognise file type."))
end
Expand All @@ -277,7 +279,9 @@ function read_source_and_ground_maps(T, V, source_file, ground_file, habitatmeta
elseif filetype == FILE_TYPE_TXTLIST
rc = _txt_list_reader(source_file, T, habitatmeta)
source_map = -9999 * ones(T, habitatmeta.nrows, habitatmeta.ncols)
source_map[V.(rc[:,2]), V.(rc[:,3])] = rc[:,1]
for (x,y,v) in zip(rc[:,2], rc[:,3], rc[:,1])
source_map[V(x), V(y)] = v
end
else
throw(ErrorException("Cannot recognize file type."))
end
Expand Down