Bandpass Filters
- class galsim.Bandpass(throughput, wave_type, blue_limit=None, red_limit=None, zeropoint=None, interpolant='linear', _wave_list=None, _tp=None)[source]
- Simple bandpass object, which models the transmission fraction of incident light as a function of wavelength, for either an entire optical path (e.g., atmosphere, reflecting and refracting optics, filters, CCD quantum efficiency), or some intermediate piece thereof. Bandpasses representing individual components may be combined through the - *operator to form a new Bandpass object representing the composite optical path.- Bandpasses are callable, returning dimensionless throughput as a function of wavelength in nm. - Bandpasses are immutable; all transformative methods return new Bandpasses, and leave their originating Bandpasses unaltered. - Bandpasses require - blue_limitand- red_limitattributes, which may either be explicitly set at initialization, or are inferred from the initializing- LookupTableor 2-column file.- Outside of the wavelength interval between - blue_limitand- red_limit, the throughput is returned as zero, regardless of the- throughputinput parameter.- Bandpasses may be multiplied by other Bandpasses, functions, scalars, or - SEDinstances. The product of a Bandpass with an- SEDis a new- SED.- The Bandpass effective wavelength is stored in the python property - effective_wavelength. We use throughput-weighted average wavelength (which is independent of any- SED) as our definition for effective wavelength.- For Bandpasses defined using a - LookupTable, a numpy.array of wavelengths,- wave_list, defining the table is maintained. Bandpasses defined as products of two other Bandpasses will define their- wave_listas the union of multiplicand- wave_listvalues, although limited to the range between the new product- blue_limitand- red_limit. (This implementation detail may affect the choice of integrator used to draw a- ChromaticObject.)- The input parameter, throughput, 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 : '+throughput), e.g.:- throughput = '0.8 + 0.2 * (wave-800)' 
 - The argument of - throughputwill be the wavelength in units specified by- wave_type. (See below.) The output should be the dimensionless throughput at that wavelength. (Note we use- waverather than- lambda, since- lambdais a python reserved word.)- The argument - wave_typespecifies the units to assume for wavelength and must be one of ‘nm’, ‘nanometer’, ‘nanometers’, ‘A’, ‘Ang’, ‘Angstrom’, or ‘Angstroms’, or an astropy distance unit. (For the string values, case is unimportant.) If given as floats, blue_limit and red_limit are taken to be in these units as well. (If given as an astropy Quantity, then the units are taken directly and converted to- wave_type.)- Note that the - wave_typeparameter does not propagate into other methods of Bandpass. For instance,- Bandpass.__call__assumes its input argument is in nanometers.- Finally, a Bandpass may have zeropoint attribute, which is a float used to convert flux (in photons/s/cm^2) to magnitudes: - mag = -2.5*log10(flux) + zeropoint - You can either set the zeropoint at initialization, or via the - withZeropointmethod. Note that the zeropoint attribute does not propagate if you get a new Bandpass by multiplying or dividing an old Bandpass.- Parameters:
- throughput – Function defining the throughput at each wavelength. See above for valid options for this parameter. 
- wave_type – The units to use for the wavelength argument of the - throughputfunction. See above for details.
- blue_limit – Hard cut off of bandpass on the blue side. [default: None, but required if throughput is not a - LookupTableor file. See above.]
- red_limit – Hard cut off of bandpass on the red side. [default: None, but required if throughput is not a - LookupTableor file. See above.]
- zeropoint – Set the zero-point for this Bandpass. Here, this can only be a float value. See the method - withZeropointfor other options for how to set this using a particular spectrum (AB, Vega, etc.) [default: None]
- interpolant – If reading from a file, what interpolant to use. [default: ‘linear’] 
 
 - __call__(wave)[source]
- Return dimensionless throughput of bandpass at given wavelength in nanometers. - Note that outside of the wavelength range defined by the - blue_limitand- red_limitattributes, the throughput is assumed to be zero.- Parameters:
- wave – Wavelength in nanometers. (Either a scalar or a numpy array) 
- Returns:
- the dimensionless throughput. 
 
 - calculateEffectiveWavelength(precise=False)[source]
- Calculate, store, and return the effective wavelength for this bandpass. - We define the effective wavelength as the throughput-weighted average wavelength, which is SED-independent. Units are nanometers. - Parameters:
- precise – Optionally use a more precise integration method when the bandpass uses a - LookupTablerather than the normal trapezoid rule. [default: False]
 
 - property effective_wavelength
