EcoJulia / NeutralLandscapes.jl

Generation of neutral landscapes in Julia.
https://ecojulia.github.io/NeutralLandscapes.jl/dev/
MIT License
16 stars 2 forks source link

`normalize` can't handle NaNs #61

Closed gottacatchenall closed 2 years ago

gottacatchenall commented 2 years ago

Describe the bug If you call normalize on an initial landscape with NaNs, some numbers get turned into nans

To Reproduce

using Plots
using SimpleSDMLayers
using Distributions

ENV["SDMLAYERS_PATH"] = "/home/michael/data/"
quebec = SimpleSDMPredictor(WorldClim, BioClim; left=-90., right=-55., top=60., bottom=45.)
qcmask = fill(true, size(quebec)) 
qcmask[findall(isnothing, quebec.grid)] .= false

init = rand(PerlinNoise((2,2)), size(quebec), mask=qcmask)

svu = SpatiotemporallyAutocorrelatedUpdater(
    rate = 0.01,
    variability = 0.01,
    spatialupdater = PlanarGradient(90)
)

seq = normalize(update(svu, init, 30))

Expected behavior Should leave NaNs in place but not convert numbers to NaNs

mkborregaard commented 2 years ago

Probably findmin and findmax? Consider replacing with NaNMath.min?

gottacatchenall commented 2 years ago

Probably findmin and findmax? Consider replacing with NaNMath.min?

Yes I think so, should be an easy fix

gottacatchenall commented 2 years ago

closed in #62