{"id":26739474,"url":"https://github.com/quishqa/limaair","last_synced_at":"2025-04-14T15:43:23.302Z","repository":{"id":112485833,"uuid":"459438261","full_name":"quishqa/limaair","owner":"quishqa","description":"An R package to download air quality  and meteorological data from Lima, Peru :peru: .","archived":false,"fork":false,"pushed_at":"2023-10-01T18:16:16.000Z","size":56,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T04:37:44.953Z","etag":null,"topics":["air-pollution","air-quality-data","lima","peru","r","r-package","rstats"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quishqa.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}},"created_at":"2022-02-15T05:19:26.000Z","updated_at":"2024-11-02T23:01:43.000Z","dependencies_parsed_at":"2023-10-11T06:00:30.124Z","dependency_job_id":null,"html_url":"https://github.com/quishqa/limaair","commit_stats":{"total_commits":43,"total_committers":1,"mean_commits":43.0,"dds":0.0,"last_synced_commit":"32cc7a331ff0fae33f38d667d23acf3207de05bc"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quishqa%2Flimaair","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quishqa%2Flimaair/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quishqa%2Flimaair/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quishqa%2Flimaair/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quishqa","download_url":"https://codeload.github.com/quishqa/limaair/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248908024,"owners_count":21181449,"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":["air-pollution","air-quality-data","lima","peru","r","r-package","rstats"],"created_at":"2025-03-28T04:37:32.244Z","updated_at":"2025-04-14T15:43:23.285Z","avatar_url":"https://github.com/quishqa.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# limaair\n \u003c!-- badges: start --\u003e\n  [![R-CMD-check](https://github.com/quishqa/limaair/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/quishqa/limaair/actions/workflows/R-CMD-check.yaml)\n\u003c!-- badges: end --\u003e\n\nThis package downloads pollutant data from the [SENAMHI air quality network](https://www.senamhi.gob.pe/?p=calidad-del-aire), meteorological data from [SENAMHI automatic weather staions](https://www.senamhi.gob.pe/servicios/?p=estaciones), and  sounding data from [Jorge Chávez airport](https://en.wikipedia.org/wiki/Jorge_Ch%C3%A1vez_International_Airport) located in Lima, capital of Peru.\nThe returned `data.frame` is a complete dataset.\nThis means that missing data by missing hours is padded out by `NA`.\n\n## Installation\n\nTo install `limaair` you need first to install `devtools`.\nYou can do it by:\n\n```R\ninstall.package(\"devtools\")\n```\n\nThen install `limaair` by:\n```R\ndevtools::install_github(\"quishqa/limaair\")\n```\n\n## How to use\n`limaair` has three functions: \n - **`download_senamhi_pol()`**.\n - **`download_senamhi_met()`**.\n - **`donwload_airport_sounding()`**\n\nTo use `download_senamhi_pol()`, you need the air quality station (AQS) code (`aqs_code`),\nthe pollutant code (`pol_code`),\nand the start and end date of the download (`start_date` and `end_date`).\nAnd, to use `download_senmahi_met()`, you need to know the automatic weather station (AWS) code \n(`aws_code`)\n\n`limaair` has three datasets to check `aqs_code`, `pol_code`, and `aws_code` values:\n\n```R\nlibrary(limaair)\n\n# To check SENAMHI AQS code, name, latitude and longitude\nsenamhi_aqs\n\n# To check SENAMHI AQS pollutant code, name and units\nsenamhi_params\n\n# To check SENAMHI AWS code, name latitude and longitude\nsenamhi_aws\n```\n\n## Examples\n### Downloading one pollutant from one station\nIn this example we'll download fine particle concentrations (PM2.5) from Campo de Marte station, from January 1st to January 7th of 2022.\nHere  how you do it.\n\n```R\nlibrary(limaair)\n\nsenamhi_aqs # To check Campo de Marte\nsenamhi_params # To check PM25 code\n\ncm_code \u003c- 112194\npm25_code \u003c- \"N_PM25\"\nstart_date \u003c- \"01/01/2022\"\nend_date \u003c- \"07/01/2022\"\n\ncm_pm25 \u003c- download_senamhi_pol(aqs_codes = cm_code,\n                                pol_codes = pm25_code,\n                                start_date = start_date,\n                                end_date = end_date)\n\n```\n\n### Download many pollutants from many stations\nMaybe you need to compare data from different stations for different pollutant. You can do it with the same `download_senamhi_pol` function. `aqs_codes` and `pol_codes` can be a vector with the AQS and pollutant codes!.\nIn this example we'll download PM25 and PM10 from Campo de Marte and San Borja stations.\n\n```R\nlibrary(limaair)\n\nsenamhi_aqs # To check Campo de Marte and San Borja station codes\nsenamhi_params # To check PM25 and PM10 codes\n\ncm_sb_code \u003c- c(112194, 112193)\npm_code \u003c- c(\"N_PM25\", \"N_PM10\")\nstart_date \u003c- \"01/01/2022\"\nend_date \u003c- \"07/01/2022\"\n\ncm_pm25 \u003c- download_senamhi_pol(aqs_codes = cm_sb_code,\n                                pol_codes = pm_code,\n                                start_date = start_date,\n                                end_date = end_date)\n\n```\nVoilà! In this case `download_senamhi_pol`returns a **`list`** with two data frames (one for each station). Each data frame has a column for each pollutant. If you prefer one **`data.frame`**  returned instead of a list (i.e. both data frames combined by row), you can just use **`to_df = TRUE`** argument:\n\n```R\ncm_sb_code \u003c- c(112194, 112193)\npm_code \u003c- c(\"N_PM25\", \"N_PM10\")\nstart_date \u003c- \"01/01/2022\"\nend_date \u003c- \"07/01/2022\"\n\ncm_pm25 \u003c- download_senamhi_pol(aqs_codes = cm_sb_code,\n                                pol_codes = pm_code,\n                                start_date = start_date,\n                                end_date = end_date,\n                                to_df = TRUE) # Look here!\n```\n\n### Downloading meteorological data  from automatic weather stations\n\nFollowing the same philosophy as `download_senamhi_pol` function, you can use `download_senamhi_met`\nto download data for Temperature (°C), Precipitation (mm/hour), Relative Humidity (%), Wind speed (m/s) and direction (°). You only need to know the `aws_code`, which for some cases is the same as the `aqs_code` (**except for Campo de Marte**). In this example, We download meteorological data \nfor Campo de Marte AWS\n```R\ncm_code \u003c- 112181 # senamhi_aws\nstart_date \u003c- \"01/01/2019\"\nend_date \u003c- \"28/02/2019\"\n\ncm_met \u003c- download_senamhi_met(112181, \"01/01/2019\", \"28/02/2019\")\n```\nLike `download_senamhi_pol`, you can download data for multiple AWS.\n\n### Downloading sounding data from Jorge Chavez airport\n\nThe `download_airport_sounding` function download sounding data from [Wyoming University sounding \nrepository](https://weather.uwyo.edu/upperair/sounding.html). Default values are set for [Jorge \nChavez International Airport](https://en.wikipedia.org/wiki/Jorge_Ch%C3%A1vez_International_Airport), so you can also use this function to download\nsounding data  for other airports ;)\n```R\n# Downloading sounding for 15/01/2019 at 12z\njc_sounding \u003c- download_airport_sounding(\"15/01/2019\")\n```\n\n### Exporting to csv\nIf you prefer to process the data in another software,\nyou can export the downloaded data to a csv.\nYou just need to add the `to_csv` and `csv_path` arguments in `download_senamhi_pol` function.\nIf `to_df = TRUE`, then it will write a csv with the following name convention `{aqs_code1}_{aqs_code2}...{aqs_codeN}-{pol_code1}...{pol_codeN}-{start_date}-{end_date}.csv`\n\nIf `to_df = FALSE`, then it will create a csv for each station with the followingname convention `{aqs_code1-{pol_code1}...{pol_codeN}-{start_date}-{end_date}.csv`.\n\nIf `csv_path = \"\"` (the default value) then the csv will be saved in the working directory.\n\n```R\ncm_sb_code \u003c- c(112194, 112193)\npm_code \u003c- c(\"N_PM25\", \"N_PM10\")\nstart_date \u003c- \"01/01/2022\"\nend_date \u003c- \"07/01/2022\"\n\ncm_pm25 \u003c- download_senamhi_pol(aqs_codes = cm_sb_code,\n                                pol_codes = pm_code,\n                                start_date = start_date,\n                                end_date = end_date,\n                                to_df = TRUE,\n                                to_csv = TRUE,\n                                csv_path = \"~/\")\n```\n\nIt will create the `112194_112193-N_PM25_N_PM10-01012022-07012022.csv` in the home directory.\n\n# Caveat Emptor\nAccording to SENAMHI, the data displayed in their site is **not validated data**, so you need to be careful and perform a data quality control methodology. You can do it!\n\n# Acknowledgment\nThanks to SENAMHI for posting on-line their air quality data.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquishqa%2Flimaair","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquishqa%2Flimaair","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquishqa%2Flimaair/lists"}