- The effective wavelength of the - Bandpass.- An alias for - self.calculateEffectiveWavelength().
 - thin(rel_err=0.0001, trim_zeros=True, preserve_range=True, fast_search=True, preserve_zp=True)[source]
- Thin out the internal wavelengths of a - Bandpassthat uses a- LookupTable.- If the bandpass was initialized with a - LookupTableor from a file (which internally creates a- LookupTable), this function removes tabulated values while keeping the integral over the set of tabulated values still accurate to the given relative error.- That is, the integral of the bandpass function is preserved to a relative precision of - rel_err, while eliminating as many internal wavelength values as possible. This process will usually help speed up integrations using this bandpass. You should weigh the speed improvements against your fidelity requirements for your particular use case.- By default, this routine will preserve the zeropoint of the original bandpass by assigning it to the new thinned bandpass. The justification for this choice is that when using an AB zeropoint, a typical optical bandpass, and the default thinning - rel_errvalue, the zeropoint for the new and thinned bandpasses changes by 10^-6. However, if you are thinning a lot, and/or want to do extremely precise tests, you can set- preserve_zp=Falseand then recalculate the zeropoint after thinning.- Parameters:
- rel_err – The relative error allowed in the integral over the throughput function. [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- Bandpassbe 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, and may also be somewhat more robust when computing an - SEDflux through a- Bandpasswhen a significant fraction of the integrated flux passes through low throughput bandpass light leaks. [default: True]
- preserve_zp – If True, the new thinned - Bandpasswill be assigned the same zeropoint as the original. If False, the new thinned- Bandpasswill have a zeropoint of None. [default: True]
 
- Returns:
- the thinned - Bandpass.
 
 - truncate(blue_limit=None, red_limit=None, relative_throughput=None, preserve_zp='auto')[source]
- Return a bandpass with its wavelength range truncated. - This function truncate the range of the bandpass either explicitly (with - blue_limitor- red_limitor both) or automatically, just trimming off leading and trailing wavelength ranges where the relative throughput is less than some amount (- relative_throughput).- This second option using relative_throughput is only available for bandpasses initialized with a - LookupTableor from a file, not when using a regular python function or a string evaluation.- This function does not remove any intermediate wavelength ranges, but see thin() for a method that can thin out the intermediate values. - When truncating a bandpass that already has an assigned zeropoint, there are several possibilities for what should happen to the new (returned) bandpass by default. If red and/or blue limits are given, then the new bandpass will have no assigned zeropoint because it is difficult to predict what should happen if the bandpass is being arbitrarily truncated. If - relative_throughputis given, often corresponding to low-level truncation that results in little change in observed quantities, then the new bandpass is assigned the same zeropoint as the original. This default behavior is called ‘auto’. The user can also give boolean True or False values.- Parameters:
- blue_limit – Truncate blue side of bandpass at this wavelength in nm. [default: None] 
- red_limit – Truncate red side of bandpass at this wavelength in nm. [default: None] 
- relative_throughput – Truncate leading or trailing wavelengths that are below this relative throughput level. (See above for details.) Either - blue_limitand/or- red_limitshould be supplied, or- relative_throughputshould be supplied – but- relative_throughputshould not be combined with one of the limits. [default: None]
- preserve_zp – If True, the new truncated - Bandpasswill be assigned the same zeropoint as the original. If False, the new truncated- Bandpasswill have a zeropoint of None. If ‘auto’, the new truncated- Bandpasswill have the same zeropoint as the original when truncating using- relative_throughput, but will have a zeropoint of None when truncating using ‘blue_limit’ and/or ‘red_limit’. [default: ‘auto’]
 
- Returns:
- the truncated - Bandpass.
 
 - withZeropoint(zeropoint)[source]
- Assign a zeropoint to this - Bandpass.- A bandpass zeropoint is a float used to convert flux (in photons/s/cm^2) to magnitudes: - mag = -2.5*log10(flux) + zeropoint - Note that the zeropoint attribute does not propagate if you get a new - Bandpassby multiplying or dividing an old- Bandpass.- The - zeropointargument can take a variety of possible forms:- a number, which will be the zeropoint 
- a - galsim.SED. In this case, the zeropoint is set such that the magnitude of the supplied- SEDthrough the- Bandpassis 0.0
- the string ‘AB’. In this case, use an AB zeropoint. 
- the string ‘Vega’. Use a Vega zeropoint. 
- the string ‘ST’. Use a HST STmag zeropoint. 
 - Parameters:
- zeropoint – See above for valid input options 
- Returns:
- new - Bandpasswith zeropoint set.