Spectral Energy Distributions
- class galsim.SED(spec, wave_type, flux_type, redshift=0.0, fast=True, interpolant='linear', _blue_limit=0.0, _red_limit=inf, _wave_list=None)[source]
- Object to represent the spectral energy distributions of stars and galaxies. - SEDs are callable, usually returning the flux density in photons/nm/cm^2/s as a function of wavelength, though SEDs are also used by GalSim to track dimensionless wavelength-dependent normalizations, and may thus also return dimensionless values. By default, the above wavelength used by __call__ is nanometers, but it’s possible to use other units via the astropy.units module (at least, if the SED keyword argument - fast=False, see below). For instance,:- >>> sed = galsim.SED(...) >>> from astropy import units as u >>> assert sed(500) == sed(5000 * u.AA) # 500 nm == 5000 Angstroms - The python type of the return value depends on the type of the input wavelength(s). A scalar input wavelength yields a scalar flux density, a tuple yields a tuple, a list yields a list, and a numpy.ndarray yields a numpy.ndarray. A scalar astropy.units.Quantity yields a python scalar, and a vector astropy.units.Quantity yields a numpy.ndarray. - SEDs are immutable; all transformative SED methods return new SEDs, and leave their originating SEDs unaltered. - SEDs have - blue_limitand- red_limitattributes, which indicate the range over which the SED is defined. An exception will be raised if the flux density or normalization is requested outside of this range. Note that- blue_limitand- red_limitare always in nanometers and in the observed frame when- redshift != 0.- SEDs may be multiplied by scalars or scalar functions of wavelength. In particular, an SED multiplied by a - Bandpasswill yield the appropriately filtered SED. Two SEDs may be multiplied together if at least one of them represents a dimensionless normalization.- SEDs may be added together if they are at the same redshift. The resulting SED will only be defined on the wavelength region where both of the operand SEDs are defined. - blue_limitand- red_limitwill be reset accordingly.- The input parameter, - spec, may be one of several possible forms:- a regular python function (or an object that acts like a function) 
- a file from which a - LookupTablecan be read in
- a string which can be evaluated to a function of - wavevia- eval('lambda wave:'+spec), e.g.:- spec = '0.8 + 0.2 * (wave-800)' 
- a python scalar (only possible for dimensionless SEDs) 
 - The argument of - specshould be the wavelength in units specified by- wave_type, which should be an instance of- astropy.units.Unitof equivalency class- astropy.units.spectral, or one of the case-insensitive aliases ‘nm’, ‘nanometer’, ‘nanometers’, ‘A’, ‘Ang’, ‘Angstrom’, or ‘Angstroms’. Note that- astropy.units.spectralincludes not only units with dimensions of length, but also frequency, energy, or wavenumber.- The return value of - specshould be a spectral density with units specified by- flux_type, which should be an instance of- astropy.units.Unitof equivalency class- astropy.units.spectral_density, or one of the case-insensitive aliases:- ‘flambda’: erg/wave_type/cm^2/s, where wave_type is as above. 
- ‘fnu’: erg/Hz/cm^2/s 
- ‘fphotons’: photons/wave_type/cm^2/s, where wave_type is as above. 
- ‘1’: dimensionless 
 - Note that the - astropy.units.spectral_densityclass includes units with dimensions of [energy/time/area/unit-wavelength], [energy/time/area/unit-frequency], [photons/time/area/unit-wavelength], and so on.- Finally, the optional - fastkeyword option is used to specify when unit and dimension changes are executed, particularly for SEDs specified by a- LookupTable. If- fast=True, the default, then the input units/dimensions may be converted to an internal working unit before interpolation in wavelength is performed. Alternatively,- fast=Falseimplies that interpolation should take place in the native units of the input- spec, and subsequently flux density converted to photons/cm^2/s/nm afterwards. Generally, the former option is faster, but may be less accurate since interpolation and dimensionality conversion do not commute. One consequence of using- fast=Trueis that __call__ can not accept an- astropy.units.Quantityin this case.- Parameters:
- spec – Function defining the z=0 spectrum at each wavelength. See above for valid options for this parameter. 
- wave_type – String or astropy.unit specifying units for wavelength input to - spec.
- flux_type – String or astropy.unit specifying what type of spectral density or dimensionless normalization - specrepresents. See above for valid options for this parameter.
- redshift – Optionally shift the spectrum to the given redshift. [default: 0] 
- fast – Convert units on initialization instead of on __call__. [default: True] 
- interpolant – If reading from a file, what interpolant to use. [default: ‘linear’] 
 
 - __call__(wave)[source]
- Return photon flux density or dimensionless normalization at wavelength - wave.- Note that outside of the wavelength range defined by the - blue_limitand- red_limitattributes, the SED is considered undefined, and this method will raise an exception if a wavelength outside the defined range is passed as an argument.- Parameters:
- wave – Wavelength in nanometers at which to evaluate the SED. May be a scalar, a numpy.array, or an astropy.units.Quantity 
- Returns:
- photon flux density in units of photons/nm/cm^2/s if self.spectral, or dimensionless normalization if self.dimensionless. 
 
 - __mul__(other)[source]
- Multiply the SED by something. - There are several possibilities: - SED * SED -> SED (at least one must be dimensionless) 
- SED * GSObject -> ChromaticObject 
- SED * Bandpass -> SED (treating throughput similarly to dimensionless SED) 
- SED * callable function -> SED (treating function as dimensionless SED) 
- SED * scalar -> SED 
 
 - calculateDCRMomentShifts(bandpass, **kwargs)[source]
