Skip to content

disease.py

disease

This class stores the attributes that characterize a disease and the methods for its initialization.

Attributes:

Name Type Description
given_parameters dict
parameters dict
initOk np.ndarray
simOk bool
random_seed int
randgencom Generator

gen_inf_prob(self, parameters)

Generates infection probability for all particles in a given distribution

Parameters:

Name Type Description Default
parameters dict

Initialization parameters for the simulation

required

Returns:

Type Description
np.array

Infection probability array

Source code in comorbuss/disease.py
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
def gen_inf_prob(self, parameters):
    """Generates infection probability for all particles in a given distribution

    Args:
        parameters (dict): Initialization parameters for the simulation

    Returns:
        np.array: Infection probability array
    """
    inf_prob = parameters["inf_probability"]
    if not type(inf_prob) is dict:
        return inf_prob * np.ones(self.Nparticles)
    else:
        randgen = default_rng(parameters["random_seed"])
        dist = inf_prob["distribution"]
        kwargs = inf_prob["arguments"]
        dt = inf_prob["multiplicative_constant"]
        inf_prob = np.ones([parameters["Nparticles"]])
        if kwargs == "":
            eval_string = "randgen." + dist + "(size=n)"
        else:
            eval_string = "randgen." + dist + "(" + kwargs + ",size=n)"
        c = 0
        while np.max(inf_prob) >= 1:
            mask_ones_or_greater = inf_prob >= 1
            n = np.sum(mask_ones_or_greater)
            inf_prob[mask_ones_or_greater] = eval(eval_string)
            c += 1
            if c > 1000:
                self.event_log(
                    "Couldn't get all probabilities below 1 in 1000 tries with given distribution",
                    S.MSG_ERROR,
                )
                self.comm.initOk = False
                break
        return inf_prob * dt

in_threshold(self, array, threshold)

Tests if each element of an array is inside an threshold

Parameters:

Name Type Description Default
array np.ndarray

Array to be evaluated

required
threshold tuple

Limits to be evaluated

required

Returns:

Type Description
np.array

Mask array of the results

Source code in comorbuss/disease.py
491
492
493
494
495
496
497
498
499
500
501
def in_threshold(self, array, threshold):
    """Tests if each element of an array is inside an threshold

    Args:
        array (np.ndarray): Array to be evaluated
        threshold (tuple): Limits to be evaluated

    Returns:
        np.array: Mask array of the results
    """
    return (array > threshold[0]) & (array <= threshold[1])

map_inf_prob_linear(self)

Maps infection probabilities values from viral_load values for the current step using a linear distribution.

Source code in comorbuss/disease.py
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
def map_inf_prob_linear(self):
    """Maps infection probabilities values from viral_load values for the current
    step using a linear distribution.
    """
    mask_lower_th = (
        self.viral_load[self.clk.step, :] <= self.vir_map_th[0]
    )  # Find a mask of particles below minimum infection threshold
    self.inf_probability[
        self.clk.step, mask_lower_th
    ] = 0  # Assign infection probability zero to particles below minimum infection threshold
    mask_higher_th = (
        self.viral_load[self.clk.step, :] >= self.vir_map_th[1]
    )  # Find a mask of particles above maximum infection threshold
    self.inf_probability[
        self.clk.step, mask_higher_th
    ] = (
        self.vir_max_inf_prob
    )  # Assign maximum infection probability to particles below minimum infection threshold
    mask_map_vir = (
        ~mask_lower_th & ~mask_higher_th
    )  # Find a mask of particles inside infection threshold
    self.inf_probability[self.clk.step, mask_map_vir] = self.map_lin(
        self.viral_load[self.clk.step, mask_map_vir]
    )  # Linearly maps an infection probability according to the viral_load value

map_inf_prob_log(self)

Maps infection probabilities values from viral_load values for the current step using a logaritimic distribution.

