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

data has extra timesteps after applying bias correction? #81

Open
scbrown86 opened this issue Mar 12, 2021 · 0 comments
Open

data has extra timesteps after applying bias correction? #81

scbrown86 opened this issue Mar 12, 2021 · 0 comments

Comments

@scbrown86
Copy link

I've noticed that after applying a bias correction, that there are extra timesteps in the output?

My obs data looks like:

# read in the cmip6 data
cmip6 <- loadGridData("test_GBR_CMIP6.nc", var = "tos", years = 1985:2012)
# read in the ESA SST data
esa <- loadGridData("test_GBR_ESA.nc", var = "analysed_sst", years = 1985:2012)
esa$Dates$start <- cmip6$Dates$start
esa$Dates$end<- cmip6$Dates$end

identical(esa$Dates$start, cmip6$Dates$start)
[1] TRUE

attr(esa$Variable, "units") <- attr(cmip6$Variable, "units")
attr(esa$Variable, "longname") <- attr(cmip6$Variable, "longname")

> str(esa)
List of 4
 $ Variable:List of 2
  ..$ varName: chr "analysed_sst"
  ..$ level  : NULL
  ..- attr(*, "use_dictionary")= logi FALSE
  ..- attr(*, "description")= chr "analysed sea surface temperature"
  ..- attr(*, "units")= chr "degC"
  ..- attr(*, "longname")= chr "tos"
  ..- attr(*, "daily_agg_cellfun")= chr "none"
  ..- attr(*, "monthly_agg_cellfun")= chr "none"
  ..- attr(*, "verification_time")= chr "none"
 $ Data    : num [1:10220, 1:30, 1:30] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ...
  ..- attr(*, "dimensions")= chr [1:3] "time" "lat" "lon"
 $ xyCoords:List of 2
  ..$ x: num [1:30] 140 141 141 142 142 ...
  ..$ y: num [1:30] -24.8 -24.2 -23.8 -23.2 -22.8 ...
  ..- attr(*, "projection")= chr "LatLonProjection"
  ..- attr(*, "resX")= num 0.5
  ..- attr(*, "resY")= num 0.5
 $ Dates   :List of 2
  ..$ start: chr [1:10220] "1985-01-01 00:00:00 GMT" "1985-01-02 00:00:00 GMT" "1985-01-03 00:00:00 GMT" "1985-01-04 00:00:00 GMT" ...
  ..$ end  : chr [1:10220] "1985-01-01 00:00:00 GMT" "1985-01-02 00:00:00 GMT" "1985-01-03 00:00:00 GMT" "1985-01-04 00:00:00 GMT" ...
 - attr(*, "dataset")= chr "../Data/test_GBR_ESA.nc"
 - attr(*, "R_package_desc")= chr "loadeR-v1.7.0"
 - attr(*, "R_package_URL")= chr "https://github.com/SantanderMetGroup/loadeR"
 - attr(*, "R_package_ref")= chr "https://doi.org/10.1016/j.envsoft.2018.09.009"

My simulated data looks like this

