LSST Applications g00274db5b6+edbf708997,g00d0e8bbd7+edbf708997,g199a45376c+5137f08352,g1fd858c14a+1d4b6db739,g262e1987ae+f4d9505c4f,g29ae962dfc+7156fb1a53,g2cef7863aa+73c82f25e4,g35bb328faa+edbf708997,g3e17d7035e+5b3adc59f5,g3fd5ace14f+852fa6fbcb,g47891489e3+6dc8069a4c,g53246c7159+edbf708997,g64539dfbff+9f17e571f4,g67b6fd64d1+6dc8069a4c,g74acd417e5+ae494d68d9,g786e29fd12+af89c03590,g7ae74a0b1c+a25e60b391,g7aefaa3e3d+536efcc10a,g7cc15d900a+d121454f8d,g87389fa792+a4172ec7da,g89139ef638+6dc8069a4c,g8d7436a09f+28c28d8d6d,g8ea07a8fe4+db21c37724,g92c671f44c+9f17e571f4,g98df359435+b2e6376b13,g99af87f6a8+b0f4ad7b8d,gac66b60396+966efe6077,gb88ae4c679+7dec8f19df,gbaa8f7a6c5+38b34f4976,gbf99507273+edbf708997,gc24b5d6ed1+9f17e571f4,gca7fc764a6+6dc8069a4c,gcc769fe2a4+97d0256649,gd7ef33dd92+6dc8069a4c,gdab6d2f7ff+ae494d68d9,gdbb4c4dda9+9f17e571f4,ge410e46f29+6dc8069a4c,geaed405ab2+e194be0d2b,w.2025.47
LSST Data Management Base Package
Loading...
Searching...
No Matches
lsst.dax.apdb.apdb.Apdb Class Reference
Inheritance diagram for lsst.dax.apdb.apdb.Apdb:
lsst.dax.apdb.cassandra.apdbCassandra.ApdbCassandra lsst.dax.apdb.sql.apdbSql.ApdbSql

Public Member Functions

Apdb from_config (cls, ApdbConfig config)
 
Apdb from_uri (cls, ResourcePathExpression uri)
 
ApdbConfig getConfig (self)
 
Table|None tableDef (self, ApdbTables table)
 
pandas.DataFrame getDiaObjects (self, Region region)
 
pandas.DataFrame|None getDiaSources (self, Region region, Iterable[int]|None object_ids, astropy.time.Time visit_time, astropy.time.Time|None start_time=None)
 
pandas.DataFrame|None getDiaForcedSources (self, Region region, Iterable[int]|None object_ids, astropy.time.Time visit_time, astropy.time.Time|None start_time=None)
 
bool containsVisitDetector (self, int visit, int detector, Region region, astropy.time.Time visit_time)
 
None store (self, astropy.time.Time visit_time, pandas.DataFrame objects, pandas.DataFrame|None sources=None, pandas.DataFrame|None forced_sources=None)
 
None reassignDiaSources (self, Mapping[int, int] idMap)
 
None dailyJob (self)
 
int countUnassociatedObjects (self)
 
ApdbMetadata metadata (self)
 
ApdbAdmin admin (self)
 

Detailed Description

Abstract interface for APDB.

Definition at line 46 of file apdb.py.

Member Function Documentation

◆ admin()

ApdbAdmin lsst.dax.apdb.apdb.Apdb.admin ( self)
Object providing adminitrative interface for APDB (`ApdbAdmin`).

Reimplemented in lsst.dax.apdb.cassandra.apdbCassandra.ApdbCassandra, and lsst.dax.apdb.sql.apdbSql.ApdbSql.

Definition at line 363 of file apdb.py.

363 def admin(self) -> ApdbAdmin:
364 """Object providing adminitrative interface for APDB (`ApdbAdmin`)."""
365 raise NotImplementedError()

◆ containsVisitDetector()

bool lsst.dax.apdb.apdb.Apdb.containsVisitDetector ( self,
int visit,
int detector,
Region region,
astropy.time.Time visit_time )
Test whether any sources for a given visit-detector are present in
the APDB.

