Input/output tools

jjmodel.iof.dir_tree(p, **kwargs)[source]

Builds an output directory tree (name suffix of the main output directory can be specified in the parameter file).

Parameters
  • p (namedtuple) -- Set of model parameters from the parameter file.

  • make (boolean) -- Optional. If True, the directory tree is created, otherwise only all the folder names are defined.

Returns

Directory tree for the model output.

Return type

dict

jjmodel.iof.tab_sorter(name, p, T, **kwargs)[source]

Sorts all kinds of the calculated quantities into the output subdirectories.

Parameters
  • name (str) -- Short name of the quantity.

  • p (namedtuple) -- Set of model parameters from the parameter file.

  • T (dict) -- Output directory tree (created by jjmodel.iof.dir_tree()).

  • R (scalar) -- Optional. Galactocentric distance, kpc. Must be specified for the vertical density profiles (name = 'rhoz'), vertical force ('Kz'), contributions of the additional peaks to the thin-disk SFR ('Fp'), and peaks' scale heights ('Hdp').

  • print (boolean) -- Optional. If True, the full list of names is printed.

Returns

Path to the directory where the quantity given by name will be saved as txt table. Or, if print is True, none.

Return type

str or none

jjmodel.iof.tab_reader(names, p, T, **kwargs)[source]

Reads data from the output directory tree.

Parameters
Returns

Data tables.

Return type

list[array-likes]

class jjmodel.iof.TabSaver(p, a, **kwargs)[source]

Sorts and saves calculated quantities into the output subfolders.

__init__(p, a, **kwargs)[source]

Initialization of the class instance.

Parameters
  • p (namedtuple) -- Set of model parameters from the parameter file.

  • a (namedtuple) -- Collection of the fixed model parameters, useful quantities, and arrays.

  • number (boolean) -- Optional. If True, calculated quantity is (or is weighted by) the spatial number density of stars in \(\mathrm{number \ pc^{-3}}\), not matter density in \(\mathrm{M_\odot \ pc^{-3}}\).

  • sigma (boolean) -- Optional. If True, the result is (or is weighted by) surface density in \(\mathrm{M_\odot \ pc^{-2}}\), otherwise the midplane mass density in \(\mathrm{M_\odot \ pc^{-3}}\) is used. In combination with number = True, uses the number surface density in \(\mathrm{number \ pc^{-2}}\).

  • fig (boolean) -- Optional. If True, a plot will be saved. By default, class methods save a table.

  • save_format (str) -- Optional. Format of the figure. Can be used only when fig is True.

  • normalized (boolean) -- Optional. Applicable in case if vertical density profiles will be saved. If True, the profiles are normalized at each height on the total density at this height. Also the file name will start from 'NRhoz' instead of 'Rhoz'.

  • cumulative (boolean) -- Optional. Applicable to density profiles, age and metallicity distributions. If True, the normalized cumulative quantities are saved. In general, 'C' is added in front of a standard file name; in case of density profiles, file will be called 'NCMassz'.

  • mode_pop (str) -- Optional. Name of stellar population. Can be a pre-defined one ('a', 'f', 'ceph', 'rc', 'rc+', 'gdw', 'kdw', 'mdw') or custom (if it was selected and saved as a table in advance). Adds a suffix with the name of population to the standard file name.

  • number -- Optional. If True, this indicates that the quantity to save was calculated with the help of stellar assembly tables (contains stellar number densities or something weighted by them). Usually adds a suffix '(nw)' (stands for 'number-weighted') to the standard file name. Otherwise, the suffix is '(rw)' ('rho', i.e., 'density-weighted').

  • between (boolean) -- Optional. If True, the output quantity corresponds to the age intervals, not to individual single mono-age subpopulations. Applicable to methods with parameter ages. If False, a suffix 'sgl' will be added to the standard file name (stands for 'single-age populations').

  • dz (scalar) -- Optional. Vertical resolution, pc. Applicable to methods which save R-z maps, adds a suffix 'dz' with z in kpc.

  • R (scalar) -- Optional. Galactocentric distance, kpc. Suffix '_R' with the given value of radis is added to the output file name.

  • ages (array-like) -- Set of age bins, Gyr. If specified, a suffix 'age' with the range of ages (or min age, max age, and step) is added to the file name.

  • mets (array-like) -- Set of metallicity bins. If specified, a suffix 'FeH' with the range of metallicities (or min metallicity, max metallicity, and step) is added to the file name.

  • vln (str) -- Optional. A string with information about the volume. Applicable to methods which save Hess diagrams and stellar number densitites corresponding to some volume.

