Skip to contents

For a given GW event name (e.g. "GW150914") and detector (e.g. "H1"), this function tries several GWOSC v2 endpoints in a sensible order to find a matching strain-file URL and download it. Among multiple candidates, it prioritizes the one whose sample rate is closest to sampling.freq.

Usage

download_event(
  event_name,
  det,
  path = ".",
  file.format = "hdf5",
  sampling.freq = 4096,
  timeout = 300,
  load = FALSE,
  remove = FALSE,
  verbose = TRUE
)

Arguments

event_name

Character. GWOSC event name, e.g. "GW150914".

det

Character. Detector name, e.g. "H1".

path

Character. Directory to save file (created if missing).

file.format

Character. "hdf5" (default), "gwf", or "txt".

sampling.freq

Numeric scalar (Hz). Desired sampling frequency used to prioritize candidates. Default 4096.

timeout

Integer. Download timeout seconds (default 300).

load

Logical. If TRUE and HDF5, load via read_H5() and return a ts.

remove

Logical. If load=TRUE and remove=TRUE, delete file after loading.

verbose

Logical. Print progress messages.

Value

If load=FALSE, normalized path to downloaded file (character). If load=TRUE and HDF5, a ts object from read_H5().

Details

The function attempts (in order): 1. /api/v2/events/<EVENT>/strain-files 2. /api/v2/events/<EVENT> -> latest version -> /event-versions/<EVENT>-vN/strain-files 3. /api/v2/event-versions/<EVENT>/dataset -> use dataset$strain_files_url

If load=TRUE and the file is HDF5, the function returns a ts object by delegating to read_H5(file, sampling.freq, dq.level).