Parameters
----------
visit, detector : `int`
    The ID of the visit-detector to search for.
region : `lsst.sphgeom.Region`
    Region corresponding to the visit/detector combination.
visit_time : `astropy.time.Time`
    Visit time (as opposed to visit processing time). This can be any
    timestamp in the visit timespan, e.g. its begin or end time.

Returns
-------
present : `bool`
    `True` if at least one DiaSource or DiaForcedSource record
    may exist for the specified observation, `False` otherwise.

Reimplemented in lsst.dax.apdb.cassandra.apdbCassandra.ApdbCassandra, and lsst.dax.apdb.sql.apdbSql.ApdbSql.

Definition at line 241 of file apdb.py.

247 ) -> bool:
248 """Test whether any sources for a given visit-detector are present in
249 the APDB.
250
251 Parameters
252 ----------
253 visit, detector : `int`
254 The ID of the visit-detector to search for.
255 region : `lsst.sphgeom.Region`
256 Region corresponding to the visit/detector combination.
257 visit_time : `astropy.time.Time`
258 Visit time (as opposed to visit processing time). This can be any
259 timestamp in the visit timespan, e.g. its begin or end time.
260
261 Returns
262 -------
263 present : `bool`
264 `True` if at least one DiaSource or DiaForcedSource record
265 may exist for the specified observation, `False` otherwise.
266 """
267 raise NotImplementedError()
268

◆ countUnassociatedObjects()

int lsst.dax.apdb.apdb.Apdb.countUnassociatedObjects ( self)
Return the number of DiaObjects that have only one DiaSource
associated with them.

Used as part of ap_verify metrics.

Returns
-------
count : `int`
    Number of DiaObjects with exactly one associated DiaSource.

Notes
-----
This method can be very inefficient or slow in some implementations.

Reimplemented in lsst.dax.apdb.cassandra.apdbCassandra.ApdbCassandra, and lsst.dax.apdb.sql.apdbSql.ApdbSql.

Definition at line 338 of file apdb.py.

338 def countUnassociatedObjects(self) -> int:
339 """Return the number of DiaObjects that have only one DiaSource
340 associated with them.
341
342 Used as part of ap_verify metrics.
343
344 Returns
345 -------
346 count : `int`
347 Number of DiaObjects with exactly one associated DiaSource.
348
349 Notes
350 -----
351 This method can be very inefficient or slow in some implementations.
352 """
353 raise NotImplementedError()
354

◆ dailyJob()

None lsst.dax.apdb.apdb.Apdb.dailyJob ( self)
Implement daily activities like cleanup/vacuum.

What should be done during daily activities is determined by
specific implementation.

Reimplemented in lsst.dax.apdb.cassandra.apdbCassandra.ApdbCassandra, and lsst.dax.apdb.sql.apdbSql.ApdbSql.

Definition at line 329 of file apdb.py.

329 def dailyJob(self) -> None:
330 """Implement daily activities like cleanup/vacuum.
331
332 What should be done during daily activities is determined by
333 specific implementation.
334 """
335 raise NotImplementedError()
336

◆ from_config()

Apdb lsst.dax.apdb.apdb.Apdb.from_config ( cls,
ApdbConfig config )
Create Ppdb instance from configuration object.

Parameters
----------
config : `ApdbConfig`
    Configuration object, type of this object determines type of the
    Apdb implementation.

Returns
-------
apdb : `apdb`
    Instance of `Apdb` class.

Definition at line 50 of file apdb.py.

50 def from_config(cls, config: ApdbConfig) -> Apdb:
51 """Create Ppdb instance from configuration object.
52
53 Parameters
54 ----------
55 config : `ApdbConfig`
56 Configuration object, type of this object determines type of the
57 Apdb implementation.
58
59 Returns
60 -------
61 apdb : `apdb`
62 Instance of `Apdb` class.
63 """
64 return make_apdb(config)
65

◆ from_uri()

