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

1import numpy as np 

2 

3 

4def comcamTessellate(side_length=0.7, overlap=0.11): 

5 """Tesselate the sphere with a square footprint 

6 

7 XXX--TODO: This really sucks at the poles, should add some different pole cap behavior. 

8 

9 Parameters 

10 ---------- 

11 side_length : float (0.7) 

12 The length of a side of the square (degrees) 

13 overlap : float (0.11) 

14 How much overlap to have in pointings 

15 

16 Returns 

17 ------- 

18 fields : numpy array 

19 With 'RA' and 'dec' keys that have the field positions in radians 

20 """ 

21 

22 # Convert to radians for all internal work 

23 side_length = np.radians(side_length) 

24 overlap = np.radians(overlap) 

25 

26 rotation_step = side_length/2. 

27 

28 step_size = side_length - overlap 

29 n_dec_steps = np.ceil(np.pi/2./step_size) 

30 dec_stripes = np.linspace(0, np.pi/2., n_dec_steps) 

31 

32 # Lists to hold the RA and dec coords 

33 ras = [] 

34 decs = [] 

35 running_step = 0. 

36 test_decs = np.array([-step_size, 0., step_size]) 

37 for dec in dec_stripes: 

38 # Find the largest circumfrance the squares will have to cover 

39 circum = np.max(2.*np.pi * np.cos(test_decs+dec)) 

40 n_ra_steps = np.ceil(circum/step_size) 

41 new_ras = np.linspace(0, 2.*np.pi, n_ra_steps) 

42 running_step += rotation_step/np.cos(dec) 

43 new_ras = (new_ras + running_step) % (2.*np.pi) 

44 ras.extend(new_ras.tolist()) 

45 new_decs = np.empty(new_ras.size) 

46 new_decs.fill(dec) 

47 decs.extend(new_decs.tolist()) 

48 

49 # That was the northern hemisphere, copy to do the south 

50 north = np.where(np.array(decs) > 0) 

51 decs.extend((-1.*np.array(decs))[north].tolist()) 

52 new_ras = -1.*np.array(ras)[north] 

53 new_ras = new_ras % (2.*np.pi) 

54 ras.extend(new_ras.tolist()) 

55 

56 names = ['RA', 'dec'] 

57 types = [float, float] 

58 fields = np.empty(len(ras), dtype=list(zip(names, types))) 

59 fields['RA'] = np.array(ras) 

60 fields['dec'] = np.array(decs) 

61 

62 return fields