Source code in comorbuss/disease.py
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
def map_inf_prob_log(self):
    """Maps infection probabilities values from viral_load values for the current
    step using a logaritimic distribution.
    """
    mask_lower_th = (
        self.viral_load[self.clk.step, :] <= self.vir_map_th[0]
    )  # Find a mask of particles below minimum infection threshold
    self.inf_probability[
        self.clk.step, mask_lower_th
    ] = 0  # Assign infection probability zero to particles below minimum infection threshold
    mask_higher_th = (
        self.viral_load[self.clk.step, :] >= self.vir_map_th[1]
    )  # Find a mask of particles above maximum infection threshold
    self.inf_probability[
        self.clk.step, mask_higher_th
    ] = (
        self.vir_max_inf_prob
    )  # Assign maximum infection probability to particles below minimum infection threshold
    mask_map_vir = (
        ~mask_lower_th & ~mask_higher_th
    )  # Find a mask of particles inside infection threshold
    self.inf_probability[self.clk.step, mask_map_vir] = self.map_log(
        self.viral_load[self.clk.step, mask_map_vir]
    )  # Logarithmicaly maps an infection probability according to the viral_load value

map_inf_prob_symptoms(self)

Maps infection probabilities values from symptoms.

Source code in comorbuss/disease.py
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
def map_inf_prob_symptoms(self):
    """Maps infection probabilities values from symptoms."""
    self.mask_asymptomatic = (
        (self.pop.symptoms == S.SYMPT_NO) | (self.pop.symptoms == S.SYMPT_NYET)
    ) & (self.pop.states == S.STATE_I)
    self.mask_symptomatic = self.pop.symptoms == S.SYMPT_YES
    self.mask_severe = self.pop.symptoms == S.SYMPT_SEVERE
    self.inf_probability[self.clk.step, self.mask_asymptomatic] = (
        self.base_inf_probability[self.mask_asymptomatic] / 2
    )
    self.inf_probability[
        self.clk.step, self.mask_symptomatic
    ] = self.base_inf_probability[self.mask_symptomatic]
    self.inf_probability[self.clk.step, self.mask_severe] = (
        self.base_inf_probability[self.mask_severe] * 2
    )

map_viral_load(self, probab, pid)

Maps a random generated number (0..1) to a viral_load value using probabilities to became symptomatic, probability to develop severe symptoms, and asymptomatic, symptomatic and severe symptoms thresholds.

Parameters:

Name Type Description Default
probab float

Randomly generated number

required

Returns:

Type Description
float

Mapped viral_load value

Source code in comorbuss/disease.py
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
def map_viral_load(self, probab, pid):
    """Maps a random generated number (0..1) to a viral_load value using probabilities
    to became symptomatic, probability to develop severe symptoms, and asymptomatic,
    symptomatic and severe symptoms thresholds.

    Args:
        probab (float): Randomly generated number

    Returns:
        float: Mapped viral_load value
    """
    if probab <= (
        1 - self.inf_prob_sympt[pid]
    ):  # If generated number is less then  probability to develop symptoms map viral_load inside asymptomatic threshold
        viral_load = self.vir_th_asymptomatic[0] + (
            self.vir_th_asymptomatic[1] - self.vir_th_asymptomatic[0]
        ) * probab / (1 - self.inf_prob_sympt[pid])
    else:
        viral_load = self.vir_th_asymptomatic[
            1
        ]  # If generated number is grater then the probability to develop symptoms initialize viral_load with asymptomatic higher threshold
        probab = (probab - (1 - self.inf_prob_sympt[pid])) / self.inf_prob_sympt[
            pid
        ]  # Subtract probability of becoming infectious from generated number and resize it with probability complementary
        if probab <= (
            1 - self.inf_severe_sympt_prob[pid]
        ):  # If resized number is less then the probability to develop severe symptoms sum viral_load with mapped number inside symptomatic threshold
            viral_load = viral_load + (
                self.vir_th_symptomatic[1] - self.vir_th_symptomatic[0]
            ) * probab / (1 - self.inf_severe_sympt_prob[pid])
        else:
            viral_load = self.vir_th_symptomatic[
                1
            ]  # If resized number is greater then the probability to develop severe symptoms initialize viral_load with symptomatic higher threshold
            probab = (
                probab - (1 - self.inf_severe_sympt_prob[pid])
            ) / self.inf_severe_sympt_prob[
                pid
            ]  # Subtract and resize number again using probability to develop severe symptoms
            viral_load = (
                viral_load
                + (self.vir_th_severe[1] - self.vir_th_severe[0]) * probab
            )  # And sums resized number mapped to severe threshold to viral_load
    return viral_load

mask_new_infections_prob(possibly_infected, mask_particles, nparticles, inf_probability, inf_susceptibility, plc_weight, probab) staticmethod

Generate a mask newly infected particles using probabilistic mechanics

Parameters:

Name Type Description Default
possibly_infected np.ndarray

