Tools for the simulation and analysis of circadian rhythms
Project description
Circadian
true
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))
f_model = Forger99Model()
spm_model = Hannay19()
tpm_model = Hannay19TP()
kj_model = KronauerJewett()
initial_conditions_forger = f_model.initial_conditions_loop(ts, light_est=light_values, num_loops=1)
initial_conditions_kj = kj_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 = f_model(ts=ts, light_est=light_values, state = initial_conditions_forger)
trajectory_kj = kj_model(ts=ts, light_est=light_values, state = initial_conditions_kj)
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_f = f_model.dlmos(trajectory)
dlmo_kj = kj_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_f, 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" )
acto.plot_phasemarker(dlmo_kj, color='purple', 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.4.tar.gz
(40.6 kB
view hashes)
Built Distribution
circadian-0.0.4-py3-none-any.whl
(42.4 kB
view hashes)
Close
Hashes for circadian-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b21b0b049d8c6b47662739b2d4a3dabc59ae812f0d015d7492a5e30d618df3d3 |
|
MD5 | e0af0e5635a0a023cc19bba62a86eacb |
|
BLAKE2b-256 | 2855f9bdde9baa46a9095afbe08f0427a2c70cc63416b2d21e1bb9484e7322ff |