# `clim_day()`
**Category:** Time and climatology
**Status:** stable

## Purpose
Estimate a two-stage daily climatology through `cube_climatology()`.

## When to use
Use it when its declared input and output match the workflow. Prefer a narrower selection before any operation that may materialise values.

## When not to use
Do not use it to calculate `spatind` indicators or to bypass coordinate, CRS, unit, and provenance checks.

## Real signature
```r
clim_day(x, period = NULL, leap = c("feb28", "drop", "keep"),      min_n = 1L)
```

## Arguments
- `x`: see the installed Rd manual for validation and defaults.
- `period`: see the installed Rd manual for validation and defaults.
- `leap`: see the installed Rd manual for validation and defaults.
- `min_n`: see the installed Rd manual for validation and defaults.

## Input and output
Input: **ocean_cube**. Output: **climatology**.

## Backend support
Memory: **TRUE**. NetCDF: **TRUE**. The core uses bounded period/block reads.

## Dimensional effect
May change shape or return a non-cube analytical object; inspect dimensions/rows.

## Metadata
Since 0.2.0, each year contributes at most one replicate per recurrent day.
`leap = "feb28"` merges February 28 and 29 inside a leap year, and `min_n`
counts valid yearly daily replicates rather than raw observations.

## Minimal executable check
```r
library(oceancube)
stopifnot(is.function(oceancube::clim_day))
names(formals(oceancube::clim_day))
```

## Example in a workflow
Typical position: `ocean_cube` → `clim_day()` → `anom_diff/anom_z`. See the workflow scripts for a checked end-to-end example.

## Frequent errors and limitations
Invalid dimensions, selectors, units, CRS, source-file identity, optional dependencies, or unsupported grids are rejected explicitly. Read the function Rd page for exact diagnostics.

## Related functions
Previous: `ocean_cube`. Next: `anom_diff/anom_z`.