Encounters array of Infectious particles with Susceptible particles

required

Returns:

Type Description
np.array

Mask array of successful infections (not treated to filter multiple infection sources)

Source code in comorbuss/disease.py
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
@staticmethod
@njit
def mask_new_infections_prob(
    possibly_infected,
    mask_particles,
    nparticles,
    inf_probability,
    inf_susceptibility,
    plc_weight,
    probab,
):
    """Generate a mask newly infected particles using probabilistic mechanics

    Args:
        possibly_infected (np.ndarray): Encounters array of Infectious particles with Susceptible particles

    Returns:
        np.array: Mask array of successful infections (not treated to filter multiple infection sources)
    """
    weights_row = inf_susceptibility[mask_particles] * plc_weight
    inf_prob_column = inf_probability[mask_particles].reshape((nparticles, 1))
    inf_prob_matrix = weights_row * inf_prob_column
    mask_new_infections = possibly_infected & (
        probab < inf_prob_matrix
    )  # Find a mask of new infection (possibly infected whose associated probability was lower than the probability of been infected)
    return mask_new_infections

mask_new_infections_vir(self, possibly_infected, mask_particles, nparticles)

Generate a mask newly infected particles using virulence mechanics

Parameters:

Name Type Description Default
possibly_infected np.ndarray

Encounters array of Infectious particles with Susceptible particles

required

Returns:

Type Description
np.array

Mask array of successful infections (not treated to filter multiple infection sources)

Source code in comorbuss/disease.py
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
def mask_new_infections_vir(self, possibly_infected, mask_particles, nparticles):
    """Generate a mask newly infected particles using virulence mechanics

    Args:
        possibly_infected (np.ndarray): Encounters array of Infectious particles with
            Susceptible particles

    Returns:
        np.array: Mask array of successful infections (not treated to filter multiple
            infection sources)
    """  # Maps virulence values to infection probability
    mask_new_infections = self.mask_new_infections_prob(
        possibly_infected, mask_particles, nparticles
    )
    new_inf_pids = self.pid[mask_particles][np.any(mask_new_infections, axis=0)]
    self.update_viral_load(
        new_inf_pids
    )  # Updates virulence to newly infected particles
    return mask_new_infections  # Return mask of newly infected particles

mask_to_infectious_new_prob(self, states)

Generate a mask of infectious particles using probabilistic mechanics

Parameters:

Name Type Description Default
states np.ndarray

States array for the current step

required

Returns:

Type Description
np.array

Mask array for the newly infectious particles

Source code in comorbuss/disease.py
629
630
631
632
633
634
635
636
637
638
639
640
641
642
def mask_to_infectious_new_prob(self, states):
    """Generate a mask of infectious particles using probabilistic mechanics

    Args:
        states (np.ndarray): States array for the current step

    Returns:
        np.array: Mask array for the newly infectious particles
    """
    self.mask_exposed = states == S.STATE_E
    self.mask_infected = self.mask_exposed & (
        self.clk.time_since(self.pop.time_exposed) >= self.E_duration
    )
    return self.mask_infected

mask_to_infectious_prob(self, states)

Generate a mask of infectious particles using probabilistic mechanics

Parameters:

Name Type Description Default
states np.ndarray

States array for the current step

required

Returns:

Type Description
np.array

Mask array for the newly infectious particles

Source code in comorbuss/disease.py
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
def mask_to_infectious_prob(self, states):
    """Generate a mask of infectious particles using probabilistic mechanics

    Args:
        states (np.ndarray): States array for the current step

    Returns:
        np.array: Mask array for the newly infectious particles
    """
    self.mask_exposed = (
        states == S.STATE_E
    )  # Find a mask of the particles that are in the incubation period (those infected who are not infectious, ie., who can not trasmit yet)
    probab = self.randgendis.uniform(
        0.0, 1.0, size=self.Nparticles
    )  # Associate a random probability to every particle
    self.mask_infected = self.mask_exposed & (
        probab < self.inf_prob_incubation
    )  # Find a logical mask that is only true for the infected particles in the incubation period whose associated probabilities are lower than the probability of leaving the incubation period
    return self.mask_infected

mask_to_infectious_vir(self, states)

Generate a mask of infectious particles using virulence mechanics

Parameters:

Name Type Description Default
states np.ndarray

States array for the current step

required

Returns:

Type Description
np.array

Mask array for the newly infectious particles

