Return a day of year in the new calendar. Removes Feb 29th and five other days chosen randomly within five sections of 72 days.
(time, target_calendar, use_cftime)
| 255 | |
| 256 | |
| 257 | def _random_day_of_year(time, target_calendar, use_cftime): |
| 258 | """Return a day of year in the new calendar. |
| 259 | |
| 260 | Removes Feb 29th and five other days chosen randomly within five sections of 72 days. |
| 261 | """ |
| 262 | year = time.dt.year[0] |
| 263 | source_calendar = time.dt.calendar |
| 264 | new_doy = np.arange(360) + 1 |
| 265 | rm_idx = np.random.default_rng().integers(0, 72, 5) + 72 * np.arange(5) |
| 266 | if source_calendar == "360_day": |
| 267 | for idx in rm_idx: |
| 268 | new_doy[idx + 1 :] = new_doy[idx + 1 :] + 1 |
| 269 | if _days_in_year(year, target_calendar) == 366: |
| 270 | new_doy[new_doy >= 60] = new_doy[new_doy >= 60] + 1 |
| 271 | elif target_calendar == "360_day": |
| 272 | new_doy = np.insert(new_doy, rm_idx - np.arange(5), -1) |
| 273 | if _days_in_year(year, source_calendar) == 366: |
| 274 | new_doy = np.insert(new_doy, 60, -1) |
| 275 | return new_doy[time.dt.dayofyear - 1] |
| 276 | |
| 277 | |
| 278 | def _convert_to_new_calendar_with_new_day_of_year( |
nothing calls this directly
no test coverage detected
searching dependent graphs…