agehist_save(ages, mode, zlim)[source]

Saves age distributions for the different Galactocentric distances to the subfolder a.T['age']. File name base is 'f(age)'.

Parameters
  • ages (array-like) -- Can contain two tables - age distributions for the grid a.R and at p.Rsun, or only a single age distribution for the local volume. Tables contain only age distributions, without the time(age) grid column a.t.

  • mode (str) -- Galactic component, can be 'd', 't', 'sh', 'dt', or 'tot' (thin disk, thick disk, halo, thin+thick disk, or total). Adds suffix '_'+mode to the file name.

  • zlim (array-like) -- Range of heights to be considered, pc. Adds to the file name suffix '_z' with the given heights (converted for shortness into kpc).

Returns

None.

ager_save(profiles, mode, zlim)[source]

Saves radial age profile to the subfolder a.T['age']. File name base is 'Age'.

Parameters
  • profiles (array-like) -- Radial age profiles. Tables contain only age profiles, without the radial grid column a.R.

  • mode (str) -- Galactic component, can be 'd', 't', 'sh', 'dt', or 'tot' (thin disk, thick disk, halo, thin+thick disk, or total). Adds suffix '_'+mode to the file name.

  • zlim (array-like) -- Range of heights to be considered, pc. Adds to the file name suffix '_z' with the given heights (converted for shortness into kpc).

Returns

None.

agez_save(profiles, mode)[source]

Saves vertical age profile to the subfolder a.T['age']. File name base is 'Age'.

Parameters
  • profiles (array-like) -- Vertical age profiles. Can include two tables - profiles at the different R and at p.Rsun, or a single table with the local profile. Tables contain only age profiles, without the vertical grid column a.z.

  • mode (str) -- Galactic component, can be 'd', 't', 'sh', 'dt', or 'tot' (thin disk, thick disk, halo, thin+thick disk, or total). Adds suffix '_'+mode to the file name.

Returns

None.

disk_brightness_save(profiles, mode, mode_geom, band)[source]

Saves surface brightness or colour profile of the MW if it is viewed edge-on or face-on. Output subfolder is a.T['pop']. File name base is 'MagR_'.

Parameters
  • profile (1d-array) -- Disk surface brightness profile (\(\mathrm{mag \ arcsec^{-2}}\)) or color profile (mag), output of jjmodel.analysis.disk_brightness().

  • mode_comp (str) -- Galactic component, can be 'd', 't', 'sh', 'dt', or 'tot' (thin disk, thick disk, halo, thin+thick disk, or total).

  • mode_geom (str) -- Modeled geometry. Disk orientation with respect to the observer: 'face-on' or 'edge-on'.

  • bands (str or list) -- If a string, this parameter corresponds to the band for the surface brightness profile. If it is a list, then bands gives the names of two bands to be used for the color profile - e.g. ['U','V'] for U-V.

Returns

None.

fi_iso_save(profiles)[source]

Saves vertical density profiles to the subfolder a.T['dens']. File name base is 'Rhoz', 'NRohz', or 'NCMassz' (depending on the class instance kwargs).

Parameters
  • profiles (array-like) -- Vertical density profiles, where the first column is a.z and the rest are density profiles of the thin disk, thick disk, molecular gas, atomic gas, DM halo, and stellar halo.

  • R (scalar) -- Galactocentric distance, kpc. Suffix '_R' with the given value of radis is added to the output file name.

Returns

None.

fw_save(profiles, mode, R, zlim)[source]

Saves W-velocity dostribution function. Output subfolder is a.T['kinem']. File name base is 'f(|W|)'.

Parameters
  • profiles (array-like) -- Normalized on area W-velocity distribution (histogram) and W-grid (bin centers), \(\mathrm{km \ s^{-1}}\).

  • mode -- Galactic component, can be 'd', 't', 'sh', 'dt', or 'tot' (thin disk, thick disk, halo, thin+thick disk, or total).

  • R (scalar) -- Galactocentric distance, kpc.

  • zlim (array-like) -- Range of heights [zmin,zmax], pc.