Source code in comorbuss/disease.py
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
def mask_to_infectious_vir(self, states):
    """Generate a mask of infectious particles using virulence mechanics

    Args:
        states (np.ndarray): States array for the current step

    Returns:
        np.array: Mask array for the newly infectious particles
    """
    self.mask_exposed = (
        states == S.STATE_E
    )  # Find a mask (logical indexes) of the particles that were infected
    self.mask_infected = self.mask_exposed & (
        self.viral_load[self.clk.step, :] > self.vir_th_infected
    )  # Find a logical mask that is only true for the infected particles whose is lesser or equal the viral_load threshold to recover
    return self.mask_infected

mask_to_recovered_new_prob(self, states, symptoms)

Generate a mask of recovered particles using probabilistic mechanics

Parameters:

Name Type Description Default
states np.ndarray

States array for the current step

required

Returns:

Type Description
np.array

Mask array for the newly recovered particles

Source code in comorbuss/disease.py
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
def mask_to_recovered_new_prob(self, states, symptoms):
    """Generate a mask of recovered particles using probabilistic mechanics

    Args:
        states (np.ndarray): States array for the current step

    Returns:
        np.array: Mask array for the newly recovered particles
    """
    self.mask_activated = (states == S.STATE_I) & (symptoms != S.SYMPT_NYET)
    self.mask_severe = symptoms == S.SYMPT_SEVERE
    self.mask_recovered = self.mask_activated & (
        self.clk.time_since(self.pop.time_infectious) >= self.I_duration
    )
    self.mask_deceased = (
        self.mask_recovered & self.mask_severe & self.mask_will_decease
    )
    self.mask_recovered[self.mask_deceased] = False
    return self.mask_recovered, self.mask_deceased

mask_to_recovered_prob(self, states, symptoms)

Generate a mask of recovered particles using probabilistic mechanics

Parameters:

Name Type Description Default
states np.ndarray

States array for the current step

required

Returns:

Type Description
np.array

Mask array for the newly recovered particles

Source code in comorbuss/disease.py
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
def mask_to_recovered_prob(self, states, symptoms):
    """Generate a mask of recovered particles using probabilistic mechanics

    Args:
        states (np.ndarray): States array for the current step

    Returns:
        np.array: Mask array for the newly recovered particles
    """
    self.mask_activated = (states == S.STATE_I) & (
        symptoms != S.SYMPT_NYET
    )  # Find a mask (logical indexes) of the particles that were infected
    self.mask_severe = (
        symptoms == S.SYMPT_SEVERE
    )  # Find a mask (logical indexes) of the particles developed severe symptoms
    probab = self.randgendis.uniform(
        0.0, 1.0, size=self.Nparticles
    )  # Associate a random probability to every particle
    self.mask_recovered = self.mask_activated & (
        (~self.mask_severe & (probab < self.inf_prob_recovery))
        | (self.mask_severe & (probab < self.inf_severe_prob_recovery))
    )  # Find a logical mask that is only true for the infected particles whose associated probabilities are lower than the probability of having recovered
    probab = self.randgendis.uniform(
        0.0, 1.0, size=self.Nparticles
    )  # Associate a random probability to every particle
    self.mask_deceased = (
        self.mask_recovered
        & self.mask_severe
        & (probab < self.inf_severe_death_prob)
    )  # Find a logical mask that is only true for the newly recovered particles whose associated probabilities are lower than the probability of dying
    self.mask_recovered[self.mask_deceased] = False
    return self.mask_recovered, self.mask_deceased

mask_to_recovered_vir(self, states, symptoms)

Generate a mask of recovered particles using virulence mechanics

Parameters:

Name Type Description Default
states np.ndarray

States array for the current step

required

Returns:

Type Description
np.array

Mask array for the newly recovered particles

