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

calendaryear=T in season_mov results in errors in curvefits #17

Open
andreattad opened this issue Oct 24, 2024 · 2 comments
Open

calendaryear=T in season_mov results in errors in curvefits #17

andreattad opened this issue Oct 24, 2024 · 2 comments

Comments

@andreattad
Copy link

Dear Mr. Kong,
thank you for your effort in developing the package.
I have a study case in temperate forest whit 1 season per year and I'm struggling in understanding how to force the season_mov.
I will use your modis example to show you the issue.

When I set the calendarYear option to FALSE in season_mov(), then curvefits() works,

image

But when I set the calendarYear option to TRUE in season_mov() I get an error in curvefits()

image

Is this a bug or am I doing something wrong?
Best regards
Davide Andreatta

@kongdd
Copy link
Member

kongdd commented Nov 5, 2024

Hi Davide, Could you provide a reproducible script, other than picture, which is hard to debug.

@andreattad
Copy link
Author

Dear Kong,
Thank you for your answer.
The example code is the one you provide about modis.
I copy the code here. Since in my study I have only one growing season, I specified calendarYear=T in the season_mov function.

Bests
Davide

library(phenofit)
library(data.table)
library(dplyr)
library(ggplot2)

d = MOD13A1$dt %>% subset(site == "CA-NS6" & date >= "2010-01-01" & date <= "2016-12-31") %>%
  .[, .(date, y = EVI/1e4, DayOfYear, QC = SummaryQA)]
d %<>% mutate(t = getRealDate(date, DayOfYear)) %>%
  cbind(d[, as.list(qc_summary(QC, wmin = 0.2, wmid = 0.5, wmax = 0.8))]) %>%
  .[, .(date, t, y, QC_flag, w)]
print(d)

lambda         <- 8
nptperyear     <- 23
minExtendMonth <- 0.5
maxExtendMonth <- 1
minPercValid   <- 0
wFUN           <- wTSM # wBisquare
wmin           <- 0.2
methods_fine <- c("AG", "Zhang", "Beck", "Elmore", "Gu")


INPUT <- check_input(d$t, d$y, d$w,
                     QC_flag = d$QC_flag,
                     nptperyear = nptperyear,
                     maxgap = nptperyear / 4, wmin = 0.2
)

brks <- season_mov(INPUT,
                   list(FUN = "smooth_wWHIT", wFUN = wFUN,
                        maxExtendMonth = 3,
                        wmin = wmin, r_min = 0.1,
                        calendarYear=T
                   ))
plot_season(INPUT, brks)


brks$dt

## 2.4 Curve fitting
fit <- curvefits(INPUT, brks,
                 list(
                   methods = methods_fine, # ,"klos",, 'Gu'
                   wFUN = wFUN,
                   iters = 2,
                   wmin = wmin,
                   nextend = 2,
                   maxExtendMonth = maxExtendMonth, minExtendMonth = minExtendMonth,
                   minPercValid = minPercValid
                 ))
                 ```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants