Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

cesm_hawc.file_index

cesm_hawc.file_index

source

Find CAM history files and read the dates in their names.

CAM history files are named <case>.cam.hN.YYYY-MM.nc (e.g. monthly means) or <case>.cam.hN.YYYY-MM-DD-SSSSS.nc, where SSSSS is the second of the day.

list_files

def list_files(directory: str, pattern: str) -> list[str]

source

List the files in a directory that match a glob pattern.

Parameters

Returns

Raises

filename_date

def filename_date(path: str) -> str | None

source

Read the date from a CAM history file name.

Parameters

Returns

filename_time

def filename_time(path: str) -> pd.Timestamp | None

source

Choose a representative time for a CAM history file from its name.

Parameters

Returns

date_in_range

def date_in_range(date: str, start: str | None, end: str | None) -> bool

source

Check whether a file date falls within a date range.

Bounds are compared at date’s own precision, so a month is in range if any part of it is.

Parameters

Returns

index_by_date

def index_by_date(directory: str, pattern: str) -> dict[str, str]

source

Index daily history files by calendar date.

Parameters

Returns

Raises

Notes

Keeps one file per date: if a date has several (e.g. 12-hourly output), only the last in sorted order is kept and the rest are dropped without warning. Use index_by_timestamp() for sub-daily output.

index_by_timestamp

def index_by_timestamp(directory: str, pattern: str) -> dict[pd.Timestamp, str]

source

Index history files by date and time of day.

Unlike index_by_date(), every file is kept when there are several per day (e.g. ...-00000.nc and ...-43200.nc for 12-hourly output).

Parameters

Returns

Raises