Tools for the simulation and analysis of circadian rhythms
Project description
Circadian
Install
pip install circadian
Quick start
The below shows how to simulate a shift worker schedule for three models and make an actogram plot
from circadian.plots import Actogram
from circadian.models import *
from circadian.lights import Light
import matplotlib.pyplot as plt
import numpy as np
days_night = 3
days_day = 2
slam_shift = Light.ShiftWorkLight(lux = 300.0,
dayson=days_night,
daysoff=days_day)
ts = np.arange(0, 24*30,0.10)
light_values = slam_shift(ts, repeat_period=24*(days_night+days_day))
model = Forger99Model()
spm_model = Hannay19()
tpm_model = Hannay19TP()
initial_conditions_forger = model.initial_conditions_loop(ts, light_est=light_values, num_loops=1)
initial_conditions_spm = spm_model.initial_conditions_loop(ts, light_est=light_values, num_loops=1)
initial_conditions_tpm = tpm_model.initial_conditions_loop(ts, light_est=light_values, num_loops=1)
Integrate the models using a explicit RK4 scheme
trajectory = model(ts=ts, light_est=light_values, state = initial_conditions_forger)
trajectory_spm = spm_model(ts=ts, light_est=light_values, state = initial_conditions_spm)
trajectory_tpm = tpm_model(ts=ts, light_est=light_values, state = initial_conditions_tpm)
Find the dlmos (Dim Light Melatonin Onset) a experimental measurement of circadian phase
dlmo = model.dlmos(trajectory)
dlmo_spm = spm_model.dlmos(trajectory_spm)
dlmo_tpm = tpm_model.dlmos(trajectory_tpm)
Now let’s make an actogram plot of the light schedule with the DLMOs shown for the simulated shiftworker
acto = Actogram(ts, light_vals=light_values, opacity=1.0, smooth=False)
acto.plot_phasemarker(dlmo, color='blue', label= "DLMO Forger99")
acto.plot_phasemarker(dlmo_spm, color='darkgreen', label = "DLMO SPM")
acto.plot_phasemarker(dlmo_tpm, color='red', label = "DLMO TPM" )
plt.title("Actogram for a Simulated Shift Worker")
plt.tight_layout()
plt.show()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
circadian-0.0.3.tar.gz
(36.6 kB
view hashes)
Built Distribution
circadian-0.0.3-py3-none-any.whl
(38.0 kB
view hashes)
Close
Hashes for circadian-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebed8c4b3860a6719c66280b18506a56b14f8241cabcb190b3e966f69b068942 |
|
MD5 | bb7907332a4d1a72c3701e0e3c7f9fef |
|
BLAKE2b-256 | 88ae93c7693f05828a68da696aa32161a1a4acc670a88b3fe589713877e67284 |