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

GridMET Errors for "fmoist_100", "fmoist_1000", and "palmer" parameters #32

Closed
program-- opened this issue Apr 7, 2021 · 2 comments
Closed

Comments

@program--
Copy link
Contributor

Hi Mike! I was playing around with aggregating climate data via climateR and ran into some issues with the following parameters for GridMET:

  • fmoist_100
  • fmoist_1000
  • palmer

I don't know if these are known, but it looks like there are recurring issues with the palmer index due to the THREDDS server so feel free to ignore that one! Also, the fmoist_* parameters can be handled individually, since this looks to be an issue only with using them in combination.

> climateR::getGridMET(aoi, c("fmoist_100", "fmoist_1000"), "2012-01-01", "2013-01-01")
Error in `names<-`(`*tmp*`, value = unique(date.names)) : incorrect number of layer names

This seems to be an issue at this line, but I'm not 100% sure. This error is only thrown when trying to get both parameters at once, and isn't thrown when trying to retrieve each parameter individually.

> climateR::getGridMET(aoi, "palmer", "2021-01-01", "2021-02-01")
Error in var[[i]] * scale_factor : non-numeric argument to binary operator

This looks to be an issue at this line. I imagine it is related to #7 and #15, and that the var variable was given some urls values due to exception handling.

reprex

aoi1 <- AOI::aoi_get("UCSB")
aoi2 <- AOI::aoi_get("Colorado Springs")

# Doesn't Work
climateR::getGridMET(
    AOI       = aoi1,
    param     = "palmer",
    startDate = "2021-01-01",
    endDate   = "2021-02-01"
)
#> Error in var[[i]] * scale_factor: non-numeric argument to binary operator

# Doesn't Work
climateR::getGridMET(
    AOI       = aoi2,
    param     = "palmer",
    startDate = "2021-01-01",
    endDate   = "2021-02-01"
)
#> Error in var[[i]] * scale_factor: non-numeric argument to binary operator

Created on 2021-04-07 by the reprex package (v2.0.0)


aoi <- AOI::aoi_get("UCSB")

# Works
climateR::getGridMET(
    AOI       = aoi,
    param     = "fmoist_100",
    startDate = "2021-01-01",
    endDate   = "2021-02-01"
)
#> $fmoist_100
#> class      : RasterStack
#> dimensions : 2, 2, 4, 32  (nrow, ncol, ncell, nlayers)
#> resolution : 0.04166667, 0.04166667  (x, y)
#> extent     : -119.9125, -119.8292, 34.37917, 34.4625  (xmin, xmax, ymin, ymax)
#> crs        : +proj=longlat +datum=WGS84 +no_defs
#> names      : X2021.01.01, X2021.01.02, X2021.01.03, X2021.01.04, X2021.01.05, X2021.01.06, X2021.01.07, X2021.01.08, X2021.01.09, X2021.01.10, X2021.01.11, X2021.01.12, X2021.01.13, X2021.01.14, X2021.01.15, ...
#> min values :        16.6,        17.5,        18.1,        18.5,        19.9,        17.3,        14.8,        12.9,        12.4,        11.8,        11.0,        10.7,        11.4,        10.8,        10.0, ...
#> max values :        19.7,        19.7,        19.6,        19.6,        22.2,        21.3,        18.9,        17.0,        17.4,        17.3,        15.5,        15.5,        16.7,        14.9,        13.2, ...

# Works
climateR::getGridMET(
    AOI       = aoi,
    param     = "fmoist_1000",
    startDate = "2021-01-01",
    endDate   = "2021-02-01"
)
#> $fmoist_1000
#> class      : RasterStack
#> dimensions : 2, 2, 4, 32  (nrow, ncol, ncell, nlayers)
#> resolution : 0.04166667, 0.04166667  (x, y)
#> extent     : -119.9125, -119.8292, 34.37917, 34.4625  (xmin, xmax, ymin, ymax)
#> crs        : +proj=longlat +datum=WGS84 +no_defs
#> names      : X2021.01.01, X2021.01.02, X2021.01.03, X2021.01.04, X2021.01.05, X2021.01.06, X2021.01.07, X2021.01.08, X2021.01.09, X2021.01.10, X2021.01.11, X2021.01.12, X2021.01.13, X2021.01.14, X2021.01.15, ...
#> min values :        14.3,        14.6,        14.6,        14.6,        15.9,        15.9,        15.8,        15.6,        15.4,        15.0,        14.6,        14.1,        14.2,        14.1,        14.0, ...
#> max values :        20.1,        20.1,        19.9,        19.6,        20.9,        21.0,        20.8,        20.5,        20.5,        20.2,        19.7,        19.2,        19.3,        19.0,        18.7, ...

