Example #1
0
def main(numIteration):
    """
    Calculates the time to run iterations of the benchmark.

    Parameters
    ----------
    numIteration: int
    
    Returns
    -------
    float: time in seconds
    """
    logger = logs.Logger(logLevel=logs.LEVEL_MAX, logPerformance=IS_TEST)
    fitter = ModelFitter(MODEL, BENCHMARK_PATH,
          ["k1", "k2"], selectedColumns=['S1', 'S3'], isPlot=IS_PLOT,
          logger=logger)
    fitter.fitModel()
    startTime = time.time()
    fitter.bootstrap(numIteration=numIteration, reportInterval=numIteration)
    elapsedTime = time.time() - startTime
    if IS_TEST:
        print(fitter.logger.formatPerformanceDF())
    fitter.plotFitAll()
    return elapsedTime
Example #2
0
# time in days since volunteer exposure
# each line in the array is an individual volunteer

#SARS_CoV2_sputum.csv and SARS_CoV2_nasal.csv
# SARS-CoV-2 data - 9 patients,
# for each patient - viral loads from lungs (sputum) and from nasal cavity (swab)
# viral levels in log10(RNA copies / ml sputum), ...
# respectively log10(RNA copies / nasal swab)
# time in days since symptoms onset
# corresponding lines in the two arrays belong to an individual patient

#SARS.csv
# SARS data recorded from 12 patients;
# included them just for comparison, probably too few datapoints for model inference
# viral levels in log10(RNA copies / ml of nasopharingeal aspirate)
# time - only three samples per patient, at 5, 10 and 15 days post symptoms onset

# Fit parameters to ts1
from SBstoat.modelFitter import ModelFitter
fitter = ModelFitter(ANTIMONY_MODEL, "Influenza-1.txt",
                     ["beta", "kappa", "delta", "p", "c"])
fitter.fitModel()
print(fitter.reportFit())

fitter.plotFitAll(numRow=2, numCol=2)
fitter.plotResiduals(numRow=2, numCol=2)

# Get estimates of parameters
fitter.bootstrap(numIteration=2000, reportInterval=500)
print(fitter.getFittedParameterStds())