Returns

None.

hess_save(profiles, mode, mode_geom, bands, mag_range, mag_step)[source]

Hess diagram for the simple volumes. Output subfolder is a.T['hess']. File name base is 'Hess_'.

Parameters
  • profiles (2d-array) -- Hess diagram, output of jjmodel.analysis.hess_simple().

  • mode (str) -- Galactic component, can be 'd', 't', 'sh', 'dt', or 'tot' (thin disk, thick disk, halo, thin+thick disk, or total).

  • mode_geom (str) -- Modeled geometry. Can be 'local_sphere', 'local_cylinder', or 'rphiz_box'.

  • bands (list[str]) -- List of names of photometric columns. Three column names must be given, e.g. ['B','V','V'] for (B-V) versus \(M_\mathrm{V}\).

  • mag_range (list[list[scalar]]) -- Minimal and maximal magnitude along the x- and y-axis of the Hess diagram, [[x_min,x_max],[y_min,y_max]].

  • mag_step (array-like) -- Step along the x- and y-axis of the Hess diagram, [dx,dy].

Returns

None.

hr_monoage_save(H, mode, ages)[source]

Saves scale heights calculated for the mono-age subpopulations for the different Galactocentric distances. Output subfolder is a.T['height']. File name base is 'H'.

Parameters
  • H (array-like) -- Table with scale heights (radial profiles in columns, age changes from column to column). Radial grid a.R is not included into H.

  • mode (str) -- Galactic component, can be 'd', 'dt', or 'tot' (thin disk, thin+thick disk, or total). Adds suffix '_'+mode to the file name.

  • ages (array-like) -- Set of age bins, Gyr.

Returns

None.

hr_monomet_save(H, mode, mets)[source]

Saves scale heights calculated for the mono-metallicity subpopulations (bins) for the different Galactocentric distances. Output subfolder is a.T['height']. File name base is 'H'.

Parameters
  • H (array-like) -- Table with scale heights (radial profiles in columns, metallicity changes from column to column). Radial grid a.R is not included into H.

  • mode (str) -- Galactic component, can be 'd', 'dt', or 'tot' (thin disk, thin+thick disk, or total). Adds suffix '_'+mode to the file name.

  • mets (array-like) -- Set of metallicity bins.

Returns

None.

input_extended_save(inp)[source]

Same as jjmodel.iof.TabSaver.input_local(), but for the model extending over some range of Galactocentric distances.

Parameters

inp (dict) -- Collection of the input functions including SFR, AVR, AMR, and IMF.

Returns

None.

input_local_save(inp)[source]

Saves a set of the local model input data: SFR, mass loss function, and AMR (for the thin and thick disk). The output directory is a.T['inp'], and file names are prescribed by jjmodel.iof.tab_sorter().

Parameters

inp (dict) -- Collection of the input functions including SFR, AVR, AMR, and IMF.

Returns

None.

mean_quantity_save(profiles, mode, R, zlim, quantity)[source]

Saves vertical profiles of some quantity calculated based on the stellar assemblies. Output subfolder is a.T['pop']. File name base is 'Mean_'.

Parameters
  • profiles (array-like) -- Vertical profiles of quantity. Tables do not contain vertical grid a.z.

  • mode (str) -- Galactic component, can be 'd', 't', 'sh', 'dt', or 'tot' (thin disk, thick disk, halo, thin+thick disk, or total). Adds suffix '_'+mode to the file name.

  • R (scalar) -- Galactocentric distance, kpc. Suffix '_R' with the given value of radis is added to the output file name.

  • zlim (array-like) -- Range of heights to be considered [zmin,zmax], pc. Adds to the file name suffix '_z' with the given heights (converted for shortness into kpc).

  • quantity (str) -- Name of the column in a stellar assemblies table for which the profile was calculated; use 'sigw' for velocity dispersion, 'age` for age, and 'FeH' for metallicity.

Returns

None.

methist_save(mets, mode, zlim)[source]

Saves metallicity distributions for the different Galactocentric distances to the subfolder a.T['met']. File name base is 'f(FeH)'.

