{"id":13736113,"url":"https://github.com/MBalthasar/rHarmonics","last_synced_at":"2025-05-08T12:32:19.510Z","repository":{"id":215749523,"uuid":"256769269","full_name":"MBalthasar/rHarmonics","owner":"MBalthasar","description":"R package for harmonic modelling of time-series data","archived":false,"fork":false,"pushed_at":"2020-08-21T12:46:43.000Z","size":22821,"stargazers_count":30,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-04T03:05:49.075Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MBalthasar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-04-18T14:08:30.000Z","updated_at":"2024-06-01T10:38:35.000Z","dependencies_parsed_at":"2024-01-06T10:23:12.407Z","dependency_job_id":null,"html_url":"https://github.com/MBalthasar/rHarmonics","commit_stats":null,"previous_names":["mbalthasar/rharmonics"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MBalthasar%2FrHarmonics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MBalthasar%2FrHarmonics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MBalthasar%2FrHarmonics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MBalthasar%2FrHarmonics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MBalthasar","download_url":"https://codeload.github.com/MBalthasar/rHarmonics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224732131,"owners_count":17360416,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T03:01:15.900Z","updated_at":"2025-05-08T12:32:19.500Z","avatar_url":"https://github.com/MBalthasar.png","language":"R","funding_links":[],"categories":["Resources for `R`","R"],"sub_categories":["Testing your code"],"readme":"# rHarmonics\n[![DOI](https://zenodo.org/badge/256769269.svg)](https://zenodo.org/badge/latestdoi/256769269)\n\nR package for harmonic modelling of time-series data.\n\n\u003cimg src=\"images/NDVI_combined_compressed.gif\" width=1000\u003e\n\nTo calculate the harmonic fitted curve of a periodic signal, ordinary least squares regressions are computed using coupled sine and cosine curves on time-series data. The underlying algorithm which is based Shumway, R. H., \u0026 Stoffer, D. S. (2017) equations 4.1 - 4.2 can be seen below:\n\n\u003cimg src=\"images/Harmonic_Equation.png\" width=500\u003e\n\n## Installation\n\nTo install the current version, use `devtools`.\n\n```R\ndevtools::install_github(\"MBalthasar/rHarmonics\")\n```\n\n## Available Functions\n\nThe following functions are currently available and tested on Windows 10.\n\n* `harmonics_fun()` This function enables the user to model different number of cycles per year for a given time series data set.\n\n## Example\n\nIn this example a fitted curve using three cylces per year based on a NDVI MODIS timeseries is computed:\n\n```R\nlibrary(ggplot2)\n\n# Load sample NDVI time-series data.frame\nndvi_df \u003c- base::readRDS(system.file(package = \"rHarmonics\",\n                                     \"extdata\", \"MODIS_NDVI_TimeSeries.rda\"))\n\n# Apply harmonic function using 3 cycles per year\nfitted_3rd_deg \u003c- harmonics_fun(user_vals = ndvi_df$ndvi,\n                                user_dates = ndvi_df$dates,\n                                harmonic_deg = 3)\n\n# Combine fitted values with original df\ncombined_df \u003c- cbind(ndvi_df, fitted_3rd_deg)\nnames(combined_df) \u003c- c(\"dates\", \"ndvi\", \"fitted\")\n\n# Plot original data with fitted values\nggplot2::ggplot() +\n  geom_point(data=combined_df, aes(x = dates, y = ndvi), color='black', size=1) +\n  geom_line(data=combined_df, aes(x = dates, y = fitted), colour = \"red\", size=1)+\n  labs(title=\"MODIS NDVI TimeSeries with fitted values\", x=\"Date\", y=\"NDVI\") +\n  theme(plot.title = element_text(hjust = 0.5, face=\"bold\", size=14),\n        axis.text=element_text(size=10),\n        axis.title=element_text(size=12),\n        legend.title=element_text(size=13, face=\"bold\"),\n        legend.text=element_text(size=13))+\n  ylim(0,1)\n```\n\n\u003cimg src=\"images/Rplot01.png\" width=1000\u003e\n\nThe function can also be applied on a multi-layer raster stack to create a cloud-interpolated psuedo times-series data set:\n\n```R\n# Apply harmonic function on multi-layer raster file\n\nlibrary(raster)\n\n# Load sample cloud- and snow-free MODIS TimeSeries\nsample_raster \u003c- raster::brick(system.file(package = \"rHarmonics\",\n                                           \"extdata\",\n                                           \"MODIS_NDVI_stack.tif\"))\n\nfitted_raster \u003c- raster::calc(sample_raster,\n                              function(x){\n                                 harmonics_fun(x, user_dates = ndvi_df$dates,\n                                               harmonic_deg = 3)\n                              })\n```\n\n## Citation\nPhilipp, M. B. (2020): rHarmonics V.1.0. Zenodo. https://doi.org/10.5281/zenodo.3994381.\n\n## Literature\nShumway, R. H., \u0026 Stoffer, D. S. (2017). Time series analysis and its applications: with r examples. Springer.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMBalthasar%2FrHarmonics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMBalthasar%2FrHarmonics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMBalthasar%2FrHarmonics/lists"}