Apdb lsst.dax.apdb.apdb.Apdb.from_uri ( cls,
ResourcePathExpression uri )
Make Apdb instance from a serialized configuration.

Parameters
----------
uri : `~lsst.resources.ResourcePathExpression`
    URI or local file path pointing to a file with serialized
    configuration, or a string with a "label:" prefix. In the latter
    case, the configuration will be looked up from an APDB index file
    using the label name that follows the prefix. The APDB index file's
    location is determined by the ``DAX_APDB_INDEX_URI`` environment
    variable.

Returns
-------
apdb : `apdb`
    Instance of `Apdb` class, the type of the returned instance is
    determined by configuration.

Definition at line 67 of file apdb.py.

67 def from_uri(cls, uri: ResourcePathExpression) -> Apdb:
68 """Make Apdb instance from a serialized configuration.
69
70 Parameters
71 ----------
72 uri : `~lsst.resources.ResourcePathExpression`
73 URI or local file path pointing to a file with serialized
74 configuration, or a string with a "label:" prefix. In the latter
75 case, the configuration will be looked up from an APDB index file
76 using the label name that follows the prefix. The APDB index file's
77 location is determined by the ``DAX_APDB_INDEX_URI`` environment
78 variable.
79
80 Returns
81 -------
82 apdb : `apdb`
83 Instance of `Apdb` class, the type of the returned instance is
84 determined by configuration.
85 """
86 config = ApdbConfig.from_uri(uri)
87 return make_apdb(config)
88

◆ getConfig()

ApdbConfig lsst.dax.apdb.apdb.Apdb.getConfig ( self)
Return APDB configuration for this instance, including any updates
that may be read from database.

Returns
-------
config : `ApdbConfig`
    APDB configuration.

Reimplemented in lsst.dax.apdb.cassandra.apdbCassandra.ApdbCassandra, and lsst.dax.apdb.sql.apdbSql.ApdbSql.

Definition at line 90 of file apdb.py.

90 def getConfig(self) -> ApdbConfig:
91 """Return APDB configuration for this instance, including any updates
92 that may be read from database.
93
94 Returns
95 -------
96 config : `ApdbConfig`
97 APDB configuration.
98 """
99 raise NotImplementedError()
100

◆ getDiaForcedSources()

pandas.DataFrame | None lsst.dax.apdb.apdb.Apdb.getDiaForcedSources ( self,
Region region,
Iterable[int] | None object_ids,
astropy.time.Time visit_time,
astropy.time.Time | None start_time = None )
Return catalog of DiaForcedSource instances from a given region.

Parameters
----------
region : `lsst.sphgeom.Region`
    Region to search for DIASources.
object_ids : iterable [ `int` ], optional
    List of DiaObject IDs to further constrain the set of returned
    sources. If list is empty then empty catalog is returned with a
    correct schema. If `None` then returned sources are not
    constrained.
visit_time : `astropy.time.Time`
    Time of the current visit. If APDB contains records later than this
    time they may also be returned.
start_time : `astropy.time.Time`, optional
    Lower bound of time window for the query. If not specified then
    it is calculated using ``visit_time`` and
    ``read_forced_sources_months`` configuration parameter.

Returns
-------
catalog : `pandas.DataFrame`, or `None`
    Catalog containing DiaForcedSource records. `None` is returned if
    ``start_time`` is not specified and ``read_forced_sources_months``
    configuration parameter is set to 0.

Raises
------
NotImplementedError
    May be raised by some implementations if ``object_ids`` is `None`.

Notes
-----
This method returns DiaForcedSource catalog for a region with
additional filtering based on DiaObject IDs. Only a subset of DiaSource
history is returned limited by ``read_forced_sources_months`` config
parameter, w.r.t. ``visit_time``. If ``object_ids`` is empty then an
empty catalog is always returned with the correct schema
(columns/types). If ``object_ids`` is `None` then no filtering is
performed and some of the returned records may be outside the specified
region.

Reimplemented in lsst.dax.apdb.cassandra.apdbCassandra.ApdbCassandra, and lsst.dax.apdb.sql.apdbSql.ApdbSql.

