-
Notifications
You must be signed in to change notification settings - Fork 34
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
rain imputation in micro_global errors where months have no rain days #22
Comments
OK fixed it by just putting a check for NA after the rainfall vector has been constructed and setting NA to zero.
From: Nick Golding ***@***.***>
Sent: Friday, August 18, 2023 2:44 PM
To: mrke/NicheMapR ***@***.***>
Cc: Subscribed ***@***.***>
Subject: [mrke/NicheMapR] rain imputation in micro_global errors where months have no rain days (Issue #22)
I'm running some microclimate models for dry places, and some spots have no rainy days in some months in the micro_global() source data. Niamey, Niger is one example. This leads to divide-by-zeros putting NAs in the rainfall data, when used with daily predictions and rainfrac=0, and then the fortran bit errors:
library(NicheMapR)
micro <- micro_global(
loc = c(2.0840132, 13.5127664),
timeinterval = 365,
rainfrac = 0
)
#> If program is crashing, try run.gads = 2.
#> extracting climate data
#> extracting soil moisture data
#> running microclimate model for 365 days by 1 years at site long 2.0840132 lat 13.5127664
#> Note: the output column `SOLR` in metout and shadmet is for unshaded horizontal plane solar radiation
#> Error in microclimate(micro): NA/NaN/Inf in foreign function call (arg 24)
Created on 2023-08-18 with reprex v2.0.2<https://reprex.tidyverse.org>
The offending lines are here (but possibly duplicated in other parts of the package?), and could be patched with some error handling
https://github.com/mrke/NicheMapR/blob/329eb11495b6f89cee8cda4bab4eb56e147c0313/R/micro_global.R#L915-L919
—
Reply to this email directly, view it on GitHub<#22>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AB7IUPBJYPGUKAIZXZL3PCDXV3XKNANCNFSM6AAAAAA3U7P734>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.******@***.***>>
|
Awesome! So speedy, thanks Mike! |
Actually, I'm getting another related error now, where it's infilling Inf for the divide by 0. Previously it was 0 rainfall over 0 rainy days ( Line 933 in f3ed05e
to: RAINFALL[!is.finite(RAINFALL)] <- 0
That makes the asumption that RAINYDAYS is correctly zero and RAINFALL is erroneously nonzero for these months. |
reprex on new coords for completeness: library(NicheMapR)
micro <- micro_global(
loc = c(73.0, 22.9),
timeinterval = 365,
rainfrac = 0
)
#> If program is crashing, try run.gads = 2.
#> extracting climate data
#> extracting soil moisture data
#> running microclimate model for 365 days by 1 years at site long 73 lat 22.9
#> Note: the output column `SOLR` in metout and shadmet is for unshaded horizontal plane solar radiation
#> Error in microclimate(micro): NA/NaN/Inf in foreign function call (arg 24) Created on 2023-08-18 with reprex v2.0.2 |
Great and thanks for the new lingo – ‘reprex’!
From: Nick Golding ***@***.***>
Sent: Friday, August 18, 2023 4:04 PM
To: mrke/NicheMapR ***@***.***>
Cc: Michael Kearney ***@***.***>; Comment ***@***.***>
Subject: Re: [mrke/NicheMapR] rain imputation in micro_global errors where months have no rain days (Issue #22)
reprex on new coords for completeness:
library(NicheMapR)
micro <- micro_global(
loc = c(73.0, 22.9),
timeinterval = 365,
rainfrac = 0
)
#> If program is crashing, try run.gads = 2.
#> extracting climate data
#> extracting soil moisture data
#> running microclimate model for 365 days by 1 years at site long 73 lat 22.9
#> Note: the output column `SOLR` in metout and shadmet is for unshaded horizontal plane solar radiation
#> Error in microclimate(micro): NA/NaN/Inf in foreign function call (arg 24)
Created on 2023-08-18 with reprex v2.0.2<https://reprex.tidyverse.org>
—
Reply to this email directly, view it on GitHub<#22 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AB7IUPEK3LYPVGTJMRITKQLXV4AVRANCNFSM6AAAAAA3U7P734>.
You are receiving this because you commented.Message ID: ***@***.******@***.***>>
|
I'm running some microclimate models for dry places, and some spots have no rainy days in some months in the micro_global() source data. Niamey, Niger is one example. This leads to divide-by-zeros putting NAs in the rainfall data, when used with daily predictions and
rainfrac=0
, and then the fortran bit errors:Created on 2023-08-18 with reprex v2.0.2
The offending lines are here (but possibly duplicated in other parts of the package?), and could be patched with some error handling
NicheMapR/R/micro_global.R
Lines 915 to 919 in 329eb11
The text was updated successfully, but these errors were encountered: