22 from __future__
import annotations
27 from typing
import Iterator
34 def _genPointsInRegion(region: Region, count: int) -> Iterator[SpherePoint]:
35 """Generate bunch of SpherePoints inside given region.
39 region : `lsst.sphgeom.Region`
42 Number of points to generate.
46 Returned points are random but not necessarily uniformly distributed.
48 bbox = region.getBoundingBox()
49 center = bbox.getCenter()
50 center_lon = center.getLon().asRadians()
51 center_lat = center.getLat().asRadians()
52 width = bbox.getWidth().asRadians()
53 height = bbox.getHeight().asRadians()
55 lon = random.uniform(center_lon - width / 2, center_lon + width / 2)
56 lat = random.uniform(center_lat - height / 2, center_lat + height / 2)
57 lonlat = LonLat.fromRadians(lon, lat)
59 if region.contains(uv3d):
65 """Make a catalog containing a bunch of DiaObjects inside a region.
69 region : `lsst.sphgeom.Region`
72 Number of records to generate.
76 catalog : `pandas.DataFrame`
77 Catalog of DiaObjects records.
81 Returned catalog only contains three columns - ``diaObjectId`, ``ra``, and
82 ``decl`` (in degrees).
84 points =
list(_genPointsInRegion(region, count))
87 ids = numpy.arange(1, len(points) + 1, dtype=numpy.int64)
88 ras = numpy.array([sp.getRa().asDegrees()
for sp
in points], dtype=numpy.float64)
89 decls = numpy.array([sp.getDec().asDegrees()
for sp
in points], dtype=numpy.float64)
90 df = pandas.DataFrame({
"diaObjectId": ids,
97 start_id: int = 0, ccdVisitId: int = 1) -> pandas.DataFrame:
98 """Make a catalog containing a bunch of DiaSources associated with the
103 objects : `pandas.DataFrame`
104 Catalog of DiaObject records.
105 visit_time : `lsst.daf.base.DateTime`
108 Starting value for ``diaObjectId``.
110 Value for ``ccdVisitId`` field.
114 catalog : `pandas.DataFrame`
115 Catalog of DiaSource records.
119 Returned catalog only contains small number of columns needed for tests.
122 midPointTai = visit_time.get(system=DateTime.MJD)
123 df = pandas.DataFrame({
124 "diaSourceId": numpy.arange(start_id, start_id + nrows, dtype=numpy.int64),
125 "diaObjectId": objects[
"diaObjectId"],
126 "ccdVisitId": numpy.full(nrows, ccdVisitId, dtype=numpy.int64),
127 "parentDiaSourceId": 0,
129 "decl": objects[
"decl"],
130 "midPointTai": numpy.full(nrows, midPointTai, dtype=numpy.float64),
131 "flags": numpy.full(nrows, 0, dtype=numpy.int64),
137 ccdVisitId: int = 1) -> pandas.DataFrame:
138 """Make a catalog containing a bunch of DiaFourceSources associated with
139 the input DiaObjects.
143 objects : `pandas.DataFrame`
144 Catalog of DiaObject records.
145 visit_time : `lsst.daf.base.DateTime`
148 Value for ``ccdVisitId`` field.
152 catalog : `pandas.DataFrame`
153 Catalog of DiaForcedSource records.
157 Returned catalog only contains small number of columns needed for tests.
160 midPointTai = visit_time.get(system=DateTime.MJD)
161 df = pandas.DataFrame({
162 "diaObjectId": objects[
"diaObjectId"],
163 "ccdVisitId": numpy.full(nrows, ccdVisitId, dtype=numpy.int64),
164 "midPointTai": numpy.full(nrows, midPointTai, dtype=numpy.float64),
165 "flags": numpy.full(nrows, 0, dtype=numpy.int64),
Point in an unspecified spherical coordinate system.
UnitVector3d is a unit vector in ℝ³ with components stored in double precision.
daf::base::PropertyList * list
pandas.DataFrame makeSourceCatalog(pandas.DataFrame objects, DateTime visit_time, int start_id=0, int ccdVisitId=1)
pandas.DataFrame makeObjectCatalog(Region region, int count)
pandas.DataFrame makeForcedSourceCatalog(pandas.DataFrame objects, DateTime visit_time, int ccdVisitId=1)