> str(cmip6)
List of 4
 $ Variable:List of 2
  ..$ varName: chr "tos"
  ..$ level  : NULL
  ..- attr(*, "use_dictionary")= logi FALSE
  ..- attr(*, "description")= chr "Sea Surface Temperature"
  ..- attr(*, "units")= chr "degC"
  ..- attr(*, "longname")= chr "tos"
  ..- attr(*, "daily_agg_cellfun")= chr "none"
  ..- attr(*, "monthly_agg_cellfun")= chr "none"
  ..- attr(*, "verification_time")= chr "none"
 $ Data    : num [1:10220, 1:30, 1:30] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ...
  ..- attr(*, "dimensions")= chr [1:3] "time" "lat" "lon"
 $ xyCoords:List of 2
  ..$ x: num [1:30] 140 141 141 142 142 ...
  ..$ y: num [1:30] -24.8 -24.2 -23.8 -23.2 -22.8 ...
  ..- attr(*, "projection")= chr "LatLonProjection"
  ..- attr(*, "resX")= num 0.5
  ..- attr(*, "resY")= num 0.5
 $ Dates   :List of 2
  ..$ start: chr [1:10220] "1985-01-01 00:00:00 GMT" "1985-01-02 00:00:00 GMT" "1985-01-03 00:00:00 GMT" "1985-01-04 00:00:00 GMT" ...
  ..$ end  : chr [1:10220] "1985-01-01 00:00:00 GMT" "1985-01-02 00:00:00 GMT" "1985-01-03 00:00:00 GMT" "1985-01-04 00:00:00 GMT" ...
 - attr(*, "dataset")= chr "../Data/test_GBR_CMIP6.nc"
 - attr(*, "R_package_desc")= chr "loadeR-v1.7.0"
 - attr(*, "R_package_URL")= chr "https://github.com/SantanderMetGroup/loadeR"
 - attr(*, "R_package_ref")= chr "https://doi.org/10.1016/j.envsoft.2018.09.009"

However, after applying the bias correction, there are extra days in the output? The timezone has also changed to my local timezone?

> cmip6_qdm <- biasCorrection(y = esa, x = cmip6, method = "qdm")
Time difference of 1 days
Time difference of 1 days
Time difference of 1 days
[2021-03-12 14:24:24] Argument precipitation is set as FALSE, please ensure that this matches your data.
[2021-03-12 14:24:28] Number of windows considered: 1...
[2021-03-12 14:24:29] Bias-correcting 1 members separately...
[2021-03-12 14:25:07] Done.

> str(cmip6_qdm)
List of 4
 $ Variable:List of 2
  ..$ varName: chr "analysed_sst"
  ..$ level  : NULL
  ..- attr(*, "use_dictionary")= logi FALSE
  ..- attr(*, "description")= chr "analysed sea surface temperature"
  ..- attr(*, "units")= chr "degC"
  ..- attr(*, "longname")= chr "tos"
  ..- attr(*, "daily_agg_cellfun")= chr "none"
  ..- attr(*, "monthly_agg_cellfun")= chr "none"
  ..- attr(*, "verification_time")= chr "none"
  ..- attr(*, "subset")= chr "time"
  ..- attr(*, "time_subset")= chr "intersectGrid.time"
  ..- attr(*, "correction")= chr "qdm"
 $ Data    : num [1:10227, 1:30, 1:30] NA NA NA NA NA NA NA NA NA NA ...
  ..- attr(*, "dimensions")= chr [1:3] "time" "lat" "lon"
 $ xyCoords:List of 2
  ..$ x: num [1:30] 140 141 141 142 142 ...
  ..$ y: num [1:30] -24.8 -24.2 -23.8 -23.2 -22.8 ...
  ..- attr(*, "projection")= chr "LatLonProjection"
  ..- attr(*, "resX")= num 0.5
  ..- attr(*, "resY")= num 0.5
 $ Dates   :List of 2
  ..$ start: chr [1:10227] "1985-01-01 ACDT" "1985-01-02 ACDT" "1985-01-03 ACDT" "1985-01-04 ACDT" ...
  ..$ end  : chr [1:10227] "1985-01-01 ACDT" "1985-01-02 ACDT" "1985-01-03 ACDT" "1985-01-04 ACDT" ...
 - attr(*, "dataset")= chr "../Data/test_GBR_ESA.nc"
 - attr(*, "R_package_desc")= chr "loadeR-v1.7.0"
 - attr(*, "R_package_URL")= chr "https://github.com/SantanderMetGroup/loadeR"
 - attr(*, "R_package_ref")= chr "https://doi.org/10.1016/j.envsoft.2018.09.009"

The issue persists using other methods

