Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • ClimProjDiags ClimProjDiags
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 1
    • Issues 1
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 1
    • Merge requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Earth SciencesEarth Sciences
  • ClimProjDiagsClimProjDiags
  • Issues
  • #7
Closed
Open
Issue created Apr 21, 2022 by aho@ahoMaintainer

WeightedMean: wrong dlon calculation

This issue is identified by @bsolaraj . WeightedMean() takes the size of each grid into consideration when calculateing the weight, so the distance between each lon/lat point (dlon and dlat) are calculated (dlon <- abs(c(abs(lon[2 : nblon]) - abs(lon[1 : nblon - 1]))) * pi / 180, line 128.)

In the following example, the problem happens at lon = -0.5 and lon = 0.5. abs() makes dlon = 0 but the distance should be 1.

lon <- seq(-179.5,179.5,by=1)
nblon <- length(lon)
lon[lon > 180] = lon[lon > 180] - 360
dlon <- abs(c(abs(lon[2 : nblon]) - abs(lon[1 : nblon - 1]))) * pi / 180

dlon[180]
[1] 0    #SHOULD BE 1
lon[180:181]
[1] -0.5  0.5

The dlon calculation can be done by diff(lon) simply. @nperez do you see any potential problem if we make this change?

Cheers,
An-Chi

Assignee
Assign to
Time tracking