Definition at line 189 of file apdb.py.

195 ) -> pandas.DataFrame | None:
196 """Return catalog of DiaForcedSource instances from a given region.
197
198 Parameters
199 ----------
200 region : `lsst.sphgeom.Region`
201 Region to search for DIASources.
202 object_ids : iterable [ `int` ], optional
203 List of DiaObject IDs to further constrain the set of returned
204 sources. If list is empty then empty catalog is returned with a
205 correct schema. If `None` then returned sources are not
206 constrained.
207 visit_time : `astropy.time.Time`
208 Time of the current visit. If APDB contains records later than this
209 time they may also be returned.
210 start_time : `astropy.time.Time`, optional
211 Lower bound of time window for the query. If not specified then
212 it is calculated using ``visit_time`` and
213 ``read_forced_sources_months`` configuration parameter.
214
215 Returns
216 -------
217 catalog : `pandas.DataFrame`, or `None`
218 Catalog containing DiaForcedSource records. `None` is returned if
219 ``start_time`` is not specified and ``read_forced_sources_months``
220 configuration parameter is set to 0.
221
222 Raises
223 ------
224 NotImplementedError
225 May be raised by some implementations if ``object_ids`` is `None`.
226
227 Notes
228 -----
229 This method returns DiaForcedSource catalog for a region with
230 additional filtering based on DiaObject IDs. Only a subset of DiaSource
231 history is returned limited by ``read_forced_sources_months`` config
232 parameter, w.r.t. ``visit_time``. If ``object_ids`` is empty then an
233 empty catalog is always returned with the correct schema
234 (columns/types). If ``object_ids`` is `None` then no filtering is
235 performed and some of the returned records may be outside the specified
236 region.
237 """
238 raise NotImplementedError()
239

◆ getDiaObjects()

pandas.DataFrame lsst.dax.apdb.apdb.Apdb.getDiaObjects ( self,
Region region )
Return catalog of DiaObject instances from a given region.

This method returns only the last version of each DiaObject,
and may return only the subset of the DiaObject columns needed
for AP association. Some
records in a returned catalog may be outside the specified region, it
is up to a client to ignore those records or cleanup the catalog before
futher use.

Parameters
----------
region : `lsst.sphgeom.Region`
    Region to search for DIAObjects.

Returns
-------
catalog : `pandas.DataFrame`
    Catalog containing DiaObject records for a region that may be a
    superset of the specified region.

Reimplemented in lsst.dax.apdb.cassandra.apdbCassandra.ApdbCassandra, and lsst.dax.apdb.sql.apdbSql.ApdbSql.

Definition at line 119 of file apdb.py.

119 def getDiaObjects(self, region: Region) -> pandas.DataFrame:
120 """Return catalog of DiaObject instances from a given region.
121
122 This method returns only the last version of each DiaObject,
123 and may return only the subset of the DiaObject columns needed
124 for AP association. Some
125 records in a returned catalog may be outside the specified region, it
126 is up to a client to ignore those records or cleanup the catalog before
127 futher use.
128
129 Parameters
130 ----------
131 region : `lsst.sphgeom.Region`
132 Region to search for DIAObjects.
133
134 Returns
135 -------
136 catalog : `pandas.DataFrame`
137 Catalog containing DiaObject records for a region that may be a
138 superset of the specified region.
139 """
140 raise NotImplementedError()
141

◆ getDiaSources()

pandas.DataFrame | None lsst.dax.apdb.apdb.Apdb.getDiaSources ( self,
Region region,
Iterable[int] | None object_ids,
astropy.time.Time visit_time,
astropy.time.Time | None start_time = None )
Return catalog of DiaSource instances from a given region.

Parameters
----------
region : `lsst.sphgeom.Region`
    Region to search for DIASources.
object_ids : iterable [ `int` ], optional
    List of DiaObject IDs to further constrain the set of returned
    sources. If `None` then returned sources are not constrained. If
    list is empty then empty catalog is returned with a correct
    schema.
