mirror of
https://github.com/Richard-Sti/csiborgtools.git
synced 2024-12-23 06:28:01 +00:00
39b3498621
* Minor typos * fix minor bugs * pep8 * formatting * pep8 * Fix minor bugs * New path & pep8 * add splitt * Updates * Improve calculation within radius * pep8 * pep8 * get the script working * Add matter overdensity * Add m200m to the script * Fix looping bug * add parents support * add import * Optionally concatenate velocities * Make optional masking * Ignore the error message * Start reading in raw data * Fix cat reading * Additional units conversions * Add clump reading * Fix indexing * Remove old comment * Remove old comment * set npart to 0 instead of overflow from NaN * fix docs * rm boring stuff * Remove old stuff * Remove old stuff * Remove old comment * Update nb
43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
# Copyright (C) 2022 Richard Stiskalek, Deaglan Bartlett
|
|
# This program is free software; you can redistribute it and/or modify it
|
|
# under the terms of the GNU General Public License as published by the
|
|
# Free Software Foundation; either version 3 of the License, or (at your
|
|
# option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful, but
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
# Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License along
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
"""Fitting utility functions."""
|
|
|
|
import numpy
|
|
|
|
|
|
def split_jobs(njobs, ncpu):
|
|
"""
|
|
Split `njobs` amongst `ncpu`.
|
|
|
|
Parameters
|
|
----------
|
|
njobs : int
|
|
Number of jobs.
|
|
ncpu : int
|
|
Number of CPUs.
|
|
|
|
Returns
|
|
-------
|
|
jobs : list of lists of integers
|
|
Outer list of each CPU and inner lists for CPU's jobs.
|
|
"""
|
|
njobs_per_cpu, njobs_remainder = divmod(njobs, ncpu)
|
|
jobs = numpy.arange(njobs_per_cpu * ncpu).reshape((njobs_per_cpu, ncpu)).T
|
|
|
|
jobs = jobs.tolist()
|
|
for i in range(njobs_remainder):
|
|
jobs[i].append(njobs_per_cpu * ncpu + i)
|
|
|
|
return jobs
|