LSST Applications g04e9c324dd+8c5ae1fdc5,g134cb467dc+b203dec576,g18429d2f64+358861cd2c,g199a45376c+0ba108daf9,g1fd858c14a+dd066899e3,g262e1987ae+ebfced1d55,g29ae962dfc+72fd90588e,g2cef7863aa+aef1011c0b,g35bb328faa+8c5ae1fdc5,g3fd5ace14f+b668f15bc5,g4595892280+3897dae354,g47891489e3+abcf9c3559,g4d44eb3520+fb4ddce128,g53246c7159+8c5ae1fdc5,g67b6fd64d1+abcf9c3559,g67fd3c3899+1f72b5a9f7,g74acd417e5+cb6b47f07b,g786e29fd12+668abc6043,g87389fa792+8856018cbb,g89139ef638+abcf9c3559,g8d7436a09f+bcf525d20c,g8ea07a8fe4+9f5ccc88ac,g90f42f885a+6054cc57f1,g97be763408+06f794da49,g9dd6db0277+1f72b5a9f7,ga681d05dcb+7e36ad54cd,gabf8522325+735880ea63,gac2eed3f23+abcf9c3559,gb89ab40317+abcf9c3559,gbf99507273+8c5ae1fdc5,gd8ff7fe66e+1f72b5a9f7,gdab6d2f7ff+cb6b47f07b,gdc713202bf+1f72b5a9f7,gdfd2d52018+8225f2b331,ge365c994fd+375fc21c71,ge410e46f29+abcf9c3559,geaed405ab2+562b3308c0,gf9a733ac38+8c5ae1fdc5,w.2025.35
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)
 
pandas.DataFrame|None getDiaForcedSources (self, Region region, Iterable[int]|None object_ids, astropy.time.Time visit_time)
 
bool containsVisitDetector (self, int visit, int detector, Region region, astropy.time.Time visit_time)
 
pandas.DataFrame getSSObjects (self)
 
None store (self, astropy.time.Time visit_time, pandas.DataFrame objects, pandas.DataFrame|None sources=None, pandas.DataFrame|None forced_sources=None)
 
None storeSSObjects (self, pandas.DataFrame objects)
 
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 371 of file apdb.py.

371 def admin(self) -> ApdbAdmin:
372 """Object providing adminitrative interface for APDB (`ApdbAdmin`)."""
373 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 221 of file apdb.py.

227 ) -> bool:
228 """Test whether any sources for a given visit-detector are present in
229 the APDB.
230
231 Parameters
232 ----------
233 visit, detector : `int`
234 The ID of the visit-detector to search for.
235 region : `lsst.sphgeom.Region`
236 Region corresponding to the visit/detector combination.
237 visit_time : `astropy.time.Time`
238 Visit time (as opposed to visit processing time). This can be any
239 timestamp in the visit timespan, e.g. its begin or end time.
240
241 Returns
242 -------
243 present : `bool`
244 `True` if at least one DiaSource or DiaForcedSource record
245 may exist for the specified observation, `False` otherwise.
246 """
247 raise NotImplementedError()
248

◆ 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 346 of file apdb.py.

346 def countUnassociatedObjects(self) -> int:
347 """Return the number of DiaObjects that have only one DiaSource
348 associated with them.
349
350 Used as part of ap_verify metrics.
351
352 Returns
353 -------
354 count : `int`
355 Number of DiaObjects with exactly one associated DiaSource.
356
357 Notes
358 -----
359 This method can be very inefficient or slow in some implementations.
360 """
361 raise NotImplementedError()
362

◆ 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 337 of file apdb.py.

337 def dailyJob(self) -> None:
338 """Implement daily activities like cleanup/vacuum.
339
340 What should be done during daily activities is determined by
341 specific implementation.
342 """
343 raise NotImplementedError()
344

◆ 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 )
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. Some implementations may not support latter case.
visit_time : `astropy.time.Time`
    Time of the current visit.

