Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • CSIndicators CSIndicators
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Graph
    • Compare revisions
  • Issues 18
    • Issues 18
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 4
    • Merge requests 4
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Terraform modules
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Earth SciencesEarth Sciences
  • CSIndicatorsCSIndicators
  • Issues
  • #50
Closed
Open
Issue created Apr 02, 2024 by abatalla@abatallaMaintainer

Warnings in s2dv_cube() and error in CST_TotalTimeExceedingThreshold()

Hi,

While following the vignette, I have encountered an issue regarding the creation of s2dv_cube objects. I am connected to a WS using RStudio with R/4.1.2-foss-2015a-bare and having loaded CDO/1.9.8-foss-2015a. I am using the following R packages versions: CSTools_5.2.0, CSIndicators_1.1.1, s2dv_2.0.0, dplyr_1.1.4 and ggplot2.

On two occasions, the vignette asks you to create an s2dv_cube object. When I create them, the following warning messages appear:

For object out$hurs:

> # Relative humidity 
> 
> # Create a new s2dv object with relative humidity
> out$hurs <- s2dv_cube(data = 100 * (exp((17.625 * out$tdps$data) / (243.04 + out$tdps$data)) / 
+                                       exp((17.625 * out$tas$data) / (243.04 + out$tas$data))),
+                       lon = out$tas$lon,
+                       lat = out$tas$lat,
+                       Variable = list(varName = "rh", level = NULL),
+                       Dates = out$tas$Dates,
+                       Datasets = out$tas$Datasets,
+                       when = Sys.time(),
+                       source_files = "see source files of tas, tdps and pr")
Warning messages:
1: In s2dv_cube(data = 100 * (exp((17.625 * out$tdps$data)/(243.04 +  :
  Parameter 'Dates' is not provided so the metadata of 's2dv_cube' object will be incomplete.
2: In s2dv_cube(data = 100 * (exp((17.625 * out$tdps$data)/(243.04 +  :
  Parameter 'varName' is not provided so the metadata of 's2dv_cube' object will be incomplete.
3: In s2dv_cube(data = 100 * (exp((17.625 * out$tdps$data)/(243.04 +  :
  Parameter 'metadata' is not provided so the metadata of 's2dv_cube' object will be incomplete.

For object out$malariaSuit:

> # Create a new s2dv object with malaria suitability
> out$malariaSuit <- s2dv_cube(data = ifelse(out$tas$data >= 14.5 & 
+                                              out$tas$data <= 33 & 
+                                              out$hurs$data >= 60 & 
+                                              out$prlr$data >= 80, 1, 0),
+                              lon = out$tas$lon,
+                              lat = out$tas$lat,
+                              Variable = list(varName = "malar_suit", level = NULL),
+                              Dates = out$tas$Dates,
+                              Datasets = out$tas$Datasets,
+                              when = Sys.time(),
+                              source_files = "see source files of tas, tdps and pr")
Warning messages:
1: In s2dv_cube(data = ifelse(out$tas$data >= 14.5 & out$tas$data <=  :
  Parameter 'Dates' is not provided so the metadata of 's2dv_cube' object will be incomplete.
2: In s2dv_cube(data = ifelse(out$tas$data >= 14.5 & out$tas$data <=  :
  Parameter 'varName' is not provided so the metadata of 's2dv_cube' object will be incomplete.
3: In s2dv_cube(data = ifelse(out$tas$data >= 14.5 & out$tas$data <=  :
  Parameter 'metadata' is not provided so the metadata of 's2dv_cube' object will be incomplete.

Giving way to these errors:

Errors for object out$hurs:

> attr(out$hurs$Variable, "units") <- "%"
Error in attr(out$hurs$Variable, "units") <- "%" : 
  attempt to set an attribute on NULL
> attr(out$hurs$Variable, "longname") <- "near-surface relative humidity"
Error in attr(out$hurs$Variable, "longname") <- "near-surface relative humidity" : 
  attempt to set an attribute on NULL
> out$tas$Dates
NULL

Errors for object out$malariaSuit:

> attr(out$malariaSuit$Variable, "units") <- "none"
Error in attr(out$malariaSuit$Variable, "units") <- "none" : 
  attempt to set an attribute on NULL
> attr(out$malariaSuit$Variable, "longname") <- "suitability for malaria transmission"
Error in attr(out$malariaSuit$Variable, "longname") <- "suitability for malaria transmission" : 
  attempt to set an attribute on NULL
> out$tas$Dates
NULL

This leads to further errors when creating the malariaInd object with the function CST_TotalTimeExceedingThreshold().

> malariaInd <- CST_TotalTimeExceedingThreshold(out$malariaSuit,
+                                               op = ">=",
+                                               threshold = 1)
Error in TotalTimeExceedingThreshold(data = data$data, dates = Dates,  : 
  Parameter 'time_dim' is not found in 'data' dimension.
> 
> # Sneak peek of the data
> malariaInd$data[1, 1, 1, , ][15:20, 15:20]
Error: object 'malariaInd' not found

It seems that the s2dv_cube object is not being properly created and is missing metadata from the temporal dimension. @vagudets mentioned this might be a bug due to the vignette being created with an older version of CSTools/CSIndicators. Issue #25 (closed) warns of a compatibility break due to changes in s2dv_cube. It may be that the vignette has not been updated.

Thanks!

Assignee
Assign to
Time tracking