SED classes#

Code author: Hugo Plombat - LUPM <hugo.plombat@umontpellier.fr> & Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Main SED objects used to perform pixel-per-pixel SED fitting.

class pixSED.sed.CigaleSED(ID: ~typing.Any, filters: ~typing.List[str], uncertainties: ~typing.Optional[~typing.List[bool]] = None, SFH: ~typing.List[~pixSED.misc.cigaleModules.SFHmodule] = [<pixSED.misc.cigaleModules.SFH2EXPmodule object>], SSP: ~typing.List[~pixSED.misc.cigaleModules.SSPmodule] = [<pixSED.misc.cigaleModules.BC03module object>], nebular: ~typing.List[~pixSED.misc.cigaleModules.NEBULARmodule] = [], attenuation: ~typing.List[~pixSED.misc.cigaleModules.ATTENUATIONmodule] = [], dust: ~typing.List[~pixSED.misc.cigaleModules.DUSTmodule] = [], agn: ~typing.List[~pixSED.misc.cigaleModules.AGNmodule] = [], radio: ~typing.List[~pixSED.misc.cigaleModules.RADIOmodule] = [], restframe: ~typing.List[~pixSED.misc.cigaleModules.RESTFRAMEmodule] = [], redshifting: ~typing.List[~pixSED.misc.cigaleModules.REDSHIFTmodule] = [<pixSED.misc.cigaleModules.REDSHIFTmodule object>], flux_uncertainty: ~typing.Union[int, float] = 0, **kwargs)[source]#

Bases: SED

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Implements Cigale SED object.

Parameters:
  • ID – an identifier used to name the output files created during the SED fitting process

  • filters (list) – filters to use for the SED fitting

Keyword arguments

Parameters:
  • uncertainties (list[bool]) – list of bool to specify which uncertainties to use. If provided, it must be same length as filters.

  • SFH (list [SFHmodule]) – star formation history modules to use. At least one module must be given.

  • SSP (list [SSPmodule]) – single stellar population modules to use. At least one module must be given.

  • nebular (list [NEBULARmodule]) – nebular emission modules to use. Empty list means no module is used.

  • attenuation (list [ATTENUATIONmodule]) – dust attenuation modules to use. Empty list means no module is used.

  • dust (list [DUSTmodule]) – dust emission modules to use. Empty list means no module is used.

  • agn (list [AGNmodule]) – agn modules to use. Empty list means no module is used.

  • radio (list [SED.misc.cigaleModules.RADIOmodule]) – synchrotron radiation modules to use. Empty list means no module is used.

  • restframe (list [SED.misc.cigaleModules.RESTFRAMEmodule]) – restframe parameters modules to use. Empty list means no module is used.

  • redshifting (list [SED.misc.cigaleModules.REDSHIFTINGmodule]) – redshifitng+IGM modules to use. Empty list means no module is used.

  • flux_uncertainty (int or float) – additional uncertainty to add to the flux, given as a fraction of the flux (i.e. 0.1 means 10% of flux added to the uncertainty in quadrature)

Raises:
  • TypeError – if any of the keyword parameters if not a list

  • ValueError – if no SFH, SSP and redshifting modules are provided

SFH: SFHmodule#

SFH modules to use

SSP: SSPmodule#

SSP modules to use

static _checkModule(modules: List[Any], inheritedClass: Any) List[Any][source]#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Check that the given list of Cigale modules belong to the correct class they should inherit from.

Parameters:
  • modules (list) – modules to check the inheritance

  • inheritedClass – class to check against for inheritance

Returns:

the list of modules if all the modules inherit from the given class

Return type:

list

Raises:

TypeError – if one of the modules in modules does not inherit from inheritedClass

agn: AGNmodule#

AGN modules to use

analysisParamsModule(physical_properties: Optional[List[str]], bands: Optional[List[str]], save_best_sed: bool, save_chi2: bool, lim_flag: bool, mock_flag: bool, redshift_decimals: int, blocks: int, **kwargs) str[source]#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Generate the analysis_params module text for Cigale.

