22from __future__
import annotations
25from typing
import Any, 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, **kwargs: Any
67 """Make a catalog containing a bunch of DiaObjects inside a region.
74 Number of records to generate.
80 Additional columns and their values to add to catalog.
84 catalog : `pandas.DataFrame`
85 Catalog of DiaObjects records.
89 Returned catalog only contains three columns - ``diaObjectId`, ``ra``,
and
90 ``decl`` (
in degrees).
92 points = list(_genPointsInRegion(region, count))
95 ids = numpy.arange(start_id, len(points) + start_id, dtype=numpy.int64)
96 ras = numpy.array([sp.getRa().asDegrees()
for sp
in points], dtype=numpy.float64)
97 decls = numpy.array([sp.getDec().asDegrees()
for sp
in points], dtype=numpy.float64)
98 nDiaSources = numpy.ones(len(points), dtype=numpy.int32)
99 dt = visit_time.toPython()
105 nDiaSources=nDiaSources,
106 lastNonForcedSource=dt,
108 df = pandas.DataFrame(data)
112def makeSourceCatalog(
113 objects: pandas.DataFrame, visit_time: DateTime, start_id: int = 0, ccdVisitId: int = 1
114) -> pandas.DataFrame:
115 """Make a catalog containing a bunch of DiaSources associated with the
120 objects : `pandas.DataFrame`
121 Catalog of DiaObject records.
125 Starting value for ``diaObjectId``.
127 Value
for ``ccdVisitId`` field.
131 catalog : `pandas.DataFrame`
132 Catalog of DiaSource records.
136 Returned catalog only contains small number of columns needed
for tests.
139 midPointTai = visit_time.get(system=DateTime.MJD)
140 df = pandas.DataFrame(
142 "diaSourceId": numpy.arange(start_id, start_id + nrows, dtype=numpy.int64),
143 "diaObjectId": objects[
"diaObjectId"],
144 "ccdVisitId": numpy.full(nrows, ccdVisitId, dtype=numpy.int64),
145 "parentDiaSourceId": 0,
147 "decl": objects[
"decl"],
148 "midPointTai": numpy.full(nrows, midPointTai, dtype=numpy.float64),
149 "flags": numpy.full(nrows, 0, dtype=numpy.int64),
155def makeForcedSourceCatalog(
156 objects: pandas.DataFrame, visit_time: DateTime, ccdVisitId: int = 1
157) -> pandas.DataFrame:
158 """Make a catalog containing a bunch of DiaForcedSources associated with
159 the input DiaObjects.
163 objects : `pandas.DataFrame`
164 Catalog of DiaObject records.
168 Value for ``ccdVisitId`` field.
172 catalog : `pandas.DataFrame`
173 Catalog of DiaForcedSource records.
177 Returned catalog only contains small number of columns needed
for tests.
180 midPointTai = visit_time.get(system=DateTime.MJD)
181 df = pandas.DataFrame(
183 "diaObjectId": objects[
"diaObjectId"],
184 "ccdVisitId": numpy.full(nrows, ccdVisitId, dtype=numpy.int64),
185 "midPointTai": numpy.full(nrows, midPointTai, dtype=numpy.float64),
186 "flags": numpy.full(nrows, 0, dtype=numpy.int64),
192def makeSSObjectCatalog(count: int, start_id: int = 1, flags: int = 0) -> pandas.DataFrame:
193 """Make a catalog containing a bunch of SSObjects.
198 Number of records to generate.
202 Value for ``flags`` column.
206 catalog : `pandas.DataFrame`
207 Catalog of SSObjects records.
211 Returned catalog only contains three columns - ``ssObjectId`, ``arc``,
214 ids = numpy.arange(start_id, count + start_id, dtype=numpy.int64)
215 arc = numpy.full(count, 0.001, dtype=numpy.float32)
216 flags_array = numpy.full(count, flags, dtype=numpy.int64)
217 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