- Calculates shifts in first and second moments of PSF due to differential chromatic refraction (DCR). - I.e., equations (1) and (2) from Plazas and Bernstein (2012): - http://arxiv.org/abs/1204.1346). - Parameters:
- bandpass – - Bandpassthrough which object is being imaged.
- zenith_angle – - Anglefrom object to zenith
- parallactic_angle – Parallactic angle, i.e. the position angle of the zenith, measured from North through East. [default: 0] 
- obj_coord – Celestial coordinates of the object being drawn as a - CelestialCoord. [default: None]
- zenith_coord – Celestial coordinates of the zenith as a - CelestialCoord. [default: None]
- HA – Hour angle of the object as an - Angle. [default: None]
- latitude – Latitude of the observer as an - Angle. [default: None]
- pressure – Air pressure in kiloPascals. [default: 69.328 kPa] 
- temperature – Temperature in Kelvins. [default: 293.15 K] 
- H2O_pressure – Water vapor pressure in kiloPascals. [default: 1.067 kPa] 
 
- Returns:
- The first element is the vector of DCR first moment shifts 
- The second element is the 2x2 matrix of DCR second (central) moment shifts. 
 
- Return type:
- a tuple 
 
 - calculateFlux(bandpass)[source]
- Return the flux (photons/cm^2/s) of the - SEDthrough the- Bandpassbandpass.
 - calculateMagnitude(bandpass)[source]
- Return the - SEDmagnitude through a- Bandpass- bandpass.- Note that this requires - bandpassto have been assigned a zeropoint using- Bandpass.withZeropoint.
 - calculateSeeingMomentRatio(bandpass, alpha=-0.2, base_wavelength=500)[source]
- Calculates the relative size of a PSF compared to the monochromatic PSF size at wavelength - base_wavelength.- Parameters:
- bandpass – - Bandpassthrough which object is being imaged.
- alpha – Power law index for wavelength-dependent seeing. [default: -0.2, the prediction for Kolmogorov turbulence] 
- base_wavelength – Reference wavelength in nm from which to compute the relative PSF size. [default: 500] 
 
- Returns:
- the ratio of the PSF second moments to the second moments of the reference PSF. 
 
 - check_spectral()[source]
- Return boolean indicating if SED has units compatible with a spectral density. 
 - property dimensionless
- Whether the object is dimensionless (rather than spectral). 
 - sampleWavelength(nphotons, bandpass, rng=None, npoints=None)[source]
- Sample a number of random wavelength values from the - SED, possibly as observed through a- Bandpassbandpass.- Parameters:
- nphotons – Number of samples (photons) to randomly draw. 
- bandpass – A - Bandpassobject representing a filter, or None to sample over the full- SEDwavelength range.
- rng – If provided, a random number generator that is any kind of - BaseDeviateobject. If- rngis None, one will be automatically created from the system. [default: None]
- npoints – Number of points - DistDeviateshould use for its internal interpolation tables. [default: None, which uses the- DistDeviatedefault]
 
 
 - thin(rel_err=0.0001, trim_zeros=True, preserve_range=True, fast_search=True)[source]
- Remove some tabulated values while keeping the integral over the set of tabulated values still accurate to - rel_err.- This is only relevant if the - SEDwas initialized with a- LookupTableor from a file (which internally creates a- LookupTable).- Parameters:
- rel_err – The relative error allowed in the integral over the - SED[default: 1.e-4]
- trim_zeros – Remove redundant leading and trailing points where f=0? (The last leading point with f=0 and the first trailing point with f=0 will be retained). Note that if both trim_leading_zeros and preserve_range are True, then the only the range of - xafter zero trimming is preserved. [default: True]
- preserve_range – Should the original range ( - blue_limitand- red_limit) of the- SEDbe preserved? (True) Or should the ends be trimmed to include only the region where the integral is significant? (False) [default: True]
- fast_search – If set to True, then the underlying algorithm will use a relatively fast O(N) algorithm to select points to include in the thinned approximation. If set to False, then a slower O(N^2) algorithm will be used. We have found that the slower algorithm tends to yield a thinned representation that retains fewer samples while still meeting the relative error requirement. [default: True] 
 
- Returns:
- the thinned - SED.
 
 - withFlux(target_flux, bandpass)[source]
- Return a new - SEDwith flux through the- Bandpass- bandpassset to- target_flux.- See - ChromaticObjectdocstring for information about how- SEDnormalization affects- ChromaticObjectnormalization.
 - withFluxDensity(target_flux_density, wavelength)[source]
- Return a new - SEDwith flux density set to- target_flux_densityat wavelength- wavelength.- See - ChromaticObjectdocstring for information about how- SEDnormalization affects- ChromaticObjectnormalization.- Parameters:
- target_flux_density – The target normalization in photons/nm/cm^2/s. 
- wavelength – The wavelength, in nm, at which the flux density will be set. 
 
- Returns:
- the new normalized SED. 
 
 - withMagnitude(target_magnitude, bandpass)[source]
- Return a new - SEDwith magnitude through the- Bandpass- bandpassset to- target_magnitude.- Note that this requires - bandpassto have been assigned a zeropoint using- Bandpass.withZeropoint. See- ChromaticObjectdocstring for information about how- SEDnormalization affects- ChromaticObjectnormalization.
 
- class galsim.EmissionLine(wavelength, fwhm=1.0, flux=1.0, wave_type='nm', flux_type='fphotons', max_wave=1e+30, **kwargs)[source]
- atRedshift(redshift)[source]
- Return a new - EmissionLinewith redshifted wavelengths.- Parameters:
- redshift – The redshift for the returned - EmissionLine
- Returns:
- the redshifted - EmissionLine.