Пример #1
0
def load_haz(force_new_hdf5_generation, name_haz, name_hdf5_file, input_folder, years):
    """
    Load CLIMADA hazard class from existing hdf5 file
    
    Parameters
    ----------
    force_new_hdf5_generation : dict of bool
        Dict containing which hdf5 should be new generated.
    name_haz : str
        name of hazard ["haz_real", "haz_synth", "haz_dur"]. 
    name_hdf5_file : dict
        names of corresponding hdf5 files.
    input_folder : str
        Path to input folder.
    years : list of str
        years for which data will be loaded.

    Returns
    -------
    haz : climada.hazard.base.Hazard
        CLIMADA hazard.

    """
    my_file = Path(input_folder + "/" + name_hdf5_file[name_haz])
    if force_new_hdf5_generation[name_haz]:
        haz = generate_haz(name_haz, name_hdf5_file, input_folder, years)
    elif my_file.exists():
        haz = Hazard()
        haz.read_hdf5(input_folder + "/" + name_hdf5_file[name_haz])
    else:
        print("{} does not exist and will be generated. Be patient".format(my_file))
        haz = generate_haz(name_haz, name_hdf5_file, input_folder, years)
    return haz
def haz_dem(x_haz=1):
    haz = Hazard()
    haz.read_hdf5(HAZ_DEMO_H5)
    haz.intensity = haz.intensity.multiply(x_haz)
    return haz