Example #1
0
def _set_gamma_from_file(br, filename=None):
    sigmas = br.get_sigmas()
    mesh = br.get_mesh_numbers()
    mesh_divisors = br.get_mesh_divisors()
    grid_points = br.get_grid_points()
    temperatures = br.get_temperatures()
    num_band = br.get_frequencies().shape[1]

    gamma = np.zeros((len(sigmas),
                      len(temperatures),
                      len(grid_points),
                      num_band), dtype='double')
    gamma_iso = np.zeros((len(sigmas),
                          len(grid_points),
                          num_band), dtype='double')
    ave_pp = np.zeros((len(grid_points), num_band), dtype='double')

    is_isotope = False

    for j, sigma in enumerate(sigmas):
        collisions = read_gamma_from_hdf5(
            mesh,
            mesh_divisors=mesh_divisors,
            sigma=sigma,
            filename=filename)
        if collisions is False:
            for i, gp in enumerate(grid_points):
                collisions_gp = read_gamma_from_hdf5(
                    mesh,
                    mesh_divisors=mesh_divisors,
                    grid_point=gp,
                    sigma=sigma,
                    filename=filename)
                if collisions_gp is False:
                    print "Gamma at grid point %d doesn't exist." % gp
                    return False
                else:
                    gamma_gp, gamma_iso_gp, ave_pp_gp = collisions_gp
                    gamma[j, :, i] = gamma_gp
                    if gamma_iso_gp is not None:
                        is_isotope = True
                        gamma_iso[j, i] = gamma_iso_gp
                    if ave_pp_gp is not None:
                        ave_pp[i] = ave_pp_gp
        else:
            gamma_at_sigma, gamma_iso_at_sigma, ave_pp = collisions
            gamma[j] = gamma_at_sigma
            if gamma_iso_at_sigma is not None:
                is_isotope = True
                gamma_iso[j] = gamma_iso_at_sigma
        
    br.set_gamma(gamma)
    if ave_pp is not None:
        br.set_averaged_pp_interaction(ave_pp)

    return True
Example #2
0
def _set_gamma_from_file(br, filename=None):
    sigmas = br.get_sigmas()
    mesh = br.get_mesh_numbers()
    mesh_divisors = br.get_mesh_divisors()
    grid_points = br.get_grid_points()
    temperatures = br.get_temperatures()
    num_band = br.get_frequencies().shape[1]

    gamma = np.zeros(
        (len(sigmas), len(temperatures), len(grid_points), num_band),
        dtype='double')
    gamma_iso = np.zeros((len(sigmas), len(grid_points), num_band),
                         dtype='double')
    is_isotope = False

    for j, sigma in enumerate(sigmas):
        collisions = read_gamma_from_hdf5(mesh,
                                          mesh_divisors=mesh_divisors,
                                          sigma=sigma,
                                          filename=filename)
        if collisions is False:
            for i, gp in enumerate(grid_points):
                collisions_gp = read_gamma_from_hdf5(
                    mesh,
                    mesh_divisors=mesh_divisors,
                    grid_point=gp,
                    sigma=sigma,
                    filename=filename)
                if collisions_gp is False:
                    print "Gamma at grid point %d doesn't exist." % gp
                    return False
                else:
                    gamma_gp, gamma_iso_gp = collisions_gp
                    gamma[j, :, i] = gamma_gp
                    if gamma_iso_gp is not None:
                        is_isotope = True
                        gamma_iso[j, i] = gamma_iso_gp
        else:
            gamma_at_sigma, gamma_iso_at_sigma = collisions
            gamma[j] = gamma_at_sigma
            if gamma_iso_at_sigma is not None:
                is_isotope = True
                gamma_iso[j] = gamma_iso_at_sigma

    br.set_gamma(gamma)
    # if is_isotope:
    #     br.set_gamma_isotope(gamma_iso)

    return True
