galaximview.units module¶
- class galaximview.units.BaseUnitsDefs[source]¶
Bases:
object
Class with basic definitions (values of solar mass, etc in CGS and conversion class methods of CGS to usual astro units. Units variables are taken from Gadget-2.
- CGS_AVOGADRO = 6.0222e+23¶
- CGS_BOLTZMANN = 1.3806e-16¶
- CGS_C = 29979000000.0¶
- CGS_ELECTRONCHARGE = 4.8032e-10¶
- CGS_ELECTRONMASS = 9.10953e-28¶
- CGS_ELECTRONVOLT = 1.602177e-12¶
- CGS_EVONC2MASS = 1.782692e-33¶
- CGS_GAS_CONST = 83142500.0¶
- CGS_GRAVITY = 6.672e-08¶
- CGS_HUBBLE = 3.2407789e-18¶
- CGS_PLANCK = 6.6262e-27¶
- CGS_PROTONMASS = 1.6726e-24¶
- CGS_RAD_CONST = 7.565e-15¶
- CGS_SOLAR_LUM = 3.826e+33¶
- CGS_SOLAR_MASS = 1.989e+33¶
- CGS_THOMPSON = 6.65245e-25¶
- CM_PER_MP = 3.085678e+24¶
- CM_PER_PC = 3.085678e+18¶
- GAMMA_MONOATOMIC_GAS = 1.6666666666666667¶
- HYDROGEN_MASS_FRACTION = 0.76¶
- SEC_PER_MEGAYEAR = 31550000000000.0¶
- SEC_PER_YEAR = 31550000.0¶
- classmethod cgs_length_to_kpc(unit_length_in_cgs)[source]¶
Conversion factor from position unit in cgs to kpc.
- Parameters
unit_length_in_cgs (float) – Length unit in cm.
- Returns
Conversion factor.
- Return type
float
- classmethod cgs_mass_to_sunm(unit_mass_in_cgs)[source]¶
Conversion factor from mass unit in cgs to solar mass.
- Parameters
unit_mass_in_cgs (float) – Mass unit in g.
- Returns
Conversion factor.
- Return type
float
- classmethod cgs_surface_density_to_sunm_per_pc2(unit_mass_in_cgs, unit_length_in_cgs)[source]¶
Conversion factor from surface density unit in cgs to solar mass per pc^2.
- Parameters
unit_mass_in_cgs (float) – Mass unit in g.
unit_length_in_cgs (float) – Length unit in cm.
- Returns
Conversion factor.
- Return type
float
- classmethod cgs_time_to_gyr(unit_time_in_cgs)[source]¶
Conversion factor from time unit in cgs to Gyr.
- Parameters
unit_time_in_cgs (float) – Time unit in s.
- Returns
Conversion factor.
- Return type
float
- classmethod cgs_vel_to_kmpers(unit_vel_in_cgs)[source]¶
Conversion factor from velocity unit in cgs to km/s.
- Parameters
unit_vel_in_cgs (float) – Velocity unit in cm/s.
- Returns
Conversion factor.
- Return type
float
- classmethod cgs_volume_density_to_sunm_per_pc3(unit_mass_in_cgs, unit_length_in_cgs)[source]¶
Conversion factor from volume density unit in cgs to solar mass per pc^3.
- Parameters
unit_mass_in_cgs (float) – Mass unit in g.
unit_length_in_cgs (float) – Length unit in cm.
- Returns
Conversion factor.
- Return type
float
- classmethod cgs_volume_nb_density_to_per_pc3(unit_length_in_cgs)[source]¶
Conversion factor from volume number density unit in cgs to per pc^3.
- Parameters
unit_length_in_cgs (float) – Length unit in cm.
- Returns
Conversion factor.
- Return type
float
- classmethod get_conversion_factor_from_string(arrstr, dicunits, conv_type=None)[source]¶
Conversion to usual practical astrophysical units.
- Parameters
arrstr (str) – Member of
listquantities
.dicunits (dict or None) – Dictionary of simulation units. None for no conversion whatever conv_type is set to.
conv_type ({None, ‘astro’, ‘cgs’}) – Type of units conversion.
- Returns
conversion factor
- Return type
float
- static get_dic_of_labels()[source]¶
Labels corresponding to usual quantities and used in plots.
- Returns
Dictionary of labels corresponding to Members of
listquantities
.- Return type
dict
- static get_dic_of_labels_units(conv_type=None)[source]¶
Units to put in labels for usual quantities and used in plots.
- Parameters
conv_type ({None, 'astro', 'cgs'}) – Type of units conversion.
- Returns
Dictionary of units corresponding to Members of
listquantities
.- Return type
dictionary
- classmethod get_label_from_string(arrstr, func_for_label=<function identity_function>, label_of_dispersion=False, conv_type=None)[source]¶
Finds label corresponding to a function func of a usual quantity, with proper unit.
- Parameters
arrstr (str) – Member of
listquantities
.func_for_label (ufunc, optional) – function of array: identity_function (no transformation), np.log, np.log10 or np.sqrt. Defaults to identity_function.
label_of_dispersion (bool, default = ` False`) – True if the label is for a dispersion. (Default value = False)
conv_type ({None, 'astro', 'cgs'}) – Type of units conversion.
- Returns
Label corresponding to member arrstr of cls.listquantities.
- Return type
str
- class galaximview.units.SimCaracs(dirname)[source]¶
Bases:
galaximview.units.BaseUnitsDefs
Gets units and energy diagnostics of Gadget-2 simulation.
- Parameters
dirname (str) – Path to simulation directory.
- dicunits¶
Dictionary with simulations unis, read for parameters-used-values file if Gadget simulation.
- Type
dict
- get_dic_of_component_energy(ntypes=6, time_conv_type=None, energy_conv_type=None)[source]¶
Comp type string amongts: ‘total’, ‘gas’, ‘DM’, ‘disc stars’, ‘bulge stars’, ‘new stars’ and ‘all stars’.
- plot_energy_conservation(ntypes=6, time_conv_type=None)[source]¶
Returns time in Gyr and (E(t)-E(t=0))/E(t=0).
- galaximview.units.dic_unity_gravity_const_units()[source]¶
Returns a dictionary of set of units so that the gravtational constant is 1.
- Returns
Set of units so that the gravtational constant is 1.
- Return type
dict
- galaximview.units.dic_usual_gadget2_units()[source]¶
Returns a dictionary of usual units used by Gadget-2.
- Returns
Usual units used by Gadget-2.
- Return type
dict