MCPcopy
hub / github.com/pydata/xarray / _cftime_range

Function _cftime_range

xarray/coding/cftime_offsets.py:1145–1218  ·  view source on GitHub ↗

Return a fixed frequency CFTimeIndex. Parameters ---------- start : str or cftime.datetime, optional Left bound for generating dates. end : str or cftime.datetime, optional Right bound for generating dates. periods : int, optional Number of periods to gen

(
    start=None,
    end=None,
    periods=None,
    freq=None,
    normalize=False,
    name=None,
    inclusive: InclusiveOptions = "both",
    calendar="standard",
)

Source from the content-addressed store, hash-verified

1143
1144
1145def _cftime_range(
1146 start=None,
1147 end=None,
1148 periods=None,
1149 freq=None,
1150 normalize=False,
1151 name=None,
1152 inclusive: InclusiveOptions = "both",
1153 calendar="standard",
1154) -> CFTimeIndex:
1155 """Return a fixed frequency CFTimeIndex.
1156
1157 Parameters
1158 ----------
1159 start : str or cftime.datetime, optional
1160 Left bound for generating dates.
1161 end : str or cftime.datetime, optional
1162 Right bound for generating dates.
1163 periods : int, optional
1164 Number of periods to generate.
1165 freq : str or None, default: "D"
1166 Frequency strings can have multiples, e.g. "5h" and negative values, e.g. "-1D".
1167 normalize : bool, default: False
1168 Normalize start/end dates to midnight before generating date range.
1169 name : str, default: None
1170 Name of the resulting index
1171 inclusive : {"both", "neither", "left", "right"}, default "both"
1172 Include boundaries; whether to set each bound as closed or open.
1173 calendar : str, default: "standard"
1174 Calendar type for the datetimes.
1175
1176 Returns
1177 -------
1178 CFTimeIndex
1179
1180 Notes
1181 -----
1182 see cftime_range
1183 """
1184 if freq is None and any(arg is None for arg in [periods, start, end]):
1185 freq = "D"
1186
1187 # Adapted from pandas.core.indexes.datetimes._generate_range.
1188 if count_not_none(start, end, periods, freq) != 3:
1189 raise ValueError(
1190 "Exactly three of 'start', 'end', 'periods', or 'freq' must be "
1191 "specified to generate a date range. Note that 'freq' defaults to "
1192 "'D' in the event that any of 'start', 'end', or 'periods' are "
1193 "None."
1194 )
1195
1196 start = _get_normalized_cfdate(start, calendar, normalize)
1197 end = _get_normalized_cfdate(end, calendar, normalize)
1198
1199 if freq is None:
1200 dates = _generate_linear_date_range(start, end, periods)
1201 else:
1202 dates = np.array(

Callers 1

date_rangeFunction · 0.85

Calls 5

count_not_noneFunction · 0.90
CFTimeIndexClass · 0.90
_get_normalized_cfdateFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…