Skip to content

Commit

Permalink
Started improving the structure of printed output, added print_sectio…
Browse files Browse the repository at this point in the history
…n function in core_util, print multiprocessing status in SpeciesInit, fixed issue with leg_param in plot_spectrum, added verbose parameter to get_median_sample, get_probably_sample, and get_compare_sample
  • Loading branch information
tomasstolker committed Feb 13, 2024
1 parent 093df1d commit ed70768
Show file tree
Hide file tree
Showing 13 changed files with 333 additions and 170 deletions.
8 changes: 8 additions & 0 deletions docs/species.util.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ species.util.convert\_util module
:undoc-members:
:show-inheritance:

species.util.core\_util module
------------------------------

.. automodule:: species.util.core_util
:members:
:undoc-members:
:show-inheritance:

species.util.data\_util module
------------------------------

Expand Down
26 changes: 16 additions & 10 deletions species/core/species_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import urllib.request

from configparser import ConfigParser
from importlib.util import find_spec
from typeguard import typechecked

import h5py
Expand Down Expand Up @@ -124,7 +125,7 @@ def __init__(self) -> None:
file_obj.write("\n; Magnitude of Vega for all filters\n")
file_obj.write("vega_mag = 0.03\n")

print("Configuration settings:")
print("\nConfiguration settings:")
print(f" - Database: {database_file}")
print(f" - Data folder: {data_folder}")
print(f" - Interpolation method: {interp_method}")
Expand All @@ -141,12 +142,17 @@ def __init__(self) -> None:
os.makedirs(data_folder)
print(" [DONE]")

# warnings.warn(
# "Importing the species package had become slow "
# "because of the many classes and functions that "
# "were implicitly imported. The initialization of "
# "the packages has therefore been adjusted. In "
# "the latest version, any functionalities should "
# "be explicitly imported from the modules that "
# "they are part of."
# )
if find_spec("mpi4py") is None:
print("\nMultiprocessing: mpi4py not installed")

else:
from mpi4py import MPI

# Rank of this process in a communicator
mpi_rank = MPI.COMM_WORLD.Get_rank()

# Number of processes in a communicator
mpi_size = MPI.COMM_WORLD.Get_size()

print("\nMultiprocessing: mpi4py installed")
print(f"Process number {mpi_rank+1:d} out of {mpi_size:d}...")
4 changes: 4 additions & 0 deletions species/data/companion_data/companion_spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

from typeguard import typechecked

from species.util.core_util import print_section


@typechecked
def companion_spectra(
Expand Down Expand Up @@ -48,6 +50,8 @@ def companion_spectra(
comp_spec = json.load(json_file)

if comp_name in comp_spec:
print_section("Get companion spectra")

data_folder = os.path.join(input_path, "companion_data/")

if not os.path.exists(data_folder):
Expand Down
Loading

1 comment on commit ed70768

@gabrielastro
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • About Process number {mpi_rank+1:d} out of {mpi_size:d}: maybe users expect mpi_rank to be zero-indexed → "Process (one-indexed) {mpi_rank…" 😉?
  • In case someone wants to deactivate mpi4py (e.g. because it is not yet working on the cluster) without actually uninstalling it, it might be good to point out the clean trick:
import sys as sys
sys.modules['mpi4py'] = None

which apparently is not so well known.

Please sign in to comment.