Source code in comorbuss/disease.py
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
def mask_to_recovered_vir(self, states, symptoms):
    """Generate a mask of recovered particles using virulence mechanics

    Args:
        states (np.ndarray): States array for the current step

    Returns:
        np.array: Mask array for the newly recovered particles
    """
    self.mask_infected = (
        states == S.STATE_I
    )  # Find a mask (logical indexes) of the particles that were infected
    self.mask_recovered = self.mask_infected & (
        self.viral_load[self.clk.step, :] <= self.vir_th_recovered
    )  # Find a logical mask that is only true for the infected particles whose is lesser or equal the viral_load threshold to recovered
    probab = self.randgendis.uniform(
        0.0, 1.0, size=self.Nparticles
    )  # Associate a random probability to every particle
    self.mask_severe = (
        symptoms == S.SYMPT_SEVERE
    )  # Find a mask (logical indexes) of the particles developed severe symptoms
    self.mask_deceased = (
        self.mask_recovered
        & self.mask_severe
        & (probab < self.inf_severe_death_prob)
    )  # Find a logical mask that is only true for the newly recovered particles whose associated probabilities are lower than the probability of dying
    self.mask_recovered[self.mask_deceased] = False
    return self.mask_recovered, self.mask_deceased

mask_to_symptoms_new_prob(self, states, symptoms, time_inf)

Generates new symptoms masks using probabilistic mechanics

Parameters:

Name Type Description Default
states np.ndarray

States array for the current step

required
symptoms np.ndarray

States array for the current step

required
time_inf np.ndarray

Array of the time on which each particle became infectious

required
time int

Current time

required

Returns:

Type Description
np.array, np.array, np.array

self.mask_symptomatic, self.mask_asymptomatic, self.mask_severe

Source code in comorbuss/disease.py
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
def mask_to_symptoms_new_prob(self, states, symptoms, time_inf):
    """Generates new symptoms masks using probabilistic mechanics

    Args:
        states (np.ndarray): States array for the current step
        symptoms (np.ndarray): States array for the current step
        time_inf (np.ndarray): Array of the time on which each particle became infectious
        time (int): Current time

    Returns:
        np.array, np.array, np.array: self.mask_symptomatic, self.mask_asymptomatic, self.mask_severe
    """
    self.mask_symptoms_notyet = symptoms == S.SYMPT_NYET
    self.mask_test_symptoms = (
        self.clk.time_since(time_inf) >= self.inf_sympt_timeto
    ) & self.mask_symptoms_notyet
    self.mask_infected = states == S.STATE_I
    self.mask_symptomatic = (
        self.mask_test_symptoms & self.mask_will_have_symptoms & self.mask_infected
    )
    self.mask_asymptomatic = (
        self.mask_test_symptoms & ~self.mask_will_have_symptoms & self.mask_infected
    )
    self.mask_severe = self.mask_symptomatic & self.mask_will_be_severe
    return self.mask_symptomatic, self.mask_asymptomatic, self.mask_severe

mask_to_symptoms_prob(self, states, symptoms, time_inf)

Generates new symptoms masks using probabilistic mechanics

Parameters:

Name Type Description Default
states np.ndarray

States array for the current step

required
symptoms np.ndarray

States array for the current step

required
time_inf np.ndarray

Array of the time on which each particle became infectious

required
time int

Current time

required

Returns:

Type Description
np.array, np.array, np.array

self.mask_symptomatic, self.mask_asymptomatic, self.mask_severe

Source code in comorbuss/disease.py
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
def mask_to_symptoms_prob(self, states, symptoms, time_inf):
    """Generates new symptoms masks using probabilistic mechanics

    Args:
        states (np.ndarray): States array for the current step
        symptoms (np.ndarray): States array for the current step
        time_inf (np.ndarray): Array of the time on which each particle became infectious
        time (int): Current time

    Returns:
        np.array, np.array, np.array: self.mask_symptomatic, self.mask_asymptomatic, self.mask_severe
    """
    self.mask_symptoms_notyet = (
        symptoms == S.SYMPT_NYET
    )  # Find a mask of the particles that are infectious and have not develop symptoms yet
    self.mask_test_symptoms = (
        self.clk.time_since(time_inf) >= self.inf_sympt_timeto
    ) & self.mask_symptoms_notyet  # Find a mask of the particles that are infectious, have not been tested yet AND there has passed enough time for the symptoms to start show
    self.mask_infected = (
        states == S.STATE_I
    )  # Find a mask of the particles that are infectious
    probab = self.randgendis.uniform(
        0.0, 1.0, size=self.Nparticles
    )  # Associate a random probability to every particle
    test = (
        probab < self.inf_prob_sympt
    )  # Find a mask that is only true if the associated probability is lower than the chance of the particle becomes symptomatic
    self.mask_symptomatic = (
        self.mask_test_symptoms & test & self.mask_infected
    )  # Find a mask for the particles that have develop symptoms
    self.mask_asymptomatic = (
        self.mask_test_symptoms & (~test) & self.mask_infected
    )  # Find a mask for the particles that have NOT develop symptoms yet
    probab = self.randgendis.uniform(
        0.0, 1.0, size=self.Nparticles
    )  # Associate a random probability to every particle
    self.mask_severe = self.mask_symptomatic & (
        probab < self.inf_severe_sympt_prob
    )  # Test if every diagnosed particle is a severe case or not
    return self.mask_symptomatic, self.mask_asymptomatic, self.mask_severe