# Doesn't Work
climateR::getGridMET(
    AOI       = aoi,
    param     = c("fmoist_100", "fmoist_1000"),
    startDate = "2021-01-01",
    endDate   = "2021-02-01"
)
#> Error in `names<-`(`*tmp*`, value = unique(date.names)): incorrect number of layer names

Created on 2021-04-07 by the reprex package (v2.0.0)

@mikejohnson51
Copy link
Owner

Hi @program-- Awesome, thank you for this I think both errors should be fixed with the latest commit:

library(AOI)
library(climateR)

aoi1 <- AOI::aoi_get("UCSB")
aoi2 <- AOI::aoi_get("Colorado Springs")

# Doesn't Work
climateR::getGridMET(
  AOI       = aoi1,
  param     = "palmer",
  startDate = "2021-01-01",
  endDate   = "2021-02-01"
)
#> $palmer
#> class      : RasterStack 
#> dimensions : 2, 2, 4, 7  (nrow, ncol, ncell, nlayers)
#> resolution : 0.04166667, 0.04166667  (x, y)
#> extent     : -119.9125, -119.8292, 34.37917, 34.4625  (xmin, xmax, ymin, ymax)
#> crs        : +proj=longlat +datum=WGS84 +no_defs 
#> names      : X2021_pentad_1, X2021_pentad_2, X2021_pentad_3, X2021_pentad_4, X2021_pentad_5, X2021_pentad_6, X2021_pentad_7 
#> min values :          -2.48,          -2.46,          -2.43,          -2.43,          -2.38,          -2.36,          -2.34 
#> max values :          -2.25,          -2.26,          -2.26,          -2.28,          -2.26,          -2.26,          -2.23

# Doesn't Work
climateR::getGridMET(
  AOI       = aoi2,
  param     = "palmer",
  startDate = "2021-01-01",
  endDate   = "2021-02-01"
)
#> $palmer
#> class      : RasterStack 
#> dimensions : 8, 9, 72, 7  (nrow, ncol, ncell, nlayers)
#> resolution : 0.04166667, 0.04166667  (x, y)
#> extent     : -104.9542, -104.5792, 38.7125, 39.04583  (xmin, xmax, ymin, ymax)
#> crs        : +proj=longlat +datum=WGS84 +no_defs 
#> names      : X2021_pentad_1, X2021_pentad_2, X2021_pentad_3, X2021_pentad_4, X2021_pentad_5, X2021_pentad_6, X2021_pentad_7 
#> min values :          -5.21,          -5.21,          -5.20,          -5.17,          -5.16,          -5.13,          -5.11 
#> max values :          -2.75,          -2.71,          -2.66,          -2.59,          -2.53,          -2.48,          -2.43


aoi <- AOI::aoi_get("UCSB")

# Works
climateR::getGridMET(
  AOI       = aoi,
  param     = "fmoist_100",
  startDate = "2021-01-01",
  endDate   = "2021-02-01"
)
#> $fmoist_100
#> class      : RasterStack 
#> dimensions : 2, 2, 4, 32  (nrow, ncol, ncell, nlayers)
#> resolution : 0.04166667, 0.04166667  (x, y)
#> extent     : -119.9125, -119.8292, 34.37917, 34.4625  (xmin, xmax, ymin, ymax)
#> crs        : +proj=longlat +datum=WGS84 +no_defs 
#> names      : X2021.01.01, X2021.01.02, X2021.01.03, X2021.01.04, X2021.01.05, X2021.01.06, X2021.01.07, X2021.01.08, X2021.01.09, X2021.01.10, X2021.01.11, X2021.01.12, X2021.01.13, X2021.01.14, X2021.01.15, ... 
#> min values :        16.6,        17.5,        18.1,        18.5,        19.9,        17.3,        14.8,        12.9,        12.4,        11.8,        11.0,        10.7,        11.4,        10.8,        10.0, ... 
#> max values :        19.7,        19.7,        19.6,        19.6,        22.2,        21.3,        18.9,        17.0,        17.4,        17.3,        15.5,        15.5,        16.7,        14.9,        13.2, ...

