def set_sigma(cfg, msh):
    """ Set sigmax and sigmaz for PMLs. """
    try:
        cfg.sigmax = float(cfg.sigmax)
    except ValueError:
        D = msh.x[msh.Npml] - msh.x[0]
        cfg.sigmax = 8 * cfg.c0 * (cfg.alpha + 1) / D
    try:
        cfg.sigmaz = float(cfg.sigmaz)
    except ValueError:
        D = msh.z[msh.Npml] - msh.z[0]
        cfg.sigmaz = 8 * cfg.c0 * (cfg.alpha + 1) / D
