Coverage for python/lsst/sims/featureScheduler/utils/comcamTessellate.py : 6%

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
4def comcamTessellate(side_length=0.7, overlap=0.11):
5 """Tesselate the sphere with a square footprint
7 XXX--TODO: This really sucks at the poles, should add some different pole cap behavior.
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
16 Returns
17 -------
18 fields : numpy array
19 With 'RA' and 'dec' keys that have the field positions in radians
20 """
22 # Convert to radians for all internal work
23 side_length = np.radians(side_length)
24 overlap = np.radians(overlap)
26 rotation_step = side_length/2.
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)
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())
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())
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)
62 return fields