Parameters
  • mets (array-like) -- Can contain two tables - metallicity distributions for the grid a.R and at p.Rsun, or only a single metallicity distribution for the local volume. Also, metallicity column must be added after the tables.

  • mode (str) -- Galactic component, can be 'd', 't', 'sh', 'dt', or 'tot' (thin disk, thick disk, halo, thin+thick disk, or total). Adds suffix '_'+mode to the file name.

  • zlim (array-like) -- Range of heights to be considered, pc. Adds to the file name suffix '_z' with the given heights (converted for shortness into kpc).

Returns

None.

metr_save(profiles, mode, zlim)[source]

Saves radial metallicity profile to the subfolder a.T['met']. File name base is 'FeH'.

Parameters
  • profiles (array-like) -- Radial metallicity profiles. Tables contain only metallicity profiles, without the radial grid column a.R.

  • mode (str) -- Galactic component, can be 'd', 't', 'sh', 'dt', or 'tot' (thin disk, thick disk, halo, thin+thick disk, or total). Adds suffix '_'+mode to the file name.

  • zlim (array-like) -- Range of heights to be considered, pc. Adds to the file name suffix '_z' with the given heights (converted for shortness into kpc).

Returns

None.

metz_save(profiles, mode)[source]

Saves vertical netallicity profile to the subfolder a.T['met']. File name base is 'FeH'.

Parameters
  • profiles (array-like) -- Vertical metallicity profiles. Can include two tables - profiles at the different R and at p.Rsun, or a single table with the local profile. Tables contain only metalllicity profiles, without the vertical grid column a.z.

  • mode (str) -- Galactic component, can be 'd', 't', 'sh', 'dt', or 'tot' (thin disk, thick disk, halo, thin+thick disk, or total). Adds suffix '_'+mode to the file name.

Returns

None.

output_extended_save(res)[source]

Same as jjmodel.iof.TabSaver.output_local(), but for the model extending over some range of Galactocentric distances.

Parameters

res (dict) -- Output of jjmodel.mwdisk.extended_run().

Returns

None.

output_local_save(out)[source]

Saves a set of the local model output data: AVR, scale heights for all model components, vertical potential, force, and density profiles. The output directory and file name for each quantity are prescribed by jjmodel.iof.tab_sorter() and jjmodel.iof.TabSaver.rhoz_save() (for density profiles).

Parameters

out (dict) -- Output of jjmodel.mwdisk.local_run().

Returns

None.

pops_in_volume_save(table, mode, R, mode_pop_name)[source]

Saves table(s) with number densities of stellar assemblies for some volume. Output subfolder is a.T['pop']. File name base is 'SSP_R'.

Parameters
  • table (astropy table or list[astropy table]) -- Saves stellar assemblies table(s) with a column 'Nz' containing the number of stars located in the specified volume (described by parameter 'vln' in kwargs of the class instance). Can be a single table or a list of tables, depending on mode. Output of jjmodel.analysis.pops_in_volume().

  • mode (str) -- Galactic component, can be 'd', 't', 'sh', 'dt', or 'tot' (thin disk, thick disk, halo, thin+thick disk, or total).

  • R (scalar) -- Galactocentric distance, kpc. Suffix '_R' with the given value of radis is added to the output file name.

  • mode_pop_name (str) -- Short name of the population (see jjmodel.iof.tab_reader()) or any custom name for the table.

Returns

None.

poptab_save(table, mode, mode_iso, R, mode_pop_name)[source]

Saves stellar assembly table to the subfolder a.T['poptab'] .

Parameters
  • table (astropy table) -- Table with stellar assemblies, output of jjmodel.populations.stellar_assemblies_iso() or methods of jjmodel.analysis.GetPopulations.

  • mode (str) -- Galactic component, can be 'd', 't', 'sh', 'dt', or 'tot' (thin disk, thick disk, halo, thin+thick disk, or total). Adds suffix '_'+mode to the file name.

  • mode_iso (str) -- Defines which set of isochrones is used, can be 'Padova', 'MIST', or 'BaSTI'. Adds suffix '_'+mode_iso to the file name.

  • R (scalar) -- Galactocentric distance, kpc. Suffix '_R' with the given value of radis is added to the output file name.

  • mode_pop_name (str) -- Short name of the population (see jjmodel.iof.tab_reader()) or any custom name for the table.