Returns
-------
catalog : `pandas.DataFrame`, or `None`
    Catalog containing DiaSource records. `None` is returned if
    ``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 179 of file apdb.py.

181 ) -> pandas.DataFrame | None:
182 """Return catalog of DiaForcedSource instances from a given region.
183
184 Parameters
185 ----------
186 region : `lsst.sphgeom.Region`
187 Region to search for DIASources.
188 object_ids : iterable [ `int` ], optional
189 List of DiaObject IDs to further constrain the set of returned
190 sources. If list is empty then empty catalog is returned with a
191 correct schema. If `None` then returned sources are not
192 constrained. Some implementations may not support latter case.
193 visit_time : `astropy.time.Time`
194 Time of the current visit.
195
196 Returns
197 -------
198 catalog : `pandas.DataFrame`, or `None`
199 Catalog containing DiaSource records. `None` is returned if
200 ``read_forced_sources_months`` configuration parameter is set to 0.
201
202 Raises
203 ------
204 NotImplementedError
205 May be raised by some implementations if ``object_ids`` is `None`.
206
207 Notes
208 -----
209 This method returns DiaForcedSource catalog for a region with
210 additional filtering based on DiaObject IDs. Only a subset of DiaSource
211 history is returned limited by ``read_forced_sources_months`` config
212 parameter, w.r.t. ``visit_time``. If ``object_ids`` is empty then an
213 empty catalog is always returned with the correct schema
214 (columns/types). If ``object_ids`` is `None` then no filtering is
215 performed and some of the returned records may be outside the specified
216 region.
217 """
218 raise NotImplementedError()
219

◆ 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 )
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.

Returns
-------
catalog : `pandas.DataFrame`, or `None`
    Catalog containing DiaSource records. `None` is returned if
    ``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.

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

◆ getSSObjects()

pandas.DataFrame lsst.dax.apdb.apdb.Apdb.getSSObjects ( self)
Return catalog of SSObject instances.

Returns
-------
catalog : `pandas.DataFrame`
    Catalog containing SSObject records, all existing records are
    returned.

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

Definition at line 250 of file apdb.py.

250 def getSSObjects(self) -> pandas.DataFrame:
251 """Return catalog of SSObject instances.
252
253 Returns
254 -------
255 catalog : `pandas.DataFrame`
256 Catalog containing SSObject records, all existing records are
257 returned.
258 """
259 raise NotImplementedError()
260

◆ 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 365 of file apdb.py.

365 def metadata(self) -> ApdbMetadata:
366 """Object controlling access to APDB metadata (`ApdbMetadata`)."""
367 raise NotImplementedError()
368

◆ 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 320 of file apdb.py.

320 def reassignDiaSources(self, idMap: Mapping[int, int]) -> None:
321 """Associate DiaSources with SSObjects, dis-associating them
322 from DiaObjects.
323
324 Parameters
325 ----------
326 idMap : `Mapping`
327 Maps DiaSource IDs to their new SSObject IDs.
328
329 Raises
330 ------
331 ValueError
332 Raised if DiaSource ID does not exist in the database.
333 """
334 raise NotImplementedError()
335

◆ 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 262 of file apdb.py.

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

◆ storeSSObjects()

None lsst.dax.apdb.apdb.Apdb.storeSSObjects ( self,
pandas.DataFrame objects )
Store or update SSObject catalog.

Parameters
----------
objects : `pandas.DataFrame`
    Catalog with SSObject records.

Notes
-----
If SSObjects with matching IDs already exist in the database, their
records will be updated with the information from provided records.

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

Definition at line 304 of file apdb.py.

304 def storeSSObjects(self, objects: pandas.DataFrame) -> None:
305 """Store or update SSObject catalog.
306
307 Parameters
308 ----------
309 objects : `pandas.DataFrame`
310 Catalog with SSObject records.
311
312 Notes
313 -----
314 If SSObjects with matching IDs already exist in the database, their
315 records will be updated with the information from provided records.
316 """
317 raise NotImplementedError()
318

◆ 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: