수면 사이클 계산기
90분 수면 사이클을 기반으로 최적의 수면 및 기상 시간을 계산합니다.
이 도구 소개
수면 사이클 계산기는 90분 수면 사이클을 기반으로 당신의 자연스러운 수면 패턴을 최적화하는 데 도움이 됩니다. 수면 사이클은 얕은 수면, 깊은 수면, 렘수면(꿈꾸는 수면)을 순서대로 거쳐 반복하는 신체의 자연스러운 리듬입니다. 완전한 사이클을 마친 후에 깨어나면 상쾌함을 느끼지만, 사이클의 중간에 깨어나면 몇 시간 동안 멍한 상태가 지속될 수 있습니다.
이 계산기를 사용하려면 원하는 취침 시간 또는 기상 시간을 입력하기만 하면 최적의 반대 시간을 알 수 있습니다. 예를 들어 오전 7시에 일어나야 한다면, 이 도구는 90분 사이클을 완성하기 위해 언제 자야 하는지 계산하여 오후 10시 30분, 자정, 또는 오전 1시 30분 같은 시간을 제안합니다. 밤새 충분한 수면을 할 때든 짧은 낮잠을 할 때든, 이 방식은 당신의 수면을 신체의 자연스러운 리듬에 맞추는 데 도움이 됩니다.
자주 묻는 질문
코드 구현
from datetime import datetime, timedelta
SLEEP_CYCLE_MINUTES = 90
FALL_ASLEEP_MINUTES = 14 # Average time to fall asleep
def wake_times_from_bedtime(bedtime: datetime, cycles: int = 5) -> list[datetime]:
"""Given a bedtime, return optimal wake-up times after N full 90-min cycles."""
fall_asleep = bedtime + timedelta(minutes=FALL_ASLEEP_MINUTES)
return [
fall_asleep + timedelta(minutes=SLEEP_CYCLE_MINUTES * i)
for i in range(1, cycles + 1)
]
def bedtimes_from_wake(wake_time: datetime, cycles: int = 5) -> list[datetime]:
"""Given a desired wake time, return bedtimes that allow N full 90-min cycles."""
return [
wake_time - timedelta(minutes=SLEEP_CYCLE_MINUTES * i + FALL_ASLEEP_MINUTES)
for i in range(1, cycles + 1)
]
# Example: bedtime at 11 PM
bedtime = datetime.now().replace(hour=23, minute=0, second=0, microsecond=0)
print(f"Bedtime: {bedtime.strftime('%I:%M %p')}")
print("Best wake times:")
for t in wake_times_from_bedtime(bedtime):
print(f" {t.strftime('%I:%M %p')} ({(t - bedtime).seconds // 60} min)")
# Example: must wake at 7 AM
wake = datetime.now().replace(hour=7, minute=0, second=0, microsecond=0)
print(f"\nWake time: {wake.strftime('%I:%M %p')}")
print("Best bedtimes:")
for t in bedtimes_from_wake(wake):
print(f" {t.strftime('%I:%M %p')}")Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.