visit_time : `astropy.time.Time`
    Time of the current visit. If APDB contains records later than this
    time they may also be returned.
start_time : `astropy.time.Time`, optional
    Lower bound of time window for the query. If not specified then
    it is calculated using ``visit_time`` and
    ``read_forced_sources_months`` configuration parameter.

Returns
-------
catalog : `pandas.DataFrame`, or `None`
    Catalog containing DiaSource records. `None` is returned if
    ``start_time`` is not specified and ``read_sources_months``
    configuration parameter is set to 0.

Notes
-----
This method returns DiaSource catalog for a region with additional
filtering based on DiaObject IDs. Only a subset of DiaSource history
is returned limited by ``read_sources_months`` config parameter, w.r.t.
``visit_time``. If ``object_ids`` is empty then an empty catalog is
always returned with the correct schema (columns/types). If
``object_ids`` is `None` then no filtering is performed and some of the
returned records may be outside the specified region.

Reimplemented in lsst.dax.apdb.cassandra.apdbCassandra.ApdbCassandra, and lsst.dax.apdb.sql.apdbSql.ApdbSql.

Definition at line 143 of file apdb.py.

149 ) -> pandas.DataFrame | None:
150 """Return catalog of DiaSource instances from a given region.
151
152 Parameters
153 ----------
154 region : `lsst.sphgeom.Region`
155 Region to search for DIASources.
156 object_ids : iterable [ `int` ], optional
157 List of DiaObject IDs to further constrain the set of returned
158 sources. If `None` then returned sources are not constrained. If
159 list is empty then empty catalog is returned with a correct
160 schema.
161 visit_time : `astropy.time.Time`
162 Time of the current visit. If APDB contains records later than this
163 time they may also be returned.
164 start_time : `astropy.time.Time`, optional
165 Lower bound of time window for the query. If not specified then
166 it is calculated using ``visit_time`` and
167 ``read_forced_sources_months`` configuration parameter.
168
169 Returns
170 -------
171 catalog : `pandas.DataFrame`, or `None`
172 Catalog containing DiaSource records. `None` is returned if
173 ``start_time`` is not specified and ``read_sources_months``
174 configuration parameter is set to 0.
175
176 Notes
177 -----
178 This method returns DiaSource catalog for a region with additional
179 filtering based on DiaObject IDs. Only a subset of DiaSource history
180 is returned limited by ``read_sources_months`` config parameter, w.r.t.
181 ``visit_time``. If ``object_ids`` is empty then an empty catalog is
182 always returned with the correct schema (columns/types). If
183 ``object_ids`` is `None` then no filtering is performed and some of the
184 returned records may be outside the specified region.
185 """
186 raise NotImplementedError()
187

◆ metadata()

ApdbMetadata lsst.dax.apdb.apdb.Apdb.metadata ( self)
Object controlling access to APDB metadata (`ApdbMetadata`).

Reimplemented in lsst.dax.apdb.cassandra.apdbCassandra.ApdbCassandra, and lsst.dax.apdb.sql.apdbSql.ApdbSql.

Definition at line 357 of file apdb.py.

357 def metadata(self) -> ApdbMetadata:
358 """Object controlling access to APDB metadata (`ApdbMetadata`)."""
359 raise NotImplementedError()
360

◆ reassignDiaSources()

None lsst.dax.apdb.apdb.Apdb.reassignDiaSources ( self,
Mapping[int, int] idMap )
Associate DiaSources with SSObjects, dis-associating them
from DiaObjects.

Parameters
----------
idMap : `Mapping`
    Maps DiaSource IDs to their new SSObject IDs.

Raises
------
ValueError
    Raised if DiaSource ID does not exist in the database.

Reimplemented in lsst.dax.apdb.cassandra.apdbCassandra.ApdbCassandra, and lsst.dax.apdb.sql.apdbSql.ApdbSql.

Definition at line 312 of file apdb.py.

