Skip to contents

Links daily surface PM2.5 and its aerosol components from NASA's MERRA-2 M2T1NXAER v5.12.4 product to each location and date in an s2cd vector.

Usage

get_merra_data(x, ...)

install_merra_data(
  merra_month,
  source = c("release", "earthdata"),
  overwrite = FALSE,
  quiet = FALSE
)

Arguments

x

a s2_cell_dates vector (see ?s2cd)

...

passed to stow::stow() when an official release asset is needed. The package and subdir arguments are fixed by geomarker.

merra_month

character vector of calendar months in YYYY-MM format, from 2017 onward

source

either "release" to install the matching official half-year asset or "earthdata" to build each complete month from NASA

overwrite

logical; recreate monthly data from the latest CMR listing? Matching staged daily source files are still reused.

quiet

logical; suppress progress messages?

Value

A named list with one data frame per input location and one row per requested date. Columns are merra_dust, merra_oc, merra_bc, merra_ss, merra_so4, and merra_pm25. Unavailable periods contain missing values and produce one warning.

install_merra_data() returns a named character vector of installed paths. Months in the same released half-year may have the same path.

Details

Each package release records one complete January–June and one complete July–December asset per available year. A fully available calendar month may instead be built locally with install_merra_data(source = "earthdata"). Local monthly data take precedence over a released half-year asset.

Source builds require a free NASA Earthdata Login account. Follow NASA's registration guide to create and activate an account. Before the first source build, sign in to the Cloud OPeNDAP service and authorize the Hyrax in the cloud application when prompted. NASA also documents how to preauthorize an application if the prompt does not appear.

Set the account credentials in EARTHDATA_USER and EARTHDATA_PASSWORD. They are written to temporary private netrc and cookie files in geomarker's durable managed local copy directory while NASA's authenticated redirects are followed.

Source concentrations are converted to micrograms per cubic meter and averaged across each day. Total PM2.5 is calculated as DUSMASS25 + OCSMASS + BCSMASS + SSSMASS25 + SO4SMASS * 132.14 / 96.06.

Examples

local({
  withr::local_envvar(
    R_USER_DATA_DIR = fs::path_package("geomarker", "gmrkr--8841"),
    R_GEOMARKER_NO_DOWNLOAD = "true"
  )
  print(get_merra_data(s2cd_example()))
})
#> $`8841b39a7c46e25f`
#>   merra_dust merra_oc merra_bc merra_ss merra_so4 merra_pm25
#> 1        1.1      2.1      3.1      4.1       5.1   17.41555
#> 
#> $`8841a45555555555`
#>   merra_dust merra_oc merra_bc merra_ss merra_so4 merra_pm25
#> 1       13.2     14.2     15.2     16.2      17.2    82.4603
#> 2       20.2     21.2     22.2     23.2      24.2   120.0895
#>