Returns

None.

rhor_monoage_save(profiles, mode, zlim, ages)[source]

Saves radial mono-age density profiles to the subfolder a.T['dens']. File name base is 'Rho', 'N',``'Sigma', or ``'SigmaN' (depending on parameters sigma and number in the class instance kwargs).

Parameters
  • profiles (array-like) -- Density profiles, where the first column is a.R and the rest are density profiles of the mono-age subpopulations (bins) corresponding to an age grid.

  • mode (str) -- Galactic component, can be 'd', 't', 'sh', 'dt', or 'tot' (thin disk, thick disk, halo, thin+thick disk, or total). Adds suffix '_'+mode to the file name.

  • zlim -- Range of heights, pc. Suffix '_z' with the given values is added to the output file name.

  • ages (array-like) -- Set of age bins, Gyr. Adds suffix '_age' with the min-max age and age step.

Returns

None.

rhor_monomet_save(profiles, mode, zlim, mets)[source]

Saves radial mono-metallicity density profiles to the subfolder a.T['dens']. File name base is 'Rho', 'N',``'Sigma', or ``'SigmaN' (depending on parameters sigma and number in the class instance kwargs).

Parameters
  • profiles (array-like) -- Density profiles, where the first column is a.R and the rest are density profiles of the mono-metallicity subpopulations (bins) corresponding to metallicity grid.

  • mode (str) -- Galactic component, can be 'd', 't', 'sh', 'dt', or 'tot' (thin disk, thick disk, halo, thin+thick disk, or total). Adds suffix '_'+mode to the file name.

  • zlim -- Range of heights, pc. Suffix '_z' with the given values is added to the output file name.

  • mets (array-like) -- Set of metallicity bins. Adds suffix '_FeH' with the min-max metallicity and step in metallicity.

Returns

None.

rhoz_monoage_save(profiles, mode, R, ages)[source]

Saves vertical mono-age density profiles to the subfolder a.T['dens']. File name base is 'Rho', 'N',``'Sigma', or ``'SigmaN' (depending on parameters sigma and number in the class instance kwargs).

Parameters
  • profiles (array-like) -- Vertical density profiles, where the first column is a.z and the rest are density profiles of the mono-age subpopulations (bins) corresponding to an age grid.

  • mode (str) -- Galactic component, can be 'd', 't', 'sh', 'dt', or 'tot' (thin disk, thick disk, halo, thin+thick disk, or total). Adds suffix '_'+mode to the file name.

  • R (scalar) -- Galactocentric distance, kpc. Suffix '_R' with the given value of radis is added to the output file name.

  • ages (array-like) -- Set of age bins, Gyr. Adds suffix '_age' with the min-max age and age step.

Returns

None.

rhoz_monomet_save(profiles, mode, R, mets)[source]

Saves vertical mono-metallicity density profiles to the subfolder a.T['dens']. File name base is 'Rho', 'N',``'Sigma', or ``'SigmaN' (depending on parameters sigma and number in the class instance kwargs).

Parameters
  • profiles (array-like) -- Vertical density profiles, where the first column is a.z and the rest are density profiles of the mono-metallicity subpopulations (bins) corresponding to the metallicity grid.

  • mode (str) -- Galactic component, can be 'd', 't', 'sh', 'dt', or 'tot' (thin disk, thick disk, halo, thin+thick disk, or total). Adds suffix '_'+mode to the file name.

  • R (scalar) -- Galactocentric distance, kpc. Suffix '_R' with the given value of radis is added to the output file name.

  • mets (array-like) -- Set of metallicity bins. Adds suffix '_FeH' with the min-max metallicity and step in metallicity.

Returns

None.

rhoz_save(profiles, R)[source]

Saves vertical density profiles to the subfolder a.T['dens']. File name base is 'Rhoz', 'NRohz', or 'NCMassz' (depending on the class instance kwargs).

Parameters
  • profiles (array-like) -- Vertical density profiles, where the first column is a.z and the rest are density profiles of the thin disk, thick disk, molecular gas, atomic gas, DM halo, and stellar halo.

  • R (scalar) -- Galactocentric distance, kpc. Suffix '_R' with the given value of radis is added to the output file name.

Returns

None.

rot_curve_save(profiles)[source]

