Coverage for tests/testUtils/TestUtilities.py : 19%

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
1from builtins import zip
2import os
3import numpy
4from lsst.sims.utils import radiansFromArcsec, icrsFromObserved
6__all__ = ["create_text_catalog"]
9def create_text_catalog(obs, file_name, raDisplacement, decDisplacement, \
10 hlr=None, mag_norm=None, pa=None):
11 """
12 Create a text file containing objects that can be read in by a fileDBObject class.
14 @param [in] obs is an ObservationMetaData specifying the pointing on which the catalog
15 will be centered
17 @param [in] file_name is the name of the file to be created. If a file already exists with that
18 name, throw an error.
20 @param [in] raDisplacement is a numpy array listing the RA displacements of objects from the
21 pointing's center in arcseconds
23 @param [in] decDisplacement is a numpy array listing the Dec displacements of objects from the
24 pointings' center in arcseconds
26 @param [in] hlr is an optional list of half light radii in arcseconds
28 @param [in] mag_norm is an optional list of the objects' magnitude normalizations
30 @param [in] pa is an optional list of the objects' position angles in degrees
31 """
33 if os.path.exists(file_name):
34 os.unlink(file_name)
36 raDisplacementList = radiansFromArcsec(raDisplacement)
37 decDisplacementList = radiansFromArcsec(decDisplacement)
39 if hlr is None:
40 hlr = [2.0]*len(raDisplacement)
42 if mag_norm is None:
43 mag_norm = [20.0]*len(raDisplacement)
45 if pa is None:
46 pa = [0.0]*len(raDisplacement)
49 with open(file_name,'w') as outFile:
50 outFile.write('# test_id ra dec hlr mag_norm pa\n')
52 for ix, (dx, dy, halfLight, magNorm, pp) in \
53 enumerate(zip(raDisplacementList, decDisplacementList, hlr, mag_norm, pa)):
55 rr = numpy.degrees(obs._pointingRA+dx)
56 dd = numpy.degrees(obs._pointingDec+dy)
58 outFile.write('%d %.9f %.9f %.9f %.9f %.9f\n' % (ix, rr, dd, halfLight, magNorm, pp))