Parameters:
  • physical_properties (list[str]) – physical properties to estimate at the end of the SED fitting. If None, all properties are computed.

  • bands (list[str]) – list of bands for which to estimate the fluxes. Note that this is independent from the fluxes actually fitted to estimate the physical properties. If None, the same bands as the ones provided in filters will be used.

  • save_best_sed (bool) – whether to save the best SED for each observation into a file or not

  • save_chi2 (bool) – whether to save the raw chi2 or not. It occupies ~15 MB/million models/variable.

  • lim_flag (bool) – if True, for each object check whether upper limits are present and analyse them

  • mock_flag – if True, for each object we create a mock object and analyse them

  • redshift_decimals (int) – when redshifts are not given explicitly in the redshifting module, number of decimals to round the observed redshifts to compute the grid of models. To disable rounding give -1. Do not round if you use narrow-band filters.

  • blocks (int) – number of blocks to compute the models and analyse the observations. If there is enough memory, we strongly recommend this to be set to 1.

Returns:

module text for the analysis parameters

Return type:

str

attenuation: ATTENUATIONmodule#

Dust attenuation modules to use

dust: DUSTmodule#

Dust emission modules to use

filters: ListStrProperty#

Filters to use for the SED fitting

id: Any#

Will be used to generate a custom directory

moduleNames: ListStrProperty#

Modules names list

modulesSpec: str#

Modules spec parameters in str format

modulesStr: str#

Modules parameters in str format

nebular: NEBULARmodule#

Nebular emission modules to use

property parameters: str#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Generate a parameter file text used by the SED fitting code.

Returns:

the text

Return type:

str

radio: RADIOmodule#

Synchrotron radiation modules to use

redshifting: REDSHIFTmodule#

Redshifting modules to use

restframe: RESTFRAMEmodule#

Rest-frame parameters modules to use

property specParameters: str#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Generate the spec parameter file text associated to the given sed modules.

Returns:

spec parameter file text

Return type:

str

startCigale(log: Optional[TextIOBase] = None)[source]#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Wrapper around default SED.startProcess() which allows to run Cigale.

Keyword arguments

Parameters:

log (TextIOBase) – oppened log file

class pixSED.sed.LePhareSED(ID: Any, properties: dict = {}, **kwargs)[source]#

Bases: SED

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Implements LePhare SED object.

Important

It is mandatory to define on your OS two environment variables:

  • $LEPHAREWORK which points to LePhare working directory

  • $LEPHAREDIR which points to LePhare main directory

These paths may be expanded to check whether the given files exist and can be used by the user to shorten some path names when providing the SED properties.

Parameters:

ID – an identifier used to name the output files created during the SED fitting process

Keyword arguments

Parameters:

properties (dict[str, str]) – properties to be passed to LePhare to compute the models grid and perform the SED fitting

Raises:
  • TypeError – if one of the properties keys is not of type str

  • ValueError – if one of the properties does not have a valid name (see list below)

