MCPcopy Create free account
hub / github.com/pydata/xarray / _infer_daily_rule

Method _infer_daily_rule

xarray/coding/frequencies.py:154–180  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

152 return _maybe_add_count("us", delta / _ONE_MICRO)
153
154 def _infer_daily_rule(self):
155 annual_rule = self._get_annual_rule()
156 if annual_rule:
157 nyears = self.year_deltas[0]
158 month = _MONTH_ABBREVIATIONS[self.index[0].month]
159 alias = f"{annual_rule}-{month}"
160 return _maybe_add_count(alias, nyears)
161
162 quartely_rule = self._get_quartely_rule()
163 if quartely_rule:
164 nquarters = self.month_deltas[0] / 3
165 mod_dict = {0: 12, 2: 11, 1: 10}
166 month = _MONTH_ABBREVIATIONS[mod_dict[self.index[0].month % 3]]
167 alias = f"{quartely_rule}-{month}"
168 return _maybe_add_count(alias, nquarters)
169
170 monthly_rule = self._get_monthly_rule()
171 if monthly_rule:
172 return _maybe_add_count(monthly_rule, self.month_deltas[0])
173
174 if len(self.deltas) == 1:
175 # Daily as there is no "Weekly" offsets with CFTime
176 days = self.deltas[0] / _ONE_DAY
177 return _maybe_add_count("D", days)
178
179 # CFTime has no business freq and no "week of month" (WOM)
180 return None
181
182 def _get_annual_rule(self):
183 if len(self.year_deltas) > 1:

Callers 1

get_freqMethod · 0.95

Calls 4

_get_annual_ruleMethod · 0.95
_get_quartely_ruleMethod · 0.95
_get_monthly_ruleMethod · 0.95
_maybe_add_countFunction · 0.85

Tested by

no test coverage detected