Coverage for python/lsst/sims/photUtils/utils/testUtils.py : 20%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2This file defines some test catalog and DBObject classes for use with unit tests.
4To date (30 October 2014) testPhotometry.py and testCosmology.py import from this module
5"""
7import numpy
8from lsst.sims.photUtils import calcSkyCountsPerPixelForM5, Sed
10__all__ = ["setM5",
11 "comovingDistanceIntegrand", "cosmologicalOmega"]
13def setM5(m5target, skysed, totalBandpass, hardware,
14 photParams,
15 FWHMeff = None):
16 """
17 Take an SED representing the sky and normalize it so that
18 m5 (the magnitude at which an object is detected in this
19 bandpass at 5-sigma) is set to some specified value.
21 The 5-sigma limiting magnitude (m5) for an observation is
22 determined by a combination of the telescope and camera parameters
23 (such as diameter of the mirrors and the readnoise) together with the
24 sky background. This method (setM5) scales a provided sky background
25 Sed so that an observation would have a target m5 value, for the
26 provided hardware parameters. Using the resulting Sed in the
27 'calcM5' method will return this target value for m5.
29 @param [in] the desired value of m5
31 @param [in] skysed is an instantiation of the Sed class representing
32 sky emission
34 @param [in] totalBandpass is an instantiation of the Bandpass class
35 representing the total throughput of the telescope (instrumentation
36 plus atmosphere)
38 @param [in] hardware is an instantiation of the Bandpass class representing
39 the throughput due solely to instrumentation.
41 @param [in] photParams is an instantiation of the
42 PhotometricParameters class that carries details about the
43 photometric response of the telescope.
45 @param [in] FWHMeff in arcseconds
47 @param [out] returns an instantiation of the Sed class that is the skysed renormalized
48 so that m5 has the desired value.
50 Note that the returned SED will be renormalized such that calling the method
51 self.calcADU(hardwareBandpass) on it will yield the number of counts per square
52 arcsecond in a given bandpass.
53 """
55 #This is based on the LSST SNR document (v1.2, May 2010)
56 #www.astro.washington.edu/users/ivezic/Astr511/LSST_SNRdoc.pdf
58 if FWHMeff is None:
59 FWHMeff = LSSTdefaults().FWHMeff('r')
61 skyCountsTarget = calcSkyCountsPerPixelForM5(m5target, totalBandpass, FWHMeff=FWHMeff,
62 photParams=photParams)
64 skySedOut = Sed(wavelen=numpy.copy(skysed.wavelen),
65 flambda=numpy.copy(skysed.flambda))
67 skyCounts = skySedOut.calcADU(hardware, photParams=photParams) \
68 * photParams.platescale * photParams.platescale
69 skySedOut.multiplyFluxNorm(skyCountsTarget/skyCounts)
71 return skySedOut
74def cosmologicalOmega(redshift, H0, Om0, Ode0 = None, Og0=0.0, Onu0=0.0, w0=-1.0, wa=0.0):
75 """
76 A method to compute the evolution of the Hubble and density parameters
77 with redshift (as a baseline against which to test the cosmology unittest)
79 @param [in] redshift is the redshift at which the output is desired
81 @param [in] H0 is the Hubble parameter at the present epoch in km/s/Mpc
83 @param [in] Om0 is the density parameter (fraction of critical) for matter at the
84 present epoch
86 @param [in] Ode0 is the density parameter for Dark Energy at the present epoch.
87 If left as None, will be set to 1.0-Om0-Og0-Onu0 (i.e. a flat universe)
89 @param [in] Og0 is the density parameter for photons at the present epoch
91 @param [in] Onu0 is the density parameter for neutrinos at the present epoch
92 (assume massless neutrinos)
94 @param [in] w0 is a parameter for calculating the equation of state for Dark Energy
95 w = w0 + wa * z/(1 + z)
97 @param [in] wa is the other parameter for calculating the equation of state for Dark
98 Energy
100 @returns Hubble parameter at desired redshift (in km/s/Mpc)
102 @returns matter density paramter at desired redshift
104 @returns Dark Energy density parameter at desired redshift
106 @returns photon density parameter at desired redshift
108 @returns neutrino density parameter at desired redshift
110 @returns curvature density parameter at desired redshift
111 """
113 if Ode0 is None:
114 Ode0 = 1.0 - Om0 - Og0 - Onu0
116 Ok0 = 1.0 - Om0 - Ode0 - Og0 - Onu0
118 aa = 1.0/(1.0+redshift)
119 Omz = Om0 * numpy.power(1.0+redshift, 3)
120 Ogz = Og0 * numpy.power(1.0+redshift, 4)
121 Onuz = Onu0 * numpy.power(1.0+redshift, 4)
122 Okz = Ok0 * numpy.power(1.0+redshift, 2)
123 Odez = Ode0 * numpy.exp(-3.0*(numpy.log(aa)*(w0 + wa +1.0) - wa*(aa - 1.0)))
125 Ototal = Omz + Ogz + Onuz + Odez + Okz
127 return H0*numpy.sqrt(Ototal), Omz/Ototal, Odez/Ototal, Ogz/Ototal, Onuz/Ototal, Okz/Ototal
129def comovingDistanceIntegrand(redshift, H0, Om0, Ode0, Og0, Onu0, w0, wa):
130 """
131 The integrand of comoving distance (as a baseline for cosmology unittest)
133 @param [in] redshift is the redshift at which to evaluate the integrand
135 @param [in] H0 is the Hubble parameter at the present epoch in km/s/Mpc
137 @param [in] Om0 is the density parameter (fraction of critical) for matter at the
138 present epoch
140 @param [in] Ode0 is the density parameter for Dark Energy at the present epoch.
142 @param [in] Og0 is the density parameter for photons at the present epoch
144 @param [in] Onu0 is the density parameter for neutrinos at the present epoch
145 (assume massless neutrinos)
147 @param [in] w0 is a parameter for calculating the equation of state for Dark Energy
148 w = w0 + wa * z/(1 + z)
150 @param [in] wa is the other parameter for calculating the equation of state for Dark
151 Energy
153 @returns 1/(Hubble parameter at desired redshift in km/s/Mpc)
155 """
156 hh, mm, de, gg, nn, kk = cosmologicalOmega(redshift, H0, Om0, Ode0=Ode0,
157 Og0=Og0, Onu0=Onu0, w0=w0, wa=wa)
158 return 1.0/hh