Skip to content

Datasets

fdatools.datasets: the datasets used in the FDA books. growth, gait and pinch ship inside the package. The others are downloaded once, checked against a SHA-256 checksum and cached in ~/.cache/fdatools (set FDATOOLS_DATA_DIR to change the location).

Loaders for the real datasets shipped with R's fda package (v6.3.0).

Every load_*() function returns a frozen dataclass of raw NumPy arrays plus the string/label metadata R attaches to the object (station names, subject ids, factor levels, ...), reproduced exactly as fda stores them. None of these datasets is already a smooth functional object in R (fda stores them as plain matrices/arrays/data frames), so none of the dataclasses below carries an .fd property -- fit one with :func:fdatools.smooth using the raw arrays and the accompanying t grid.

Storage: growth, gait and pinch ship inside the wheel (src/fdatools/_data/, read via :mod:importlib.resources). Every other dataset is downloaded on first use from the project's GitHub release data-v1, SHA-256 verified, and cached under $FDATOOLS_DATA_DIR (default ~/.cache/fdatools). See docs/dev/data-release.md for how the release archives are built and published.

fda 6.3.0's dataset catalog has no CSTR dataset and no separate "Chinese script" dataset (see tests/golden/datasets.json's dataset_catalog case) -- load_cstr/load_chinese_script from SPEC.md §8 are not implemented; see PROGRESS.md for the record. The catalog's "dateAccessories" group (day.5, monthLetters, ...) are plotting-axis constants, not datasets, and are likewise out of scope.

CanadianWeather dataclass

CanadianWeather(
    temp: NDArray[float64],
    precip: NDArray[float64],
    log10precip: NDArray[float64],
    t: NDArray[float64],
    stations: list[str],
    province: list[str],
    region: list[str],
    coordinates: NDArray[float64],
    monthly_temp: NDArray[float64],
    monthly_precip: NDArray[float64],
    geogindex: NDArray[float64],
)

Daily temperature/precipitation at 35 Canadian weather stations, 1960-1994.

