← LeaderboardThe Skill Leaderboard

netcdf-cf-time-audit

Audit NetCDF CF-Conventions time coordinates offline with xarray and cftime across reference units, Gregorian vs. 360_day/noleap calendars, Feb 30, time_bnds, and round-trips.

Published by sickn33 ↗sickn33/agentic-awesome-skills

Try your first task

A source-grounded starter task has not been verified for this skill yet.

SKILL.md

name: netcdf-cf-time-auditdescription: "Audit NetCDF CF-Conventions time coordinates offline with xarray and cftime across reference units, Gregorian vs. 360_day/noleap calendars, Feb 30, time_bnds, and round-trips."category: datarisk: safesource: selfsource_type: selfdate_added: "2026-12-01"author: Koushik-Katkamtags: [netcdf, cf-conventions, xarray, cftime, climate, time-coordinates]

NetCDF CF Time Audit

Overview

Audit NetCDF CF-Conventions time coordinates offline using xarray (xarray.coders.CFDatetimeCoder(use_cftime=True)), cftime, and netCDF4 (CF-1.11 / CF-Conventions calendar and time-coordinate rules). Verifies reference epochs and units, non-Gregorian 360_day (including February 30) and noleap (365_day) calendar decoding, standard vs. non-Gregorian leap-day stepping, bounds (time_bnds) interval consistency, NetCDF write/read round-trips, and explicit rejection of invalid units, unsupported calendars, or lossy pandas datetime64 coercions.

Distinction from existing weather and scientific-data skills:

  • xarray-coordinate-alignment: aligns and merges already-loaded xarray datasets (xr.align, xr.merge) without auditing raw NetCDF CF units, calendar, time_bnds, or cftime round-trips.
  • weather-data-reproducibility: creates SHA-256 provenance manifests for downloaded weather datasets rather than testing CF time coordinate decoding/encoding invariants.
  • weather-observation-fetching and weather-model-data-fetching: retrieve METAR/ISD/IGRA station reports and AWS S3/NOMADS GRIB2 slices rather than auditing NetCDF CF time metadata.

When to Use

  • Validating climate/GCM or synthetic NetCDF datasets using 360_day, noleap (365_day), all_leap, proleptic_gregorian, or standard calendars.
  • Catching silent calendar corruption caused by loading NetCDF with default numpy/pandas coercion or invalid CF units ("months since ...").
  • Auditing time_bnds variables alongside time centers/edges before downstream regridding or temporal aggregation.
  • Do not use this skill to fetch remote OPeNDAP/THREDDS endpoints or rewrite production archives in place.

Prerequisites

  • Python 3.12+ with pinned NetCDF/xarray dependencies (numpy==2.5.3 and scipy==1.18.1 require >=3.12; xarray==2026.9.0 and cftime==1.6.6 require >=3.11; tested with Python 3.12.10, xarray==2026.9.0, cftime==1.6.6, netCDF4==1.7.4, scipy==1.18.1, numpy==2.5.3, pytest==9.1.1).
  • No network access, remote catalogs, or external files required (fixtures run cleanly in temporary directories).

How It Works

1. Inspect raw NetCDF time attributes before decoding

  1. Read raw units, calendar, and bounds attributes directly via netCDF4.Dataset(..., "r"), validate coordinate dimensionality (strictly 1-D non-empty), inspect masked/fill values before coercion, and reject non-finite (NaN/inf) values as structured findings.
  2. Validate CF units format ("<unit> since <reference-datetime>") against the harness's supported fixed-duration unit subset (seconds, minutes, hours, days) — explicitly distinguishing non-uniform "months since" / "years since" or unsupported udunits strings from universally malformed units.
  3. Explicitly classify unknown calendar strings ("mars_sol") as UNSUPPORTED.

2. Decode strictly with CFDatetimeCoder(use_cftime=True) and verify monotonicity & exact tuples

Run the local verification suite in NetCDF CF time audit harness:

  1. Monotonic coordinate validation: Assert strictly monotonic increasing (or explicitly permitted monotonic decreasing) time values; reject constant duplicates or time reversals (INVALID_TIME_ORDER).
  2. Exact decoded (year, month, day, hour, minute, second, microsecond) comparison & tuples: Compare exact cftime timestamps including fractional-second microsecond precision between cftime.num2date and xr.coders.CFDatetimeCoder(use_cftime=True), catching xarray decoding errors as structured FAIL findings rather than uncaught exceptions.
  3. Block lossy datetime64 coercion: Prove that attempting to coerce 360_day coordinates containing February 30 into standard numpy.datetime64 / Python datetime fails explicitly instead of silently dropping or shifting dates.
  4. time_bnds consistency: Verify (N, 2) unmasked finite bounds shape, endpoint order matching the time axis (descending for a decreasing axis), and coordinate containment between the endpoint values.
  5. Encode/decode round-trip: Persist to NetCDF4 with explicit encoding={"time": {"units": ..., "calendar": ...}} and re-read verifying identical cftime timestamps, calendar, and units.

Examples

Run the self-contained verification suite in NetCDF CF time audit harness:

User request: "Audit our 360_day climate NetCDF output to make sure Feb 30 decodes accurately and time_bnds match."
Inputs: Local NetCDF4 dataset with CF units ('days since 2025-01-01 00:00:00'), calendar='360_day', and time_bnds.
Expected result: CFDatetimeCoder(use_cftime=True) preserves Datetime360Day(2025, 2, 30) across NetCDF round-trip,
  noleap skips 2024-02-29 cleanly, out-of-bounds time_bnds fail with INVALID_TIME_BOUNDS, and unsupported calendars
  return UNSUPPORTED.

Limitations

  • Audits the CF time coordinate and optional bounds variable using netCDF4==1.7.4, xarray==2026.9.0, and cftime==1.6.6 under CF-1.11 fixed-duration time units (seconds, minutes, hours, days); calendar-varying units such as "months since" / "years since" are excluded from this fixed-duration subset (UNSUPPORTED_OR_INVALID_UNIT).
  • decoded_tuples summarizes (year, month, day, hour, minute, second) cleanly while decoded_timestamps_us preserves 7-tuple sub-second microsecond precision when inspecting fractional offsets.
  • julian vs. standard (gregorian mixed Julian/Gregorian reform at 1582-10-15) historical edge cases prior to 1582 require explicit historical epoch checks beyond modern 2024–2025 fixtures.

Safety and Side Effects

  • Strictly offline and read-only against user-supplied files (writes synthetic NetCDF fixtures solely inside temporary pytest directories).
  • Never modifies existing scientific archives in place or queries remote data portals.

Sources and related skills