Example #3
0
def _set_gamma_from_file(br, filename=None, verbose=True):
    sigmas = br.get_sigmas()
    mesh = br.get_mesh_numbers()
    mesh_divisors = br.get_mesh_divisors()
    grid_points = br.get_grid_points()
    temperatures = br.get_temperatures()
    num_band = br.get_frequencies().shape[1]

    gamma = np.zeros(
        (len(sigmas), len(temperatures), len(grid_points), num_band),
        dtype='double')
    gamma_iso = np.zeros((len(sigmas), len(grid_points), num_band),
                         dtype='double')
    ave_pp = np.zeros((len(grid_points), num_band), dtype='double')

    is_isotope = False
    read_succeeded = True

    for j, sigma in enumerate(sigmas):
        collisions = read_gamma_from_hdf5(mesh,
                                          mesh_divisors=mesh_divisors,
                                          sigma=sigma,
                                          filename=filename,
                                          verbose=verbose)
        if collisions:
            gamma_at_sigma, gamma_iso_at_sigma, ave_pp = collisions
            gamma[j] = gamma_at_sigma
            if gamma_iso_at_sigma is not None:
                is_isotope = True
                gamma_iso[j] = gamma_iso_at_sigma
        else:
            for i, gp in enumerate(grid_points):
                collisions_gp = read_gamma_from_hdf5(
                    mesh,
                    mesh_divisors=mesh_divisors,
                    grid_point=gp,
                    sigma=sigma,
                    filename=filename,
                    verbose=verbose)
                if collisions_gp:
                    gamma_gp, gamma_iso_gp, ave_pp_gp = collisions_gp
                    gamma[j, :, i] = gamma_gp
                    if gamma_iso_gp is not None:
                        is_isotope = True
                        gamma_iso[j, i] = gamma_iso_gp
                    if ave_pp_gp is not None:
                        ave_pp[i] = ave_pp_gp
                else:
                    for bi in range(num_band):
                        collisions_band = read_gamma_from_hdf5(
                            mesh,
                            mesh_divisors=mesh_divisors,
                            grid_point=gp,
                            band_index=bi,
                            sigma=sigma,
                            filename=filename,
                            verbose=verbose)
                        if collisions_band:
                            gamma_bi, gamma_iso_bi, ave_pp_bi = collisions_band
                            gamma[j, :, i, bi] = gamma_bi
                            if gamma_iso_bi is not None:
                                is_isotope = True
                                gamma_iso[j, i, bi] = gamma_iso_bi
                            if ave_pp_bi is not None:
                                ave_pp[i, bi] = ave_pp_bi
                        else:
                            read_succeeded = False

    if read_succeeded:
        br.set_gamma(gamma)
        if ave_pp is not None:
            br.set_averaged_pp_interaction(ave_pp)
        return True
    else:
        return False
Example #4
0
def _set_gamma_from_file(br, filename=None, verbose=True):
    sigmas = br.get_sigmas()
    mesh = br.get_mesh_numbers()
    mesh_divisors = br.get_mesh_divisors()
    grid_points = br.get_grid_points()
    temperatures = br.get_temperatures()
    num_band = br.get_frequencies().shape[1]

    gamma = np.zeros((len(sigmas),
                      len(temperatures),
                      len(grid_points),
                      num_band), dtype='double')
    gamma_iso = np.zeros((len(sigmas),
                          len(grid_points),
                          num_band), dtype='double')
    ave_pp = np.zeros((len(grid_points), num_band), dtype='double')

    is_isotope = False
    read_succeeded = True

    for j, sigma in enumerate(sigmas):
        collisions = read_gamma_from_hdf5(
            mesh,
            mesh_divisors=mesh_divisors,
            sigma=sigma,
            filename=filename,
            verbose=verbose)
        if collisions:
            gamma_at_sigma, gamma_iso_at_sigma, ave_pp = collisions
            gamma[j] = gamma_at_sigma
            if gamma_iso_at_sigma is not None:
                is_isotope = True
                gamma_iso[j] = gamma_iso_at_sigma
        else:
            for i, gp in enumerate(grid_points):
                collisions_gp = read_gamma_from_hdf5(
                    mesh,
                    mesh_divisors=mesh_divisors,
                    grid_point=gp,
                    sigma=sigma,
                    filename=filename,
                    verbose=verbose)
                if collisions_gp:
                    gamma_gp, gamma_iso_gp, ave_pp_gp = collisions_gp
                    gamma[j, :, i] = gamma_gp
                    if gamma_iso_gp is not None:
                        is_isotope = True
                        gamma_iso[j, i] = gamma_iso_gp
                    if ave_pp_gp is not None:
                        ave_pp[i] = ave_pp_gp
                else:
                    for bi in range(num_band):
                        collisions_band = read_gamma_from_hdf5(
                            mesh,
                            mesh_divisors=mesh_divisors,
                            grid_point=gp,
                            band_index=bi,
                            sigma=sigma,
                            filename=filename,
                            verbose=verbose)
                        if collisions_band:
                            gamma_bi, gamma_iso_bi, ave_pp_bi = collisions_band
                            gamma[j, :, i, bi] = gamma_bi
                            if gamma_iso_bi is not None:
                                is_isotope = True
                                gamma_iso[j, i, bi] = gamma_iso_bi
                            if ave_pp_bi is not None:
                                ave_pp[i, bi] = ave_pp_bi
                        else:
                            read_succeeded = False

    if read_succeeded:
        br.set_gamma(gamma)
        if ave_pp is not None:
            br.set_averaged_pp_interaction(ave_pp)
        return True
    else:
        return False