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