Accepted properties are:

  • STAR_SED [str]: stellar library list file (full path)

  • STAR_FSCALE [float]: stellar flux scale

  • STAR_LIB [str]: stellar library to use (default libraries found at $LEPHAREWORK/lib_bin). To not use a stellar library, provide 'NONE'.

  • QSO_SED [str]: QSO list file (full path)

  • QSO_FSCALE [float]: QSO flux scale

  • QSO_LIB [str]: QSO library to use (default libraries found at LEPHAREWORK/lib_bin). To not use a QSO library, provide 'NONE'.

  • GAL_SED [str]: galaxy library list file (full path)

  • GAL_FSCALE [float]: galaxy flux scale

  • GAL_LIB [str]: galaxy library to use (default libraries found at $LEPHAREWORK/lib_bin). To not use a galaxy library, provide 'NONE'.

  • SEL_AGE [str]: stellar ages list (full path)

  • AGE_RANGE [list[float]]: minimum and maximum ages in years

  • FILTER_LIST [list[str]]: list of filter names used for the fit (must all be located in $LEPHAREDIR/filt directory)

  • TRANS_TYPE [int]: transmission type (0 for Energy, 1 for photons)

  • FILTER_CALIB [int]: filter calibration (0 for fnu=ctt, 1 for nu.fnu=ctt, 2 for fnu=nu, 3 for fnu=Black Body @ T=10000K, 4 for MIPS (leff with nu fnu=ctt and flux with BB @ 10000K)

  • FILTER_FILE [str]: filter file (must be located in $LEPHAREWORK/filt directory)

  • STAR_LIB_IN [str]: input stellar library (dupplicate with STAR_LIB ?)

  • STAR_LIB_OUT [str]: output stellar magnitudes

  • QSO_LIB_IN [str]: input QSO library (dupplicate with QSO_LIB ?)

  • QSO_LIB_OUT [str]: output QSO magnitudes

  • GAL_LIB_IN [str]: input galaxy library (dupplicate with GAL_LIB ?)

  • GAL_LIB_OUT [str]: output galaxy magnitudes

  • MAGTYPE [MagType]: magnitude system used (AB or VEGA)

  • Z_STEP [list[int/float]]: redshift step properties. Values are in this order: redshift step, max redshift, redshift step for redshifts above 6 (coarser sampling).

  • COSMOLOGY [list[int/float]]: cosmology parameters. Values are in this order: Hubble constant \(H_0\), baryon fraction \(\Omega_{m, 0}\), cosmological constant fraction \(\Omega_{\lambda, 0}\).

  • MOD_EXTINC [list[int/float]]: minimum and maximum model extinctions

  • EXTINC_LAW [str]: extinction law file (in $LEPHAREDIR/ext)

  • EB_V [list[int/float]]: color excess \(E(B-V)\). It must contain less than 50 values.

  • EM_LINES [YESNO]: whether to consider emission lines or not. Accepted values are YES or NO.

  • BD_SCALE [int]: number of bands used for scaling (0 means all bands). See LePhare documentation for more details.

  • GLB_CONTEXT [int]: context number (0 means all bands). See LePhare documentation for more details.

  • ERR_SCALE [list[int/float]]: magnitude errors per band to add in quadrature

  • ERR_FACTOR [int/float]: scaling factor to apply to the errors

  • ZPHOTLIB [list[str]]: librairies used to compute the \(\chi^2\). Maximum number is 3.

  • ADD_EMLINES [YESNO]: whether to add emission lines or not (dupplicate with EM_LINES ?). Accepted values are YES or NO.

  • FIR_LIB [str]: far IR library

  • FIR_LMIN [int/float]: minimum wavelength (in microns) for the far IR analysis

  • FIR_CONT [int/float]: far IR continuum. Use -1 for no continuum.

  • FIR_SCALE [int/float]: far IR flux scale. Use -1 to skip flux scale.

  • FIR_FREESCALE [str]: whether to let the far IR spectrum freely scale

  • FIR_SUBSTELLAR [str]: ???

  • PHYS_LIB [str]: physical stochastic library

  • PHYS_CONT [int/float]: physical continuum. Use -1 for no continuum.

  • PHYS_SCALE [int/float]: physical flux scale. Use -1 to skip flux scale.

  • PHYS_NMAX [int]: ???

  • MAG_ABS [list[int/float]]: minimum and maximum values for the magnitudes.

  • MAG_REF [int]: reference band used by MAG_ABS

  • Z_RANGE [list[int/float]]: minimum and maximum redshifts used by the galaxy library

  • EBV_RANGE [list[int/float]]: minimum and maximum colour excess \(E(B-V)\)

  • ZFIX [YESNO]: whether to fix the redshift or let it free. Accepted values are YES or NO.

  • Z_INTERP [YESNO]: whether to perform an interpolation to find the redshift. Accepted values are YES or NO.

  • DZ_WIN [int/float]: window search for second peak. Must be between 0 and 5.

  • MIN_THRES [int/float]: minimum threshold for second peak. Must be between 0 and 1.

  • MABS_METHOD [int]: method used to compute magnitudes (0 : obs->Ref, 1 : best obs->Ref, 2 : fixed obs->Ref, 3 : mag from best SED, 4 : Zbin). See LePhare documentation for more details.

  • MABS_CONTEXT [int]: context for absolute magnitudes. See LePhare documentation for more details.

  • MABS_REF [int]: reference band used to compute the absolute magnitudes. This is only used if MABS_METHOD = 2.

  • MABS_FILT [list[int]]: filters used in each redshift bin (see MABS_ZBIN). This is only used if MABS_METHOD = 4.

  • MABS_ZBIN [list[int/float]]: redshift bins (must be an even number). This is only used if MABS_METHOD = 4.

  • SPEC_OUT [YESNO]: whether to output the spectrum of each object or not. Accepted values are YES or NO.

  • CHI2_OUT [YESNO]: whether to generate an output file with all the values or not. Accepted values are YES or NO.

  • PDZ_OUT [str]: output file name for the PDZ analysis. To not do the pdz analysis, provide 'NONE'.

  • PDZ_MABS_FILT [list[int]]: absolute magnitude for reference filters to be extracted. See LePhare documentation for more details.

  • FAST_MODE [YESNO]: whether to perform a fast computation or not. Accepted values are YES or NO.

  • COL_NUM [int]: number of colors used

  • COL_SIGMA [int/float]: quantity by which to enlarge the errors on the colors

  • COL_SEL [ANDOR]: operation used to combine colors. Accepted values are AND or OR.

  • AUTO_ADAPT [YESNO]: whether to use an adaptive method with a z-spec sample. Accepted values are YES or NO.

  • ADAPT_BAND [list[int]]: reference band, band1 and band2 for colors

  • ADAPT_LIM [list[int/float]]: magnitude limit for spectro in reference band

  • ADAPT_POLY [int]: number of coefficients in polynomial. Maximum is 4.

  • ADAPT_METH [int]: fit method, 1 for color model, 2 for redshift, 3 for models. See LePhare documentation for more details.

  • ADAPT_CONTEXT [int]: context for the bands used for training. See LePhare documentation for more details.

  • ADAPT_ZBIN [list[int/float]]: minimum and maximum redshift interval used for training.

id: Any#

Will be used to generate a custom directory

output_parameters(params: List[str] = [], *args, **kwargs) str[source]#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Generate an output parameter file used by the SED fitting code.

Keyword arguments

Parameters:

params (list[str]) – list of parameters to activate in the ouput parameters file

Note

To know which output parameters can be passed print outParam property, i.e.

>>> sed = LePhareSED('identifier')
>>> print(sed.outParams)
property parameters: str#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Generate a parameter file text used by the SED fitting code.

Returns:

the text

Return type:

str

prop: Dict[str, Any]#

Allowed keys and corresponding allowed types

runScript(commands: List[str], file: str = '', log: Optional[TextIOBase] = None, errMsg: str = '', test: bool = True, testMsg: str = '')[source]#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Wrapper around default startProcess() which allows to separately provide the commands and the file.

Parameters:

commands (list[str]) – list of commands to use with Popen

Keyword arguments

Parameters:
  • file (str) – file to run the process or script against

  • log (TextIOBase) – oppened log file

  • errMsg (str) – message error to show if the process failed

  • test (bool) – a test that must be passed at the end of the command for the program to continue

  • testMsg (str) – a test that must be passed at the end of the command for the program to continue

Raises:
  • TypeError – if commands if not of type list

  • ValueError – if testFunc returns False

class pixSED.sed.SED(*args, **kwargs)[source]#

Bases: ABC

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Abstract SED object used for inheritance.

appendLog(text: str, f: TextIOBase, verbose: bool = False, **kwargs) None[source]#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Append a new text line to the log file.

Parameters:
  • text (str) – text to append

  • f (TextIOBase) – file-like opened obect to write into

Keyword arguments

Parameters:

verbose (bool) – whether to also print the log line or not

Raises:

TypeError

  • if text is not of type str

  • if verbose is not of type bool

  • if f is not of type TextIOBase

log: List#

Log file

startProcess(commands: List[str], log: Optional[TextIOBase] = None, errMsg: str = '') None[source]#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Start a process.

Parameters:

commands (list[str]) – list of commands to use with Popen

Keyword arguments

Parameters:
  • log (TextIOBase) – oppened log file

  • errMsg (str) – message error to show if the process failed

Raises:
  • TypeError

    • if errMsg is not of type str

    • if commands is not of type list

    • if one of the commands in commands is not of type str

  • OSError – if the first command in commands is not a valid file/script name

  • ValueError – if log is None