Ejemplo n.º 1
0
def run_world(year, cascade, drop_emr=False, reimport=False):
    cl = Cascade_loc(1, 0, year, cascade, timespan=50, reimport=reimport)
    if drop_emr:
        cl.gen_data(1, 0, drop_emr=True)
    cl.run_dismod()
    cl.summarize_posterior()
    cl.draw()
    cl.predict()
    return cascade
Ejemplo n.º 2
0
def run_world(year, cascade, drop_emr=False, reimport=False):
    ''' Instantiates a global cascade_loc object and runs dismod.

    Since we're running dismod, that means this function reads from and writes
    to file system.

    Args:
        year (int): Year to run dismod for
        cascade (drill.cascade): Cascade object of the model_version_id we're
            running dismod for
        drop_emr (bool, False): If True, exclude excess mortality data before
            running dismod
        reimport (bool, False): if True, read input data from database via
            importer.Importer object. If False, rely on cached csv files
            written during a previous cascade instantiation
            (if a file is missing, will automatically read from db)

    Returns:
        cascade object that was passed in

    '''
    log = logging.getLogger(__name__)
    cl = Cascade_loc(1, 0, year, cascade, timespan=50, reimport=reimport)
    if drop_emr:
        cl.gen_data(1, 0, drop_emr=True)

    log.info("Starting dismod for year {} loc {}".format(year, cl.loc))
    cl.run_dismod()
    log.info("dismod finished")
    log.info("summarizing posterior")
    cl.summarize_posterior()
    log.info("summarizing posterior finished")
    log.info("begin draw")
    cl.draw()
    log.info("draw finished")
    log.info("beginning predict")
    cl.predict()
    log.info("predict finished")
    return cascade