How to use the pynbody.util.skip_fortran function in pynbody

To help you get started, we’ve selected a few pynbody examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pynbody / pynbody / pynbody / snapshot / ramses.py View on Github external
def _cpui_level_iterator(cpu, amr_filename, bisection_order, maxlevel, ndim):
    f = open(amr_filename, 'rb')
    header = read_fortran_series(f, ramses_amr_header)
    skip_fortran(f, 13)

    n_per_level = read_fortran(f, _int_type, header[
                               'nlevelmax'] * header['ncpu']).reshape((header['nlevelmax'], header['ncpu']))
    skip_fortran(f, 1)
    if header['nboundary'] > 0:
        skip_fortran(f, 2)
        n_per_level_boundary = read_fortran(f, _int_type, header[
                                            'nlevelmax'] * header['nboundary']).reshape((header['nlevelmax'], header['nboundary']))

    skip_fortran(f, 2)
    if bisection_order:
        skip_fortran(f, 5)
    else:
        skip_fortran(f, 1)
    skip_fortran(f, 3)

    offset = np.array(header['ng'], dtype='f8') / 2
    offset -= 0.5

    coords = np.zeros(3, dtype=_float_type)

    for level in xrange(maxlevel or header['nlevelmax']):

        # loop through those CPUs with grid data (includes ghost regions)
        for cpuf in 1 + np.where(n_per_level[level, :] != 0)[0]:
            # print "CPU=",cpu,"CPU on
            # disk=",cpuf,"npl=",n_per_level[level,cpuf-1]