mask_to_symptoms_vir(self, states, symptoms, time_inf)

Generates new symptoms masks using virulence mechanics

Parameters:

Name Type Description Default
states np.ndarray

States array for the current step

required
symptoms np.ndarray

States array for the current step

required
time_inf np.ndarray

Array of the time on which each particle became infectious

required

Returns:

Type Description
np.array, np.array, np.array

self.mask_symptomatic, self.mask_asymptomatic, self.mask_severe

Source code in comorbuss/disease.py
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
def mask_to_symptoms_vir(self, states, symptoms, time_inf):
    """Generates new symptoms masks using virulence mechanics

    Args:
        states (np.ndarray): States array for the current step
        symptoms (np.ndarray): States array for the current step
        time_inf (np.ndarray): Array of the time on which each particle became infectious

    Returns:
        np.array, np.array, np.array: self.mask_symptomatic, self.mask_asymptomatic, self.mask_severe
    """
    self.mask_symptoms_notyet = (
        symptoms == S.SYMPT_NYET
    )  # Find a mask of the particles that are infectious and have not developed symptoms yet
    mask_infectious = states == S.STATE_I
    self.mask_test_symptoms = mask_infectious & self.mask_symptoms_notyet
    self.mask_infected = states == S.STATE_I
    self.mask_symptomatic = (
        self.mask_test_symptoms
        & self.mask_infected
        & self.in_threshold(
            self.viral_load[self.clk.step, :], self.vir_th_symptomatic
        )
    )  # Find a mask for the particles that have develop symptoms
    self.mask_asymptomatic = (
        self.mask_test_symptoms
        & self.mask_infected
        & self.in_threshold(
            self.viral_load[self.clk.step, :], self.vir_th_asymptomatic
        )
    )  # Find a mask for the particles that have will not develop symptoms
    self.mask_severe = (
        self.mask_test_symptoms
        & self.mask_infected
        & self.in_threshold(self.viral_load[self.clk.step, :], self.vir_th_severe)
    )  # Find a mask for the particles that have will develop severe symptoms
    return self.mask_symptomatic, self.mask_asymptomatic, self.mask_severe

update_viral_load(self, new_inf_pids)

Creates viral_load step curves for newly infected particles

Parameters:

Name Type Description Default
new_inf_pids np.ndarray

Array with the pids of newly infected particles

required
Source code in comorbuss/disease.py
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
def update_viral_load(self, new_inf_pids):
    """Creates viral_load step curves for newly infected particles

    Args:
        new_inf_pids (np.ndarray): Array with the pids of newly infected particles
    """
    # Iterate over all newly infected particles
    for i in new_inf_pids:
        # Generate a random number and map it to a viral_load value
        probab = self.randgendis.uniform()
        viral_load = self.map_viral_load(probab, i)
        # Randomly choose times the particle to became infectious to develop symptoms and to recover
        time_to_infectious = int(
            self.clk.step + self.get_inf_incubation(self.inf_incubation)
        )
        # check if particle will develop severe symptoms
        if viral_load > self.vir_th_severe[0]:
            time_to_recovered = int(
                time_to_infectious
                + self.get_inf_severe_duration(self.inf_severe_duration)
            )
        else:
            time_to_recovered = int(
                time_to_infectious + self.get_inf_duration(self.inf_duration)
            )
        time_to_symptoms = int(
            time_to_infectious + self.get_inf_sympt_timeto(self.inf_sympt_timeto)
        )
        # stores the viral load value in the correct spot in the viral_load vector
        if time_to_recovered <= time_to_symptoms:
            self.viral_load[
                time_to_infectious:time_to_recovered, i
            ] = self.vir_th_asymptomatic[0]
        else:
            self.viral_load[
                time_to_infectious:time_to_symptoms, i
            ] = self.vir_th_asymptomatic[0]
            self.viral_load[time_to_symptoms:time_to_recovered, i] = viral_load