synthpop.synthpop_main
SynthPop is a modular framework to generate synthetic galaxy population models. For usage see README.md!
This file contains the main SynthPop class and main function. Which handles the setting of synthpop, data collection from the different populations and saving process. The generation process for each population is performed by the Population class defined in population.py.
Classes
Model class for generating catalogs of stars. |
Functions
|
Run Synthpop in the standard mode |
Module Contents
- class synthpop.synthpop_main.SynthPop(*args, **kwargs)
Model class for generating catalogs of stars.
Attributes
- model_namestr
name of the model directory
- population_fileslist<str>
list of population.json files detected in the model directory
- populationlist<Population>
list of the initialized population objects
- solid_anglefloat [sr]
size of the cone
- min_mass, max_massfloat [Msun]
minimum and maximum mass of the Star generation
- filename_basestr
file name to store the results including the path and without an extension
Methods
- __init__()None
initialize the SynthPop class
- init_populations()None
collects the population configuration and initializes the populations
- update_location(l_deg: float, b_deg: float, solid_angle_sr: float)None
wrapper to update the location in all the populations
- estimate_field_population()None
wrapper to estimate the field output for each population
- do_kinematics(field_df: pandas.DataFrame)pandas.DataFrame
wrapper to call the kinematics generation in each population
- generate_fields()None
wrapper to generate all the populations
- write_astrotable(filename: str, df: pandas.DataFrame, extension: str)None
option to save the table as fits or VoTable.
- write_to_file(df: pandas.DataFrame)str
save the generated model, returns the filename
- get_filename(l_deg: float, b_deg: float, solid_angle_sr: float)None
generate the base of the filename (i.e. without extension) for a given location
- process_location(l_deg: float, b_deg: float,
solid_angle_sr: float, save_data: bool) : Pandas.DataFrame Dict
process a given location.
- process_all()None
process all locations as specified in the configuration
- parms
- population_files = None
- populations = []
- filename_base = None
- populations_are_initialized = False
- save_data = True
- l_deg = None
- b_deg = None
- solid_angle = None
- solid_angle_unit = None
- init_populations(forced: bool = False) None
Wrapper function that initializes all the populations for the model. Can initialize with coordinates, but it is not necessary.
Parameters
- forcedbool
forced the initialisation, even if the populations are initialized before
Returns
- update_location(l_deg: float, b_deg: float, solid_angle: float, solid_angle_unit: str = 'deg^2', **positional_kwargs) None
Simple wrapper to update filename, logfile, and all populations in the model to the new location (l,b) and solid angle.
Parameters
- l_degfloat [‘deg’]
galactic longitude for the center of the cone
- b_degfloat [‘deg’]
galactic longitude for the center of the cone
- solid_anglefloat [deg^2]
steradians for the cone size
- solid_angle_unitstr
unit for steradians
- positional_kwargs :
any keyword to be passed to Position
- estimate_field_population() None
A simple wrapper to estimate the total mass and number of stars to be drawn in a field
- do_kinematics(field_df: pandas.DataFrame) pandas.DataFrame
A simple wrapper to call the kinematic generation of each population
Note that the change is performed in place. I.e. It will overwrite what the kinematics in field_df is
Parameters
- field_dfDataFrame
Generated stars
Returns
- field_df
dataframe of the generated stars
- generate_fields() Tuple[pandas.DataFrame, Dict]
calls the generate_field for all the populations and collects the data in a common pandas dataframe.
Returns
- field_df: DataFrame
DataFrame including the generated Stars from all populations
- distributions: dict
collection of intrinsic distributions for each population
- write_astrotable(filename: str, df: pandas.DataFrame, extension: str) None
save the result as fits file or votable by converting it to an astropy.table.Table object.
Parameters
- filenamestr
save location
- dfDataFrame
Data frame of the generated model
- extensionstr
file extension. either “fits” or “vot”/”votable”
Returns
- write_to_file(df: pandas.DataFrame) str
write the results to disc
Parameters
- dfDataFrame
Model output
Returns
- filenamestr
path of the created file save location.
- get_filename(l_deg: float, b_deg: float, solid_angle: float) str
create a file name for a given position
Parameters
- l_deg, b_degfloat [deg]
galactic coordinates
- solid_angle: float [rad]
solid angle of the cone
Returns
- filenamestr
filename including location
- process_location(l_deg: float, b_deg: float, solid_angle: float, solid_angle_unit: str = 'deg^2', save_data: bool = True) Tuple[pandas.DataFrame, Dict]
Performs the field generation for a given position.
Parameters
- l_deg, b_degfloat [deg]
galactic coordinates
- solid_anglefloat [deg^2]
Area of the cone
- solid_angle_unitstr
Unit of the provided solid_angle
- save_databool
If True the DataFrame is saved to disk If False the DataFrame are only returned,
Returns
- field_dfDataFrame
Generated stars as Pandas Dataframe
- distributions: dict
collection of intrinsic distributions for each population