github pynbody / pynbody / pynbody / snapshot / ramses.py View on Github external
offset = np.array(header['ng'], dtype='f8') / 2
    offset -= 0.5

    coords = np.zeros(3, dtype=_float_type)

    for level in xrange(maxlevel or header['nlevelmax']):

        # loop through those CPUs with grid data (includes ghost regions)
        for cpuf in 1 + np.where(n_per_level[level, :] != 0)[0]:
            # print "CPU=",cpu,"CPU on
            # disk=",cpuf,"npl=",n_per_level[level,cpuf-1]

            if cpuf == cpu:

                # this is the data we want
                skip_fortran(f, 3)  # grid, next, prev index

                # store the coordinates in temporary arrays. We only want
                # to copy it if the cell is not refined
                coords = [
                    read_fortran(f, _float_type, n_per_level[level, cpu - 1]) for ar in range(ndim)]

                # stick on zeros if we're in less than 3D
                coords += [np.zeros_like(coords[0]) for ar in range(3 - ndim)]

                skip_fortran(f, 1  # father index
                             + 2 * ndim  # nbor index
                             # son index,cpumap,refinement map
                             + 2 * (2 ** ndim)
                             )

                refine = np.array(
github pynbody / pynbody / pynbody / snapshot / ramses.py View on Github external
# disk=",cpuf,"npl=",n_per_level[level,cpuf-1]

            if cpuf == cpu:

                # this is the data we want
                skip_fortran(f, 3)  # grid, next, prev index

                # store the coordinates in temporary arrays. We only want
                # to copy it if the cell is not refined
                coords = [
                    read_fortran(f, _float_type, n_per_level[level, cpu - 1]) for ar in range(ndim)]

                # stick on zeros if we're in less than 3D
                coords += [np.zeros_like(coords[0]) for ar in range(3 - ndim)]

                skip_fortran(f, 1  # father index
                             + 2 * ndim  # nbor index
                             # son index,cpumap,refinement map
                             + 2 * (2 ** ndim)
                             )

                refine = np.array(
                    [read_fortran(f, _int_type, n_per_level[level, cpu - 1]) for i in xrange(2 ** ndim)])

                if level == maxlevel:
                    refine[:] = 0

                coords[0] -= offset[0]
                coords[1] -= offset[1]
                coords[2] -= offset[2]
                # x0-=offset[0]; y0-=offset[1]; z0-=offset[2]
github pynbody / pynbody / pynbody / snapshot / ramses.py View on Github external
header = read_fortran_series(f, ramses_amr_header)
    skip_fortran(f, 13)

    n_per_level = read_fortran(f, _int_type, header[
                               'nlevelmax'] * header['ncpu']).reshape((header['nlevelmax'], header['ncpu']))
    skip_fortran(f, 1)
    if header['nboundary'] > 0:
        skip_fortran(f, 2)
        n_per_level_boundary = read_fortran(f, _int_type, header[
                                            'nlevelmax'] * header['nboundary']).reshape((header['nlevelmax'], header['nboundary']))

    skip_fortran(f, 2)
    if bisection_order:
        skip_fortran(f, 5)
    else:
        skip_fortran(f, 1)
    skip_fortran(f, 3)

    offset = np.array(header['ng'], dtype='f8') / 2
    offset -= 0.5

    coords = np.zeros(3, dtype=_float_type)

    for level in xrange(maxlevel or header['nlevelmax']):

        # loop through those CPUs with grid data (includes ghost regions)
        for cpuf in 1 + np.where(n_per_level[level, :] != 0)[0]:
            # print "CPU=",cpu,"CPU on
            # disk=",cpuf,"npl=",n_per_level[level,cpuf-1]

            if cpuf == cpu:
github pynbody / pynbody / pynbody / snapshot / ramses.py View on Github external
def _cpui_level_iterator(cpu, amr_filename, bisection_order, maxlevel, ndim):
    f = open(amr_filename, 'rb')
    header = read_fortran_series(f, ramses_amr_header)
    skip_fortran(f, 13)

    n_per_level = read_fortran(f, _int_type, header[
                               'nlevelmax'] * header['ncpu']).reshape((header['nlevelmax'], header['ncpu']))
    skip_fortran(f, 1)
    if header['nboundary'] > 0:
        skip_fortran(f, 2)
        n_per_level_boundary = read_fortran(f, _int_type, header[
                                            'nlevelmax'] * header['nboundary']).reshape((header['nlevelmax'], header['nboundary']))

    skip_fortran(f, 2)
    if bisection_order:
        skip_fortran(f, 5)
    else:
        skip_fortran(f, 1)
    skip_fortran(f, 3)
github pynbody / pynbody / pynbody / snapshot / ramses.py View on Github external
def _cpui_level_iterator(cpu, amr_filename, bisection_order, maxlevel, ndim):
    f = open(amr_filename, 'rb')
    header = read_fortran_series(f, ramses_amr_header)
    skip_fortran(f, 13)

    n_per_level = read_fortran(f, _int_type, header[
                               'nlevelmax'] * header['ncpu']).reshape((header['nlevelmax'], header['ncpu']))
    skip_fortran(f, 1)
    if header['nboundary'] > 0:
        skip_fortran(f, 2)
        n_per_level_boundary = read_fortran(f, _int_type, header[
                                            'nlevelmax'] * header['nboundary']).reshape((header['nlevelmax'], header['nboundary']))

    skip_fortran(f, 2)
    if bisection_order:
        skip_fortran(f, 5)
    else:
        skip_fortran(f, 1)
    skip_fortran(f, 3)

    offset = np.array(header['ng'], dtype='f8') / 2
    offset -= 0.5

    coords = np.zeros(3, dtype=_float_type)
github pynbody / pynbody / pynbody / snapshot / ramses.py View on Github external
skip_fortran(f, 13)

    n_per_level = read_fortran(f, _int_type, header[
                               'nlevelmax'] * header['ncpu']).reshape((header['nlevelmax'], header['ncpu']))
    skip_fortran(f, 1)
    if header['nboundary'] > 0:
        skip_fortran(f, 2)
        n_per_level_boundary = read_fortran(f, _int_type, header[
                                            'nlevelmax'] * header['nboundary']).reshape((header['nlevelmax'], header['nboundary']))

    skip_fortran(f, 2)
    if bisection_order:
        skip_fortran(f, 5)
    else:
        skip_fortran(f, 1)
    skip_fortran(f, 3)

    offset = np.array(header['ng'], dtype='f8') / 2
    offset -= 0.5

    coords = np.zeros(3, dtype=_float_type)

    for level in xrange(maxlevel or header['nlevelmax']):

        # loop through those CPUs with grid data (includes ghost regions)
        for cpuf in 1 + np.where(n_per_level[level, :] != 0)[0]:
            # print "CPU=",cpu,"CPU on
            # disk=",cpuf,"npl=",n_per_level[level,cpuf-1]

            if cpuf == cpu:

                # this is the data we want