Hide keyboard shortcuts

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 

5 

6__all__ = ["create_text_catalog"] 

7 

8 

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. 

13 

14 @param [in] obs is an ObservationMetaData specifying the pointing on which the catalog 

15 will be centered 

16 

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. 

19 

20 @param [in] raDisplacement is a numpy array listing the RA displacements of objects from the 

21 pointing's center in arcseconds 

22 

23 @param [in] decDisplacement is a numpy array listing the Dec displacements of objects from the 

24 pointings' center in arcseconds 

25 

26 @param [in] hlr is an optional list of half light radii in arcseconds 

27 

28 @param [in] mag_norm is an optional list of the objects' magnitude normalizations 

29 

30 @param [in] pa is an optional list of the objects' position angles in degrees 

31 """ 

32 

33 if os.path.exists(file_name): 

34 os.unlink(file_name) 

35 

36 raDisplacementList = radiansFromArcsec(raDisplacement) 

37 decDisplacementList = radiansFromArcsec(decDisplacement) 

38 

39 if hlr is None: 

40 hlr = [2.0]*len(raDisplacement) 

41 

42 if mag_norm is None: 

43 mag_norm = [20.0]*len(raDisplacement) 

44 

45 if pa is None: 

46 pa = [0.0]*len(raDisplacement) 

47 

48 

49 with open(file_name,'w') as outFile: 

50 outFile.write('# test_id ra dec hlr mag_norm pa\n') 

51 

52 for ix, (dx, dy, halfLight, magNorm, pp) in \ 

53 enumerate(zip(raDisplacementList, decDisplacementList, hlr, mag_norm, pa)): 

54 

55 rr = numpy.degrees(obs._pointingRA+dx) 

56 dd = numpy.degrees(obs._pointingDec+dy) 

57 

58 outFile.write('%d %.9f %.9f %.9f %.9f %.9f\n' % (ix, rr, dd, halfLight, magNorm, pp))