Coverage for python/lsst/sims/catalogs/utils/testUtils.py : 73%

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
"makeGalTestDB", "myTestStars", "makeStarTestDB"]
try: chunk = next(results) except StopIteration: raise RuntimeError("No results were returned. Cannot run tests. Try increasing the size of the" " test database") return chunk
if first: fh.write(",".join([str(el) for el in chunk.dtype.names])+"\n") first = False for i in range(len(chunk)): fh.write(",".join([str(chunk[name][i]) for name in chunk.dtype.names])+"\n")
# From Shao 1996: "Spherical Sampling by Archimedes' Theorem" rng = np.random.RandomState(42)
""" Sample points in a focused field of view @param [in] raCenter is the RA at the center of the field of view in radians @param [in] decCenter is the Dec at the center of the field of view in radians @param [in] radius is the radius of the field of view in radians @param [in] rng is a random number generator (an instance of np.random.RandomState) @param [out] returns numpy arrays of ra and decs in radians """ if rng is None: rng = np.random.RandomState(1453)
theta = rng.random_sample(size) rc = np.radians(raCenter) dc = np.radians(decCenter) rr = np.radians(radius)*rng.random_sample(size) ra = np.empty(size) dec = np.empty(size) for i, th in enumerate(theta): ra[i] = rc + rr*np.cos(th) dec[i] = dc + rr*np.sin(th)
return ra, dec
# Make this implausibly large? ('raJ2000', 'ra*%f'%(np.pi/180.)), ('decJ2000', 'decl*%f'%(np.pi/180.)), ('umag', None), ('gmag', None), ('rmag', None), ('imag', None), ('zmag', None), ('ymag', None), ('magNormAgn', 'mag_norm_agn', None), ('magNormDisk', 'mag_norm_disk', None), ('magNormBulge', 'mag_norm_bulge', None), ('redshift', None), ('a_disk', None), ('b_disk', None), ('a_bulge', None), ('b_bulge', None)]
raCenter=None, decCenter=None, radius=None, **kwargs): """ Make a test database to serve information to the myTestGals object @param size: Number of rows in the database @param seedVal: Random seed to use
@param raCenter,decCenter: the center of the field of view in degrees (optional) @param radius: the radius of the field of view in degrees (optional)
These last optional parameters exist in the event that you want to make sure that the objects are clustered around the bore site for a unit test """ (id int, ra real, decl real, umag real, gmag real, rmag real, imag real, zmag real, ymag real, mag_norm_agn real, mag_norm_bulge real, mag_norm_disk real, redshift real, a_disk real, b_disk real, a_bulge real, b_bulge real, varParamStr text)''') except: raise RuntimeError("Error creating database.")
else: rng = np.random.RandomState(3321)
else: rc = np.radians(raCenter) dc = np.radians(decCenter) ra, dec = sampleFocus(size, rc, dc, radius, rng=rng) # Typical colors for main sequece stars
# assume mag norm is g-band (which is close to true) np.power(10, mag_norm_agn/-2.5))
# note that we are storing period and amp at a fixed string length # to facilitate a consistent dtype when we read them back in # via DBObject
%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, '%s')''' % \ (i, np.degrees(ra[i]), np.degrees(dec[i]), umag[i], gmag[i], rmag[i], imag[i], zmag[i], ymag[i], mag_norm_agn[i], mag_norm_bulge[i], mag_norm_disk[i], redshift[i], a_disk[i], b_disk[i], a_bulge[i], b_bulge[i], paramStr)
# Make this implausibly large? ('raJ2000', 'ra*%f'%(np.pi/180.)), ('decJ2000', 'decl*%f'%(np.pi/180.)), ('parallax', 'parallax*%.15f'%(np.pi/(648000000.0))), ('properMotionRa', 'properMotionRa*%.15f'%(np.pi/180)), ('properMotionDec', 'properMotionDec*%.15f'%(np.pi/180.)), ('umag', None), ('gmag', None), ('rmag', None), ('imag', None), ('zmag', None), ('ymag', None), ('magNorm', 'mag_norm', float)]
raCenter=None, decCenter=None, radius=None, **kwargs): """ Make a test database to serve information to the myTestStars object @param size: Number of rows in the database @param seedVal: Random seed to use
@param raCenter,decCenter: the center of the field of view in degrees (optional) @param radius: the radius of the field of view in degrees (optional)
These last optional parameters exist in the event that you want to make sure that the objects are clustered around the bore site for a unit test """ (id int, ra real, decl real, umag real, gmag real, rmag real, imag real, zmag real, ymag real, mag_norm real, radialVelocity real, properMotionDec real, properMotionRa real, parallax real, varParamStr text, ebv real)''') except: raise RuntimeError("Error creating database.")
else:
else: rc = np.radians(raCenter) dc = np.radians(decCenter) ra, dec = sampleFocus(size, rc, dc, radius, rng=rng)
# Typical colors # assume mag norm is g-band (which is close to true)
# note that we are storing period and amp at a fixed string length # to facilitate a consistent dtype when we read them back in # via DBObject
%f, %f, %f, %f, %.15f, %.15f, %.15f, '%s', %f)''' % \ (i, np.degrees(ra[i]), np.degrees(dec[i]), umag[i], gmag[i], rmag[i], imag[i], zmag[i], ymag[i], mag_norm[i], radVel[i], pmRa[i], pmDec[i], parallax[i], paramStr, ebv[i])
|