Saves rotation curve to the subfolder a.T['kintab']. File name base is 'Vc_R'.

Parameters

profiles (array-like) -- The first column is Galactocentric distance R, kpc. Other columns contain rotation velocity (\(\mathrm{km \ s^{-1}}\)) in the following order: total, bulge, thin disk, thick disk, molecular gas, atomic gas, DM halo, stellar halo.

Returns

None.

rz_map_quantity_save(profiles, mode, quantity)[source]

Saves R-z map of some quantity. Output subfolder is a.T['maps']. File name begins with quantity.

Parameters
  • profiles (2d-array) -- Map of the chosen quantity in R-z Galactic coordinates.

  • mode (str) -- Galactic component, can be 'd', 't', 'sh', 'dt', or 'tot' (thin disk, thick disk, halo, thin+thick disk, or total).

  • quantity (str) -- Name of the column in a stellar assemblies table to which the function has to be applied; for velocity dispersion use 'sigw', 'age` for age, and 'FeH' for metallicity.

Returns

None.

rz_map_save(profiles, mode)[source]

Saves R-z map of some quantity. Output subfolder is a.T['maps']. File name is 'Rho', 'N', 'Sigma', or 'SigmaN', depending on kwargs of the class instance.

Parameters
  • profiles (2d-array) -- Map of stellar mass or number density in R-z Galactic coordinates.

  • mode (str) -- Galactic component, can be 'd', 't', 'sh', 'dt', or 'tot' (thin disk, thick disk, halo, thin+thick disk, or total).

Returns

None.

sigwr_monoage_save(profiles, mode, zlim, ages)[source]

Saves radial W-velocity dispersion profiles calculated for the mono-age subpopulations. Output subfolder is a.T['kinem']. File name base is 'SigW'.

Parameters
  • profiles (array-like) -- Radial velocity dispersion profiles (ages change from column to column). Tables contain only kinematics, without the radial grid column a.R.

  • mode (str) -- Galactic component, can be 'd', 'dt', or 'tot' (thin disk, thin+thick disk, or total). Adds suffix '_'+mode to the file name.

  • zlim (array-like) -- Range of heights to be considered, pc. Adds to the file name suffix '_z' with the given heights (converted for shortness into kpc).

  • ages (array-like) -- Set of age bins, Gyr.

Returns

None.

sigwr_monomet_save(profiles, mode, zlim, mets)[source]

Saves radial W-velocity dispersion profiles calculated for the mono-metallicity subpopulations (bins). Output subfolder is a.T['kinem']. File name base is 'SigW'.

Parameters
  • profiles (array-like) -- Radial velocity dispersion profiles (metallicity changes from column to column). Tables contain only kinematics, without the radial grid column a.R.

  • mode (str) -- Galactic component, can be 'd', 'dt', or 'tot' (thin disk, thin+thick disk, or total). Adds suffix '_'+mode to the file name.

  • zlim (array-like) -- Range of heights to be considered, pc. Adds to the file name suffix '_z' with the given heights (converted for shortness into kpc).

  • ages (array-like) -- Set of metallicity bins.

Returns

None.

sigwr_save(profiles, mode, zlim)[source]

Saves radial W-velocity dispersion profiles to the subfolder a.T['kinem']. File name base is 'SigW'.

Parameters
  • profiles (array-like) -- Radial velocity dispersion profiles. Tables contain only kinematics, without the radial grid column a.R.

  • mode (str) -- Galactic component, can be 'd', 'dt', or 'tot' (thin disk, thin+thick disk, or total). Adds suffix '_'+mode to the file name.

  • zlim (array-like) -- Range of heights to be considered, pc. Adds to the file name suffix '_z' with the given heights (converted for shortness into kpc).

Returns

None.

sigwz_save(profiles, mode)[source]

Saves vertical profile of W velocity dispersion to the subfolder a.T['kinem']. File name base is 'SigW'.

Parameters
  • profiles (array-like) -- Velocity dispersion profiles. Can include two tables - profiles at the different R and at p.Rsun, or a single table with the local profile. Tables contain only velocity dispersion profiles, without the vertical grid column a.z.

  • mode (str) -- Galactic component, can be 'd', 'dt', or 'tot' (thin disk, thin+thick disk, or total).

Returns

None.