lsst.shapelet  13.0-4-g5a043c4+15
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
generator.py
Go to the documentation of this file.
1 from __future__ import absolute_import, division, print_function
2 from builtins import range, object
3 from .constants import HERMITE, LAGUERRE, computeSize
4 
5 class IndexGenerator(object):
6  """
7  Base class for shapelet index generators.
8  """
9 
10  __slots__ = "order", "size"
11 
12  @staticmethod
13  def make(self, order, basisType):
14  if basisType == HERMITE:
15  return HermiteIndexGenerator(order)
16  elif basisType == LAGUERRE:
17  return LaguerreIndexGenerator(order)
18 
19  def __init__(self, order):
20  self.order = order
21  self.size = computeSize(self.order)
22 
23  def __len__(self):
24  return self.size
25 
26 
28  """
29  Iterable that generates tuples of (i, nx, ny) in which:
30  - 'i' is the overall coefficient index for a 2-d shapelet expansion (just counts from zero)
31  - 'nx' is the order of the x expansion
32  - 'ny' is the order of the y expansion
33  """
34 
35  def __iter__(self):
36  i = 0
37  for n in range(0, self.order+1):
38  for nx in range(0, n+1):
39  yield (i, nx, n - nx)
40  i += 1
41 
42 
44  """
45  Iterable that generates tuples of (i, p, q, re) in which:
46  - 'i' is the overall coefficient index for a 2-d shapelet expansion (just counts from zero)
47  - 'p' and 'q' are the indices of the polar shapelet expansion (see BasisTypeEnum).
48  - 're' is True if this the real part of the coefficient
49  """
50 
51  def __iter__(self):
52  i = 0
53  for n in range(0, self.order+1):
54  p = n
55  q = 0
56  while p > q:
57  yield (i, p, q, True)
58  i += 1
59  yield (i, p, q, False)
60  i += 1
61  p -= 1
62  q += 1
63  if p == q:
64  yield (i, p, q, True)
65  i += 1
int computeSize(int order)
Return the size of the coefficient vector for the given order.
Definition: constants.h:97