예제 #1
0
from sys import argv
from sys import stdout
from sys import stderr
import logging

from nbodykit.utils.pluginargparse import PluginArgumentParser
from nbodykit import plugins
import h5py

parser = PluginArgumentParser(None,
        loader=plugins.load,
        description=
     """ 
        Finding subhalos from FOF groups. This is a variant of FOF6D.
     """,
        epilog=
     """
        This script is written by Yu Feng, as part of `nbodykit'. 
     """
        )

parser.add_argument("datasource", type=plugins.DataSource.open,
        help='Data source')
parser.add_argument("halolabel", 
        help='basename of the halo label files, only nbodykit format is supported in this script')

parser.add_argument("linklength", type=float,
        help='Linking length of subhalos, in units of mean particle seperation')

parser.add_argument("vfactor", type=float, default=0.368,
        help='velocity linking length in units of 1d velocity dispersion.')
예제 #2
0
파일: fof.py 프로젝트: DonRegan/nbodykit
from sys import argv
from sys import stdout
from sys import stderr
import logging

from nbodykit.utils.pluginargparse import PluginArgumentParser
from nbodykit import plugins
import numpy
import h5py

parser = PluginArgumentParser(
    None,
    loader=plugins.load,
    description="""
        Find friend of friend groups from a Nbody simulation snapshot
        """,
    epilog="""
        This script is written by Yu Feng, as part of `nbodykit'. 
        """,
)

h = "Data source to read particle position:\n\n"
parser.add_argument("datasource", type=plugins.DataSource.open, help=h + plugins.DataSource.format_help())
parser.add_argument("LinkingLength", type=float, help="LinkingLength in mean separation (0.2)")
parser.add_argument("output", help="output file; output.grp.N and output.halo are written")
parser.add_argument("--nmin", type=float, default=32, help="minimum number of particles in a halo")

ns = parser.parse_args()
logging.basicConfig(level=logging.DEBUG)

from mpi4py import MPI
예제 #3
0
from sys import argv
from sys import stdout
from sys import stderr
import logging

from nbodykit.utils.pluginargparse import PluginArgumentParser
from nbodykit import plugins
import h5py

parser = PluginArgumentParser(None,
        loader=plugins.load,
        description=
     """This script trace particles in halo at datasource_tf by ID
        find their positions datasource_ti, then compute FOF group
        properties at datasource_ti and save it to a file.
     """,
        epilog=
     """
        This script is written by Yu Feng, as part of `nbodykit'. 
     """
        )

parser.add_argument("datasource_ti", type=plugins.DataSource.open,
        help=plugins.DataSource.format_help())
parser.add_argument("datasource_tf", type=plugins.DataSource.open,
        help=plugins.DataSource.format_help())
parser.add_argument("halolabel", 
        help='basename of the halo label files, only nbodykit format is supported in this script')
parser.add_argument("output", help='write output to this file (hdf5 is appended)')

ns = parser.parse_args()
예제 #4
0
파일: power.py 프로젝트: DonRegan/nbodykit
def initialize_power_parser(**kwargs):
    """
    Initialize the command-line parser for ``power.py``, 
    optionally providing``args`` to be passed to the
    initializing (for, i.e., the case when this is called
    not from the command line)
    
    Parameters
    ----------
    kwargs : 
        keyword arguments to pass to the `PluginArgumentParser` class
    """
    parser = PluginArgumentParser("Parallel Power Spectrum Calculator",
            loader=plugins.load,
            description=
         """Calculating matter power spectrum from RunPB input files. 
            Output is written to stdout, in Mpc/h units. 
            PowerSpectrum is the true one, without (2 pi) ** 3 factor. (differ from Gadget/NGenIC internal)
            This script moves all particles to the halo center.
         """,
            epilog=
         """
            This script is written by Yu Feng, as part of `nbodykit'. 
            Other contributors are: Nick Hand, Man-yat Chu
            The author would like thank Marcel Schmittfull for the explanation on cic, shotnoise, and k==0 plane errors.
         """,
            **kwargs
         )

    # add the positional arguments
    parser.add_argument("mode", choices=["2d", "1d"]) 
    parser.add_argument("Nmesh", type=int, help='size of calculation mesh, recommend 2 * Ngrid')
    parser.add_argument("output", help='write power to this file. set as `-` for stdout') 

    # add the input field types
    h = "one or two input fields, specified as:\n\n"
    parser.add_argument("inputs", nargs="+", type=plugins.DataSource.open, 
                        help=h+plugins.DataSource.format_help())

    # add the optional arguments
    parser.add_argument("--bunchsize", type=int, default=1024*1024*4,
        help='Number of particles to read per rank. A larger number usually means faster IO, but less memory for the FFT mesh. This is not respected by some data sources.')
    parser.add_argument("--binshift", type=float, default=0.0,
            help='Shift the bin center by this fraction of the bin width. Default is 0.0. Marcel uses 0.5. this shall rarely be changed.' )
    parser.add_argument("--remove-cic", default='anisotropic', choices=["anisotropic","isotropic", "none"],
            help='deconvolve cic, anisotropic is the proper way, see http://www.personal.psu.edu/duj13/dissertation/djeong_diss.pdf')
    parser.add_argument("--remove-shotnoise", action='store_true', default=False,
            help='Remove shotnoise')
    parser.add_argument("--Nmu", type=int, default=5,
            help='the number of mu bins to use; if `mode = 1d`, then `Nmu` is set to 1' )
    parser.add_argument("--los", choices="xyz", default='z',
            help="the line-of-sight direction, which the angle `mu` is defined with respect to")
    parser.add_argument("--dk", type=float,
            help='the spacing of k bins to use; if not provided, the fundamental mode of the box is used')
    parser.add_argument("--kmin", type=float, default=0,
            help='the edge of the first bin to use; default is 0')
    parser.add_argument('-q', '--quiet', help="silence the logging output",
            action="store_const", dest="log_level", const=logging.ERROR, default=logging.DEBUG)
    parser.add_argument('--poles', type=lambda s: map(int, s.split()), default=[],
            help='if specified, compute these multipoles from P(k,mu), saving to `pole_output`')
    parser.add_argument('--pole_output', type=str, help='the name of the output file for multipoles')
    
    return parser