> cmip6_eqm <- biasCorrection(y = esa, x = cmip6, method = "eqm")
> str(cmip6_eqm)
List of 4
 $ Variable:List of 2
  ..$ varName: chr "analysed_sst"
  ..$ level  : NULL
  ..- attr(*, "use_dictionary")= logi FALSE
  ..- attr(*, "description")= chr "analysed sea surface temperature"
  ..- attr(*, "units")= chr "degC"
  ..- attr(*, "longname")= chr "tos"
  ..- attr(*, "daily_agg_cellfun")= chr "none"
  ..- attr(*, "monthly_agg_cellfun")= chr "none"
  ..- attr(*, "verification_time")= chr "none"
  ..- attr(*, "subset")= chr "time"
  ..- attr(*, "time_subset")= chr "intersectGrid.time"
  ..- attr(*, "correction")= chr "eqm"
 $ Data    : num [1:10227, 1:30, 1:30] NA NA NA NA NA NA NA NA NA NA ...
  ..- attr(*, "dimensions")= chr [1:3] "time" "lat" "lon"
 $ xyCoords:List of 2
  ..$ x: num [1:30] 140 141 141 142 142 ...
  ..$ y: num [1:30] -24.8 -24.2 -23.8 -23.2 -22.8 ...
  ..- attr(*, "projection")= chr "LatLonProjection"
  ..- attr(*, "resX")= num 0.5
  ..- attr(*, "resY")= num 0.5
 $ Dates   :List of 2
  ..$ start: chr [1:10227] "1985-01-01 ACDT" "1985-01-02 ACDT" "1985-01-03 ACDT" "1985-01-04 ACDT" ...
  ..$ end  : chr [1:10227] "1985-01-01 ACDT" "1985-01-02 ACDT" "1985-01-03 ACDT" "1985-01-04 ACDT" ...
 - attr(*, "dataset")= chr "../Data/test_GBR_ESA.nc"
 - attr(*, "R_package_desc")= chr "loadeR-v1.7.0"
 - attr(*, "R_package_URL")= chr "https://github.com/SantanderMetGroup/loadeR"
 - attr(*, "R_package_ref")= chr "https://doi.org/10.1016/j.envsoft.2018.09.009"

> cmip6_scaling <- biasCorrection(y = esa, x = cmip6, method = "scaling", scaling.type = "additive")
Time difference of 1 days
Time difference of 1 days
Time difference of 1 days
[2021-03-12 14:51:01] Argument precipitation is set as FALSE, please ensure that this matches your data.
[2021-03-12 14:51:06] Number of windows considered: 1...
[2021-03-12 14:51:06] Bias-correcting 1 members separately...
[2021-03-12 14:51:12] Done.
> length(cmip6_scaling$Dates$start)
[1] 10227

Looking at the difference between the lengths of the date vectors, there should only be an additional 7 dates?

> length(cmip6$Dates$start)
[1] 10220
> length(cmip6_eqm$Dates$start)
[1] 10227

But, there are 30 duplicated dates in the output

> cmip6_eqm$Dates$start[duplicated(cmip6_eqm$Dates$start)]
 [1] "1985-03-03 ACDT" "1986-03-16 ACDT" "1987-03-15 ACDT" "1988-03-20 ACDT" "1989-03-19 ACDT" "1990-03-18 ACDT"
 [7] "1991-03-03 ACDT" "1992-03-22 ACDT" "1993-03-07 ACDT" "1994-03-20 ACDT" "1995-03-26 ACDT" "1996-03-31 ACDT"
[13] "1997-03-30 ACDT" "1998-03-29 ACDT" "1999-03-28 ACDT" "2000-03-26 ACDT" "2001-03-25 ACDT" "2002-03-31 ACDT"
[19] "2003-03-30 ACDT" "2004-03-28 ACDT" "2005-03-27 ACDT" "2006-04-02 ACDT" "2007-03-25 ACDT" "2008-04-06 ACDT"
[25] "2009-04-05 ACDT" "2010-04-04 ACDT" "2011-04-03 ACDT" "2012-04-01 ACDT"

The example files I'm using can be downloaded from here

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

1 participant