312 def reassignDiaSources(self, idMap: Mapping[int, int]) -> None:
313 """Associate DiaSources with SSObjects, dis-associating them
314 from DiaObjects.
315
316 Parameters
317 ----------
318 idMap : `Mapping`
319 Maps DiaSource IDs to their new SSObject IDs.
320
321 Raises
322 ------
323 ValueError
324 Raised if DiaSource ID does not exist in the database.
325 """
326 raise NotImplementedError()
327

◆ store()

None lsst.dax.apdb.apdb.Apdb.store ( self,
astropy.time.Time visit_time,
pandas.DataFrame objects,
pandas.DataFrame | None sources = None,
pandas.DataFrame | None forced_sources = None )
Store all three types of catalogs in the database.

Parameters
----------
visit_time : `astropy.time.Time`
    Time of the visit.
objects : `pandas.DataFrame`
    Catalog with DiaObject records.
sources : `pandas.DataFrame`, optional
    Catalog with DiaSource records.
forced_sources : `pandas.DataFrame`, optional
    Catalog with DiaForcedSource records.

Notes
-----
This methods takes DataFrame catalogs, their schema must be
compatible with the schema of APDB table:

  - column names must correspond to database table columns
  - types and units of the columns must match database definitions,
    no unit conversion is performed presently
  - columns that have default values in database schema can be
    omitted from catalog
  - this method knows how to fill interval-related columns of DiaObject
    (validityStart, validityEnd) they do not need to appear in a
    catalog
  - source catalogs have ``diaObjectId`` column associating sources
    with objects

This operation need not be atomic, but DiaSources and DiaForcedSources
will not be stored until all DiaObjects are stored.

Reimplemented in lsst.dax.apdb.cassandra.apdbCassandra.ApdbCassandra, and lsst.dax.apdb.sql.apdbSql.ApdbSql.

Definition at line 270 of file apdb.py.

276 ) -> None:
277 """Store all three types of catalogs in the database.
278
279 Parameters
280 ----------
281 visit_time : `astropy.time.Time`
282 Time of the visit.
283 objects : `pandas.DataFrame`
284 Catalog with DiaObject records.
285 sources : `pandas.DataFrame`, optional
286 Catalog with DiaSource records.
287 forced_sources : `pandas.DataFrame`, optional
288 Catalog with DiaForcedSource records.
289
290 Notes
291 -----
292 This methods takes DataFrame catalogs, their schema must be
293 compatible with the schema of APDB table:
294
295 - column names must correspond to database table columns
296 - types and units of the columns must match database definitions,
297 no unit conversion is performed presently
298 - columns that have default values in database schema can be
299 omitted from catalog
300 - this method knows how to fill interval-related columns of DiaObject
301 (validityStart, validityEnd) they do not need to appear in a
302 catalog
303 - source catalogs have ``diaObjectId`` column associating sources
304 with objects
305
306 This operation need not be atomic, but DiaSources and DiaForcedSources
307 will not be stored until all DiaObjects are stored.
308 """
309 raise NotImplementedError()
310

◆ tableDef()

Table | None lsst.dax.apdb.apdb.Apdb.tableDef ( self,
ApdbTables table )
Return table schema definition for a given table.

Parameters
----------
table : `ApdbTables`
    One of the known APDB tables.

Returns
-------
tableSchema : `.schema_model.Table` or `None`
    Table schema description, `None` is returned if table is not
    defined by this implementation.

Reimplemented in lsst.dax.apdb.cassandra.apdbCassandra.ApdbCassandra, and lsst.dax.apdb.sql.apdbSql.ApdbSql.

Definition at line 102 of file apdb.py.

102 def tableDef(self, table: ApdbTables) -> Table | None:
103 """Return table schema definition for a given table.
104
105 Parameters
106 ----------
107 table : `ApdbTables`
108 One of the known APDB tables.
109
110 Returns
111 -------
112 tableSchema : `.schema_model.Table` or `None`
113 Table schema description, `None` is returned if table is not
114 defined by this implementation.
115 """
116 raise NotImplementedError()
117

The documentation for this class was generated from the following file: