.. currentmodule:: pNbody.main .. _messages_and_debugging-label: Messages and debugging ====================== **pNbody** offers different methods to print messages in order to inform or ease debugging. Messages are are method of the ``Nbody`` default class. Each of these messages are triggered by a verbosity level (from 0 to 10) that is defined at the creation of the ``Nbody`` object:: >>> from pNbody import Nbody >>> nb = Nbody("MW_galaxy.hdf5",verbose=1) check_spec_ftype: checking swift format... find_format: The format is swift read_particles: reading header... read_particles: reading units... read_particles: reading particles... At any time, the verbosity level can be changed:: >>> from pNbody import Nbody >>> nb = Nbody("MW_galaxy.hdf5") >>> nb.get_verbosity() 0 >>> nb.set_verbosity(2) >>> nb.get_verbosity() get_verbosity: current verbosity level is 2 2 Verbosity levels ---------------- A message is defined with a verbosity level, i.e., it will be triggered only if the current verbosity is larger than this level. By default the verbosity is 0, i.e, all but error messages are ignored. A verbosity of 10 guarantee that all messages will be printed. If the current verbosity is larger than 4, the message is supplemented with the file name and line where the message has been triggered. **pNbody** offers the following pre-defined methods to print messages. .. list-table:: Main convertion methods :widths: 30 25 25 40 :header-rows: 1 * - method name - default verbosity - color - trigger a crash * - :meth:`nb.message()` - 1 - black - no * - :meth:`nb.warning()` - 1 - red - no * - :meth:`nb.debug()` - 10 - blue - no * - :meth:`nb.error()` - 0 - red - yes The following example shows the messages from a level 10 verbosity:: >>> from pNbody import Nbody >>> nb = Nbody("MW_galaxy.hdf5",verbose=10) find_format ("/local/lib/python3.10/dist-packages/pNbody/main.py", line 407): the format file is not default find_format ("/local/lib/python3.10/dist-packages/pNbody/main.py", line 407): the format file is not gh5 check_spec_ftype ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 619): checking swift format... find_format ("/local/lib/python3.10/dist-packages/pNbody/main.py", line 410): The format is swift read_particles ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 866): reading header... read_particles ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 900): Header BoxSize >> boxsize [1500.32945615] read_particles ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 900): Header Command_line >> command_line [b'/local/bin/gpy MW_galaxy.hdf5'] read_particles ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 900): Header Date >> date [b'Sat Nov 16 17:48:23 2024'] read_particles ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 900): Header Flag_Entropy_ICs >> flag_entr_ics [0] read_particles ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 900): Header GitTag >> gittag [b'40dfb622619fd9e69678c1ffa6dbf6601bc22348'] read_particles ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 900): Header MassTable >> massarr [ 0 0 100000 0 0 0] read_particles ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 900): Header NumFilesPerSnapshot >> num_files [1] read_particles ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 900): Header NumPart_ThisFile >> npart [ 391 17969 0 0 1875 0] read_particles ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 900): Header NumPart_Total >> npart_tot [ 391 17969 0 0 1875 0] read_particles ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 900): Header NumPart_Total_HighWord >> nallhw [0 0 0 0 0 0] read_particles ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 900): Header Redshift >> redshift [0.] read_particles ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 900): Header Scale-factor >> atime [0.] read_particles ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 900): Header UserName >> username [b'revaz'] read_particles ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 900): Cosmology Omega_lambda >> omegalambda [0.] read_particles ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 900): Cosmology Omega_m >> omega0 [0.] read_particles ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 900): Cosmology h >> hubbleparam [0.] read_particles ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 900): Units Unit current in cgs (U_I) >> Unit_current_in_cgs [1.] read_particles ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 900): Units Unit length in cgs (U_L) >> UnitLength_in_cm [3.085e+21] read_particles ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 900): Units Unit mass in cgs (U_M) >> UnitMass_in_g [1.98848e+43] read_particles ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 900): Units Unit temperature in cgs (U_T) >> Unit_temp_in_cgs [1.] read_particles ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 900): Units Unit time in cgs (U_t) >> Unit_time_in_cgs [3.085e+16] read_particles ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 979): reading units... read_particles ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 1009): reading particles... loadFromHDF5 ("/local/lib/python3.10/dist-packages/pNbody/main.py", line 1830): loading pos ptype=0 dtype= dim=3 loadFromHDF5 ("/local/lib/python3.10/dist-packages/pNbody/main.py", line 1830): loading pos ptype=1 dtype= dim=3 loadFromHDF5 ("/local/lib/python3.10/dist-packages/pNbody/main.py", line 1830): loading pos ptype=4 dtype= dim=3 loadFromHDF5 ("/local/lib/python3.10/dist-packages/pNbody/main.py", line 1830): loading vel ptype=0 dtype= dim=3 loadFromHDF5 ("/local/lib/python3.10/dist-packages/pNbody/main.py", line 1830): loading vel ptype=1 dtype= dim=3 loadFromHDF5 ("/local/lib/python3.10/dist-packages/pNbody/main.py", line 1830): loading vel ptype=4 dtype= dim=3 loadFromHDF5 ("/local/lib/python3.10/dist-packages/pNbody/main.py", line 1830): loading mass ptype=0 dtype= dim=1 loadFromHDF5 ("/local/lib/python3.10/dist-packages/pNbody/main.py", line 1830): loading mass ptype=1 dtype= dim=1 loadFromHDF5 ("/local/lib/python3.10/dist-packages/pNbody/main.py", line 1830): loading mass ptype=4 dtype= dim=1 loadFromHDF5 ("/local/lib/python3.10/dist-packages/pNbody/main.py", line 1830): loading num ptype=0 dtype= dim=1 loadFromHDF5 ("/local/lib/python3.10/dist-packages/pNbody/main.py", line 1830): loading num ptype=1 dtype= dim=1 loadFromHDF5 ("/local/lib/python3.10/dist-packages/pNbody/main.py", line 1830): loading num ptype=4 dtype= dim=1 loadFromHDF5 ("/local/lib/python3.10/dist-packages/pNbody/main.py", line 1830): loading rsp_init ptype=0 dtype= dim=1 loadFromHDF5 ("/local/lib/python3.10/dist-packages/pNbody/main.py", line 1830): loading rsp_init ptype=4 dtype= dim=1 loadFromHDF5 ("/local/lib/python3.10/dist-packages/pNbody/main.py", line 1830): loading u_init ptype=0 dtype= dim=1 loadFromHDF5 ("/local/lib/python3.10/dist-packages/pNbody/main.py", line 1830): loading tstar_init ptype=4 dtype= dim=1 loadFromHDF5 ("/local/lib/python3.10/dist-packages/pNbody/main.py", line 1830): loading sp_type ptype=4 dtype= dim=1 read_particles ("/local/lib/python3.10/dist-packages/pNbody/config/formats/swift.py", line 1034): Massarr is not supported! Please specify the mass of all the particles! Methods description ------------------- .. automethod:: Nbody.message .. automethod:: Nbody.warning .. automethod:: Nbody.debug .. automethod:: Nbody.error