22from __future__
import annotations
27from typing
import Iterator
34def _genPointsInRegion(region: Region, count: int) -> Iterator[SpherePoint]:
35 """Generate bunch of SpherePoints inside given 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 region: Region, count: int, visit_time: DateTime, *, start_id: int = 1
67 """Make a catalog containing a bunch of DiaObjects inside a region.
74 Number of records to generate.
82 catalog : `pandas.DataFrame`
83 Catalog of DiaObjects records.
87 Returned catalog only contains three columns - ``diaObjectId`, ``ra``, and
88 ``decl`` (
in degrees).
90 points = list(_genPointsInRegion(region, count))
93 ids = numpy.arange(start_id, len(points) + start_id, dtype=numpy.int64)
94 ras = numpy.array([sp.getRa().asDegrees()
for sp
in points], dtype=numpy.float64)
95 decls = numpy.array([sp.getDec().asDegrees()
for sp
in points], dtype=numpy.float64)
96 nDiaSources = numpy.ones(len(points), dtype=numpy.int32)
97 dt = visit_time.toPython()
98 df = pandas.DataFrame(
103 "nDiaSources": nDiaSources,
104 "lastNonForcedSource": dt,
111 objects: pandas.DataFrame, visit_time: DateTime, start_id: int = 0, ccdVisitId: int = 1
112) -> pandas.DataFrame:
113 """Make a catalog containing a bunch of DiaSources associated with the
118 objects : `pandas.DataFrame`
119 Catalog of DiaObject records.
123 Starting value for ``diaObjectId``.
125 Value
for ``ccdVisitId`` field.
129 catalog : `pandas.DataFrame`
130 Catalog of DiaSource records.
134 Returned catalog only contains small number of columns needed
for tests.
137 midPointTai = visit_time.get(system=DateTime.MJD)
138 df = pandas.DataFrame(
140 "diaSourceId": numpy.arange(start_id, start_id + nrows, dtype=numpy.int64),
141 "diaObjectId": objects[
"diaObjectId"],
142 "ccdVisitId": numpy.full(nrows, ccdVisitId, dtype=numpy.int64),
143 "parentDiaSourceId": 0,
145 "decl": objects[
"decl"],
146 "midPointTai": numpy.full(nrows, midPointTai, dtype=numpy.float64),
147 "flags": numpy.full(nrows, 0, dtype=numpy.int64),
154 objects: pandas.DataFrame, visit_time: DateTime, ccdVisitId: int = 1
155) -> pandas.DataFrame:
156 """Make a catalog containing a bunch of DiaForcedSources associated with
157 the input DiaObjects.
161 objects : `pandas.DataFrame`
162 Catalog of DiaObject records.
166 Value for ``ccdVisitId`` field.
170 catalog : `pandas.DataFrame`
171 Catalog of DiaForcedSource records.
175 Returned catalog only contains small number of columns needed
for tests.
178 midPointTai = visit_time.get(system=DateTime.MJD)
179 df = pandas.DataFrame(
181 "diaObjectId": objects[
"diaObjectId"],
182 "ccdVisitId": numpy.full(nrows, ccdVisitId, dtype=numpy.int64),
183 "midPointTai": numpy.full(nrows, midPointTai, dtype=numpy.float64),
184 "flags": numpy.full(nrows, 0, dtype=numpy.int64),
191 """Make a catalog containing a bunch of SSObjects.
196 Number of records to generate.
200 Value for ``flags`` column.
204 catalog : `pandas.DataFrame`
205 Catalog of SSObjects records.
209 Returned catalog only contains three columns - ``ssObjectId`, ``arc``,
212 ids = numpy.arange(start_id, count + start_id, dtype=numpy.int64)
213 arc = numpy.full(count, 0.001, dtype=numpy.float32)
214 flags_array = numpy.full(count, flags, dtype=numpy.int64)
215 df = pandas.DataFrame({"ssObjectId": ids,
"arc": arc,
"flags": flags_array})
Class for handling dates/times, including MJD, UTC, and TAI.
Point in an unspecified spherical coordinate system.
Region is a minimal interface for 2-dimensional regions on the unit sphere.
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 makeForcedSourceCatalog(pandas.DataFrame objects, DateTime visit_time, int ccdVisitId=1)
pandas.DataFrame makeObjectCatalog(Region region, int count, DateTime visit_time, *int start_id=1)
pandas.DataFrame makeSSObjectCatalog(int count, int start_id=1, int flags=0)