Coverage for python/lsst/sims/catUtils/utils/testUtils.py : 72%

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
raDecFromAltAz, haversine, ObservationMetaData)
""" Accepts a list generated by traceback.extract_tb; determines if the last point in the sims code in the traceback is _connect_to_engine (from sims_catalogs_generation/../db/dbConnection.py), in which case, the failure was probably due to fatboy connectivity. """ return False
not isinstance(item, traceback.FrameSummary)): return False
return False
return False
galacticAv=None, galacticRv=None, bandpass=None): """ Read in an SED and calculat the number of ADU produced by that SED in a specified bandpass
Parameters ---------- sedName is a string specifying the file name of the SED
magNorm is the normalizing magnitude of the SED in the imsimBandpass
redshift is the redshift of the SED
internalAv is the Av due to internal dust of the source (if a galaxy)
internalRv is the Rv due to internal dust of the source (if a galaxy)
galacticAv is the Av due to Milky Way dust between observer and source
galacticRv is the Rv due to Milky Way dust between observer and source
bandpass is an intantiation of Bandpass representing the band in which the ADUs are measured
Returns ------- A float representing the number of ADUs measured in the bandpass """
imsimband = Bandpass() imsimband.imsimBandpass() sed = Sed() sed.readSED_flambda(sedName) fNorm = sed.calcFluxNorm(magNorm, imsimband) sed.multiplyFluxNorm(fNorm) if internalAv is not None and internalRv is not None: if internalAv != 0.0 and internalRv != 0.0: a_int, b_int = sed.setupCCMab() sed.addCCMDust(a_int, b_int, A_v=internalAv, R_v=internalRv)
if redshift is not None and redshift != 0.0: sed.redshiftSED(redshift, dimming=True)
a_int, b_int = sed.setupCCMab() sed.addCCMDust(a_int, b_int, A_v=galacticAv, R_v=galacticRv)
adu = sed.calcADU(bandpass, photParams=PhotometricParameters())
return adu
deltaRA=None, deltaDec=None, bandpass='r', m5=None, seeing=None, magnorm_min=17.0, delta_magnorm=4.0, **kwargs): """ Make a test database to storing cartoon information for the test phoSim input catalog to use.
The method will return an ObservationMetaData object guaranteed to encompass the objects in this database.
@param [in] filename is a string indicating the name of the DB file to be created
@param [in] size is the number of objects int he database
@param [in] seedVal is the seed passed to the random number generator
@param [in] radius is the radius (in degrees) of the field of view to be returned
@param [in] bandpass is the bandpas(es) of the observation to be passed to ObservationMetaData (optional)
@param [in] m5 is the m5 value(s) to be passed to ObservationMetaData (optional)
@param [in] seeing is the seeing value(s) in arcseconds to be passed to ObservationMetaData (optional)
@param [in] deltaRA/Dec are numpy arrays that indicate where (in relation to the center of the field of view) objects should be placed. These coordinates are in degrees. Specifying either of these paramters will overwrite size. If you only specify one of these parameters, the other will be set randomly. These parameters are optional.
@param [in] magnorm_min is the min magnorm (magNorms for sources in the database will be distributed according to a random deviate drawn from magnorm_min + random*delta_magnorm)
@param [in] delta_magnorm (see documentation for magnorm_min) """
os.unlink(filename)
# just an example of some valid SED file names
if len(deltaRA) != len(deltaDec): raise RuntimeError("WARNING in makePhoSimTestDB deltaRA and " "deltaDec have different lengths")
size = len(deltaRA) size = len(deltaDec)
# create the ObservationMetaData object
pointingDec=np.degrees(centerDec), rotSkyPos=np.degrees(rotSkyPos), bandpassName=bandpass, mjd=mjd, boundType = 'circle', boundLength = 2.0*radius, site=testSite, m5=m5, seeing=seeing)
obs_metadata._pointingRA, obs_metadata._pointingDec)
'moondec': moon_dec, 'moonalt': moon_alt, 'sunalt': sun_alt, 'dist2moon': dist2moon, 'rottelpos': np.degrees(rotTel)}
# Now begin building the database. # First create the tables. (galtileid int, galid int, bra real, bdec real, ra real, dec real, magnorm_bulge real, sedname_bulge text, a_b real, b_b real, pa_bulge real, bulge_n int, ext_model_b text, av_b real, rv_b real, u_ab real, g_ab real, r_ab real, i_ab real, z_ab real, y_ab real, redshift real, BulgeHalfLightRadius real)''') except: raise RuntimeError("Error creating galaxy_bulge table.")
(galtileid int, galid int, ra real, dec real, bra real, bdec real, dra real, ddec real, agnra real, agndec real, magnorm_bulge, magnorm_disk, magnorm_agn, sedname_bulge text, sedname_disk text, sedname_agn text, varParamStr text, a_b real, b_b real, pa_bulge real, bulge_n int, a_d real, b_d real, pa_disk real, disk_n int, ext_model_b text, av_b real, rv_b real, ext_model_d text, av_d real, rv_d real, u_ab real, g_ab real, r_ab real, i_ab real, z_ab real, y_ab real, redshift real, BulgeHalfLightRadius real, DiskHalfLightRadius real)''')
except: raise RuntimeError("Error creating galaxy table.")
(galtileid int, galid int, agnra real, agndec real, ra real, dec real, magnorm_agn real, sedname_agn text, varParamStr text, u_ab real, g_ab real, r_ab real, i_ab real, z_ab real, y_ab real, redshift real)''') except: raise RuntimeError("Error creating galaxy_agn table.")
(simobjid int, ra real, decl real, magNorm real, mudecl real, mura real, galacticAv real, vrad real, varParamStr text, sedFilename text, parallax real, ebv real)''') except: raise RuntimeError("Error creating StarAllForceseek table.")
# Now generate the data to be stored in the tables.
else: ra = np.degrees(centerRA) + deltaRA
else: dec = np.degrees(centerDec) + deltaDec
else: raStar = centerRA + np.radians(deltaRA)
else: decStar = centerDec + np.radians(deltaDec)
# write the data to the tables.
'%s', %f, %f, %f, %i, '%s', %f, %f, %f, %f, %f, %f, %f, %f, %f, %f)''' % \ (i, i, bra[i], bdec[i], ra[i], dec[i], magnorm_bulge[i], galaxy_seds[i%len(galaxy_seds)], a_b[i], b_b[i], pa_bulge[i], 4, 'CCM', av_b[i], rv_b[i], u_ab[i], g_ab[i], r_ab[i], i_ab[i], z_ab[i], y_ab[i], redshift[i], BulgeHalfLightRadius[i])
'pars': {'agn_tau': round(agn_tau[i], 4), 't0_mjd': round(t0_mjd[i], 4), 'agn_sfu': round(agn_sfu[i], 4), 'agn_sfg': round(agn_sfg[i], 4), 'agn_sfr': round(agn_sfr[i], 4), 'agn_sfi': round(agn_sfi[i], 4), 'agn_sfz': round(agn_sfz[i], 4), 'agn_sfy': round(agn_sfy[i], 4), 'seed': int(agnSeed[i])}}
'%s', '%s', '%s', '%s', %f, %f, %f, %i, %f, %f, %f, %i, '%s', %f, %f, '%s', %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f)''' % \ (i, i, ra[i], dec[i], bra[i], bdec[i], dra[i], ddec[i], agnra[i], agndec[i], magnorm_bulge[i], magnorm_disk[i], magnorm_agn[i], galaxy_seds[i%len(galaxy_seds)], galaxy_seds[i%len(galaxy_seds)], agn_sed, paramStr, a_b[i], b_b[i], pa_bulge[i], 4, a_d[i], b_d[i], pa_disk[i], 1, 'CCM', av_b[i], rv_b[i], 'CCM', av_d[i], rv_d[i], u_ab[i], g_ab[i], r_ab[i], i_ab[i], z_ab[i], y_ab[i], redshift[i], BulgeHalfLightRadius[i], DiskHalfLightRadius[i])
%f, %f, %f, %f, %f, %f, %f)''' % \ (i, i, agnra[i], agndec[i], ra[i], dec[i], magnorm_agn[i], agn_sed, paramStr, u_ab[i], g_ab[i], r_ab[i], i_ab[i], z_ab[i], y_ab[i], redshift[i])
(i, raStar[i], decStar[i], magnormStar[i], mudecl[i], mura[i], galacticAv[i], vrad[i], paramStr, star_seds[i%len(star_seds)], parallax[i], galacticAv[i]/3.1)
|