Spaces:
Running
Running
Commit History
-
Time in hr, min and second option more ôver stepsize - Follow Up Deployment
Verified signature6f867d4 -
develop an app based on the data provided "import numpy as np import pandas as pd import matplotlib.pyplot as plt from scipy.constants import N_A # Avogadro's number # Parameters initial_cells = 1e4 # Initial T-cell count growth_rate = 0.15 # per hour (0.15 hr⁻¹) blood_volume = 5 # in liters noise_level = 0.05 # 5% multiplicative noise step_size_seconds = 300 # 5-minute intervals (300 seconds) # Time grid in seconds (0 to 24 hours + 1 step) time_seconds = np.arange(0, 24*3600 + step_size_seconds, step_size_seconds) time_hours = time_seconds / 3600 # Convert to hours for plotting # Exponential growth model (per-second rate) growth_rate_per_second = growth_rate / 3600 # Convert hr⁻¹ to s⁻¹ ideal_counts = initial_cells * np.exp(growth_rate_per_second * time_seconds) # Add realistic log-normal noise (multiplicative) noise = np.random.lognormal(mean=0, sigma=noise_level, size=len(time_seconds)) noisy_counts = ideal_counts * noise # Convert cell counts to molar concentration molar_ideal = ideal_counts / (N_A * blood_volume) # cells → mol/L molar_noisy = noisy_counts / (N_A * blood_volume) # Create dataframe with all computed values df = pd.DataFrame({ 'time_seconds': time_seconds, 'time_hours': time_hours, 'ideal_cell_count': ideal_counts, 'noisy_cell_count': noisy_counts, 'molar_ideal': molar_ideal, 'molar_noisy': molar_noisy }) # Visualization fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(12, 8)) # Linear-scale plot ax1.plot(time_seconds, molar_ideal, 'b--', label='Ideal Growth') ax1.plot(time_seconds, molar_noisy, 'r-', alpha=0.7, label='Noisy Measurements') ax1.set_xlabel('Time (seconds)') ax1.set_ylabel('Molar Concentration (M)') ax1.set_title('T-cell Concentration (Linear Scale)') ax1.legend() ax1.grid(True) # Log-scale plot ax2.semilogy(time_seconds, molar_ideal, 'b--', label='Ideal Growth') ax2.semilogy(time_seconds, molar_noisy, 'r-', alpha=0.7, label='Noisy Measurements') ax2.set_xlabel('Time (seconds)') ax2.set_ylabel('Molar Concentration (M)') ax2.set_title('T-cell Concentration (Log Scale)') ax2.legend() ax2.grid(True, which="both", ls="--") plt.tight_layout() plt.show()" - Initial Deployment
Verified signature0395d46 -
initial commit
Verified signaturedb354da