Reproduces R fda::CanadianWeather (dailyAv's three layers split into separate fields) plus CanadianWeather$monthlyTemp/monthlyPrecip.

Attributes:

Name Type Description
temp, precip (ndarray, shape(365, 35))

Average daily temperature (deg C) and precipitation (mm).

log10precip (ndarray, shape(365, 35))

log10(precip) with the 27 zero readings replaced by 0.05 mm first.

t (ndarray, shape(365))

Day of year, 1-365.

stations list of str

35 station names (R: CanadianWeather$place).

province, region list of str

Province and one of the 4 climate zones (Atlantic/Pacific/Continental/Arctic) for each station.

coordinates (ndarray, shape(35, 2))

North latitude, west longitude.

monthly_temp, monthly_precip (ndarray, shape(12, 35))

Monthly averages: temperature (deg C) and daily precipitation (mm).

geogindex (ndarray, shape(35))

Station order east-to-west-then-north (R: CanadianWeather$geogindex).

Growth dataclass

Growth(
    hgtm: NDArray[float64],
    hgtf: NDArray[float64],
    age: NDArray[float64],
)

Berkeley Growth Study: heights of 39 boys and 54 girls, ages 1-18.

Reproduces R fda::growth (hgtm, hgtf, age). Ages are not equally spaced.

Attributes:

Name Type Description
hgtm (ndarray, shape(31, 39))

Boys' heights in cm at each of 31 ages.

hgtf (ndarray, shape(31, 54))

Girls' heights in cm at each of 31 ages.

age (ndarray, shape(31))

Ages in years at which heights were measured.

Gait dataclass

Gait(
    value: NDArray[float64],
    t: NDArray[float64],
    subjects: list[str],
    variables: list[str],
)

Hip and knee angle (degrees) through a 20-point gait cycle, 39 boys.

Reproduces R fda::gait, an array of dim (20, 39, 2).

Attributes:

Name Type Description
value (ndarray, shape(20, 39, 2))

Angles in degrees: value[..., 0] is hip angle, value[..., 1] is knee angle (see :attr:hip_angle/:attr:knee_angle).

t (ndarray, shape(20))

Standardized gait time, proportion of the cycle (0.025 to 0.975).

subjects list of str

39 subject ids, "boy1".."boy39".

variables list of str

["Hip Angle", "Knee Angle"], the meaning of value's last axis.

hip_angle property

hip_angle: NDArray[float64]

Return value[..., 0], shape (20, 39).

knee_angle property

knee_angle: NDArray[float64]

Return value[..., 1], shape (20, 39).

Handwriting dataclass

Handwriting(
    value: NDArray[float64],
    t: NDArray[float64],
    subjects: list[str],
    variables: list[str],
)

20 cursive samples of 1401 (x, y) coordinates writing "fda".

Reproduces R fda::handwrit + fda::handwritTime. The subject was Jim Ramsay; each replicate has been resampled to a common 2300 ms length and registered so key features align across replicates.

Attributes:

Name Type Description
value (ndarray, shape(1401, 20, 2))

Pen position in metres: value[..., 0] is X, value[..., 1] is Y (see :attr:x/:attr:y).

t (ndarray, shape(1401))

Sampling times in milliseconds, 0 to 2300.

subjects list of str

20 replicate ids, "rep01".."rep20".

variables list of str

["X", "Y"], the meaning of value's last axis.

x property

x: NDArray[float64]

Return value[..., 0], shape (1401, 20).

y property

y: NDArray[float64]

Return value[..., 1], shape (1401, 20).

Pinch dataclass

Pinch(
    pinch: NDArray[float64],
    pinchraw: NDArray[float64],
    t: NDArray[float64],
)

151 measurements of pinch force across 20 replications.

Reproduces R fda::pinch + pinchraw + pinchtime. The original recording had 300 observations every 2 ms; pinchraw keeps the first 151, while pinch instead selects the 151 observations so that every curve's maximum falls at 0.076 s.

Attributes:

Name Type Description
pinch (ndarray, shape(151, 20))

Pinch force in newtons (N), aligned so each curve peaks at 0.076 s.

pinchraw (ndarray, shape(151, 20))

Pinch force in newtons (N), the first 151 of the original 300 samples, unaligned.

t (ndarray, shape(151))

Time in seconds from the start, every 2 ms (R: pinchtime).

Melanoma dataclass

Melanoma(value: NDArray[float64], columns: list[str])

Age-adjusted melanoma incidence per 100,000 in Connecticut, 1936-1972.

Reproduces R fda::melanoma. The R object is a bare 37x3 matrix; its first column is a plain 1..37 row index (the documented format lists only year/incidence, but the shipped object carries a leading index column -- reproduced as-is, see columns for the mapping).

Attributes:

Name Type Description
value (ndarray, shape(37, 3))

Columns as listed in columns: the row index, the calendar year (1936-1972), and the age-adjusted incidence per 100,000 people.

columns list of str

["index", "year", "incidence"].

Refinery dataclass

Refinery(
    time: NDArray[float64],
    reflux: NDArray[float64],
    tray47: NDArray[float64],
)

194 observations of reflux and "tray 47 level" in an oil refinery column.

Reproduces R fda::refinery (a data frame with 3 numeric columns). R documents no physical unit for any column, so none is given here.

Attributes:

Name Type Description
time (ndarray, shape(194))

Observation time, 0-193 (an index; R gives no unit).

reflux (ndarray, shape(194))

Reflux flow, centered on the mean of the first 60 observations (no unit documented).

tray47 (ndarray, shape(194))

Tray 47 level, centered on the mean of the first 60 observations (no unit documented).

Seabird dataclass

Seabird(
    counts: dict[str, NDArray[float64]],
    year: NDArray[float64],
    site: NDArray[float64],
    transect: NDArray[float64],
    temp: NDArray[float64],
    observ_cond: list[str],
    bay: list[str],
    observ_cond_factor3: list[str] = list(),
)

Seabird sighting counts by transect, 4 Kodiak Island bays, 1986-2005.

Reproduces R fda::seabird (a data frame with 22 columns): 15 species count columns, 3 integer id columns, one numeric column, and 3 factor columns.

Attributes:

Name Type Description
counts dict of str to ndarray, each shape (3793,)

One entry per species code (BAGO, BLSC, COME, COMU, CORM, HADU, HOGR, LOON, MAMU, OLDS, PIGU, RBME, RNGR, SUSC, WWSC): the number of sightings of that species by transect by year; NaN marks R's NA.

year, site, transect, temp (ndarray, shape(3793))

Survey year (1986-2005), site code, transect code, and temperature (R documents no unit for the temperature).

observ_cond list of str

Observing conditions factor (5 levels).

bay list of str

Bay name factor (4 levels).

observ_cond_factor3 list of str

observ_cond collapsed to 3 levels.

ReginaPrecip dataclass

ReginaPrecip(value: NDArray[float64])

Daily June precipitation (mm) in Regina, Saskatchewan, 1960-1993.

Reproduces R fda::ReginaPrecip: 16 missing values already omitted.

Attributes:

Name Type Description
value (ndarray, shape(1006))

Precipitation in mm.

MontrealTemp dataclass

MontrealTemp(value: NDArray[float64], years: list[str])

Daily temperature (deg C) in Montreal, 1961-1994.

Reproduces R fda::MontrealTemp, a 34 (years) x 365 (days) matrix.

Attributes:

Name Type Description
value (ndarray, shape(34, 365))

Daily average temperature in degrees Celsius.

years list of str

The 34 years, "1961".."1994".

Daily dataclass

Daily(
    tempav: NDArray[float64],
    precav: NDArray[float64],
    place: list[str],
)

Daily temperature/precipitation at 35 Canadian stations (alternate layout).

Reproduces R fda::daily: the same data as :class:CanadianWeather, kept by fda "primarily for compatibility with scripts written before the other format became available" and with the Matlab fda code -- place here is padded to a fixed 11 characters (unlike :attr:CanadianWeather.stations, which is trimmed).

Attributes:

Name Type Description
tempav, precav (ndarray, shape(365, 35))

Average daily temperature (deg C) and precipitation (mm).

place list of str

35 station names, each padded to 11 characters with trailing blanks.

InfantGrowth dataclass

InfantGrowth(
    day: NDArray[float64],
    tibia_length: NDArray[float64],
    sd_length: NDArray[float64],
)

Tibia length for one infant's first 40 days of life.

Reproduces R fda::infantGrowth (a 3-column matrix): each length is the average of 5 measurements.

Attributes:

Name Type Description
day (ndarray, shape(40))

Age in days.

tibia_length (ndarray, shape(40))

Average tibia length in mm.

sd_length (ndarray, shape(40))

Standard deviation of the 5 measurements, in mm.

Nondurables dataclass

Nondurables(
    value: NDArray[float64], start: str, frequency: int
)

US nondurable goods index, monthly, January 1919 onward.

Reproduces R fda::nondurables.

Attributes:

Name Type Description
value (ndarray, shape(1377))

The index value each month (a dimensionless index; R documents no unit).

start str

First month covered, "1919-01".

frequency int

Observations per year (12, monthly).

Lip dataclass

Lip(
    value: NDArray[float64],
    t: NDArray[float64],
    left_elbow: NDArray[float64],
    right_elbow: NDArray[float64],
)

51 measurements of lower lip position, 20 repetitions of "bob".

Reproduces R fda::lip + liptime + lipmarks.

Attributes:

Name Type Description
value (ndarray, shape(51, 20))

Lower lip position in mm (the unit R's help examples give it), sampled every 7 ms for 350 ms.

t (ndarray, shape(51))

Time in seconds from the start (R: liptime).

left_elbow, right_elbow (ndarray, shape(20))

Landmark times (R: lipmarks$leftElbow/lipmarks$rightElbow) for each of the 20 repetitions.

load_canadian_weather

load_canadian_weather() -> CanadianWeather

Load :class:CanadianWeather (downloaded + cached on first use).

Examples:

>>> import fdatools as fdt
>>> cw = fdt.datasets.load_canadian_weather()
>>> cw.temp.shape
(365, 35)

load_growth

load_growth() -> Growth

Load :class:Growth (ships in-package, no network).

Examples:

>>> import fdatools as fdt
>>> g = fdt.datasets.load_growth()
>>> g.hgtm.shape, g.hgtf.shape, g.age.shape
((31, 39), (31, 54), (31,))

load_gait

load_gait() -> Gait

Load :class:Gait (ships in-package, no network).

Examples:

>>> import fdatools as fdt
>>> gait = fdt.datasets.load_gait()
>>> gait.value.shape
(20, 39, 2)

load_handwriting

load_handwriting() -> Handwriting

Load :class:Handwriting (downloaded + cached on first use).

Examples:

>>> import fdatools as fdt
>>> hw = fdt.datasets.load_handwriting()
>>> hw.value.shape
(1401, 20, 2)

load_pinch

load_pinch() -> Pinch

Load :class:Pinch (ships in-package, no network).

Examples:

>>> import fdatools as fdt
>>> p = fdt.datasets.load_pinch()
>>> p.pinch.shape, p.pinchraw.shape, p.t.shape
((151, 20), (151, 20), (151,))

load_melanoma

load_melanoma() -> Melanoma

Load :class:Melanoma (downloaded + cached on first use).

Examples:

>>> import fdatools as fdt
>>> m = fdt.datasets.load_melanoma()
>>> m.value.shape
(37, 3)

load_refinery

load_refinery() -> Refinery

Load :class:Refinery (downloaded + cached on first use).

Examples:

>>> import fdatools as fdt
>>> r = fdt.datasets.load_refinery()
>>> r.time.shape
(194,)

load_seabird

load_seabird() -> Seabird

Load :class:Seabird (downloaded + cached on first use).

Examples:

>>> import fdatools as fdt
>>> sb = fdt.datasets.load_seabird()
>>> sb.year.shape
(3793,)

load_regina_precip

load_regina_precip() -> ReginaPrecip

Load :class:ReginaPrecip (downloaded + cached on first use).

Examples:

>>> import fdatools as fdt
>>> rp = fdt.datasets.load_regina_precip()
>>> rp.value.shape
(1006,)

load_montreal_temp

load_montreal_temp() -> MontrealTemp

Load :class:MontrealTemp (downloaded + cached on first use).

Examples:

>>> import fdatools as fdt
>>> mt = fdt.datasets.load_montreal_temp()
>>> mt.value.shape
(34, 365)

load_daily

load_daily() -> Daily

Load :class:Daily (downloaded + cached on first use).

Examples:

>>> import fdatools as fdt
>>> d = fdt.datasets.load_daily()
>>> d.tempav.shape
(365, 35)

load_infant_growth

load_infant_growth() -> InfantGrowth

Load :class:InfantGrowth (downloaded + cached on first use).

Examples:

>>> import fdatools as fdt
>>> ig = fdt.datasets.load_infant_growth()
>>> ig.day.shape
(40,)

load_nondurables

load_nondurables() -> Nondurables

Load :class:Nondurables (downloaded + cached on first use).

Examples:

>>> import fdatools as fdt
>>> nd = fdt.datasets.load_nondurables()
>>> nd.value.shape
(1377,)

load_lip

load_lip() -> Lip

Load :class:Lip (downloaded + cached on first use).

Examples:

>>> import fdatools as fdt
>>> lip = fdt.datasets.load_lip()
>>> lip.value.shape
(51, 20)