# Works
climateR::getGridMET(
  AOI       = aoi,
  param     = "fmoist_1000",
  startDate = "2021-01-01",
  endDate   = "2021-02-01"
)
#> $fmoist_1000
#> class      : RasterStack 
#> dimensions : 2, 2, 4, 32  (nrow, ncol, ncell, nlayers)
#> resolution : 0.04166667, 0.04166667  (x, y)
#> extent     : -119.9125, -119.8292, 34.37917, 34.4625  (xmin, xmax, ymin, ymax)
#> crs        : +proj=longlat +datum=WGS84 +no_defs 
#> names      : X2021.01.01, X2021.01.02, X2021.01.03, X2021.01.04, X2021.01.05, X2021.01.06, X2021.01.07, X2021.01.08, X2021.01.09, X2021.01.10, X2021.01.11, X2021.01.12, X2021.01.13, X2021.01.14, X2021.01.15, ... 
#> min values :        14.3,        14.6,        14.6,        14.6,        15.9,        15.9,        15.8,        15.6,        15.4,        15.0,        14.6,        14.1,        14.2,        14.1,        14.0, ... 
#> max values :        20.1,        20.1,        19.9,        19.6,        20.9,        21.0,        20.8,        20.5,        20.5,        20.2,        19.7,        19.2,        19.3,        19.0,        18.7, ...

climateR::getGridMET(
  AOI       = aoi,
  param     = c("fmoist_100", "fmoist_1000"),
  startDate = "2021-01-01",
  endDate   = "2021-02-01"
)
#> $fmoist_100
#> class      : RasterStack 
#> dimensions : 2, 2, 4, 32  (nrow, ncol, ncell, nlayers)
#> resolution : 0.04166667, 0.04166667  (x, y)
#> extent     : -119.9125, -119.8292, 34.37917, 34.4625  (xmin, xmax, ymin, ymax)
#> crs        : +proj=longlat +datum=WGS84 +no_defs 
#> names      : X2021.01.01, X2021.01.02, X2021.01.03, X2021.01.04, X2021.01.05, X2021.01.06, X2021.01.07, X2021.01.08, X2021.01.09, X2021.01.10, X2021.01.11, X2021.01.12, X2021.01.13, X2021.01.14, X2021.01.15, ... 
#> min values :        16.6,        17.5,        18.1,        18.5,        19.9,        17.3,        14.8,        12.9,        12.4,        11.8,        11.0,        10.7,        11.4,        10.8,        10.0, ... 
#> max values :        19.7,        19.7,        19.6,        19.6,        22.2,        21.3,        18.9,        17.0,        17.4,        17.3,        15.5,        15.5,        16.7,        14.9,        13.2, ... 
#> 
#> 
#> $fmoist_1000
#> class      : RasterStack 
#> dimensions : 2, 2, 4, 32  (nrow, ncol, ncell, nlayers)
#> resolution : 0.04166667, 0.04166667  (x, y)
#> extent     : -119.9125, -119.8292, 34.37917, 34.4625  (xmin, xmax, ymin, ymax)
#> crs        : +proj=longlat +datum=WGS84 +no_defs 
#> names      : X2021.01.01, X2021.01.02, X2021.01.03, X2021.01.04, X2021.01.05, X2021.01.06, X2021.01.07, X2021.01.08, X2021.01.09, X2021.01.10, X2021.01.11, X2021.01.12, X2021.01.13, X2021.01.14, X2021.01.15, ... 
#> min values :        14.3,        14.6,        14.6,        14.6,        15.9,        15.9,        15.8,        15.6,        15.4,        15.0,        14.6,        14.1,        14.2,        14.1,        14.0, ... 
#> max values :        20.1,        20.1,        19.9,        19.6,        20.9,        21.0,        20.8,        20.5,        20.5,        20.2,        19.7,        19.2,        19.3,        19.0,        18.7, ...

Created on 2021-04-12 by the reprex package (v1.0.0)

@program--
Copy link
Contributor Author

Awesome @mikejohnson51! I'll go ahead and close this issue 😄

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