LSST Applications g0265f82a02+0e5473021a,g02d81e74bb+bd2ed33bd6,g1470d8bcf6+c6d6eb38e2,g14a832a312+9d12ad093c,g2079a07aa2+86d27d4dc4,g2305ad1205+91a32aca49,g295015adf3+88246b6574,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g3ddfee87b4+c34e8be1fa,g487adcacf7+85dcfbcc36,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+ea1711114f,g5a732f18d5+53520f316c,g64a986408d+bd2ed33bd6,g858d7b2824+bd2ed33bd6,g8a8a8dda67+585e252eca,g99cad8db69+016a06b37a,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+ef4e3a5875,gb0e22166c9+60f28cb32d,gb6a65358fc+0e5473021a,gba4ed39666+c2a2e4ac27,gbb8dafda3b+b6d7b42999,gc120e1dc64+f745648b3a,gc28159a63d+0e5473021a,gcf0d15dbbd+c34e8be1fa,gdaeeff99f8+f9a426f77a,ge6526c86ff+508d0e0a30,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gf18bd8381d+8d59551888,gf1cff7945b+bd2ed33bd6,w.2024.16
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
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)
 
VersionTuple apdbImplementationVersion (cls)
 
VersionTuple apdbSchemaVersion (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)
 
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)
 
ConfigurableField makeField (cls, str doc)
 
ApdbMetadata metadata (self)
 

Static Public Attributes

 ConfigClass = ApdbConfig
 

Detailed Description

Abstract interface for APDB.

Definition at line 85 of file apdb.py.

Member Function Documentation

◆ apdbImplementationVersion()

VersionTuple lsst.dax.apdb.apdb.Apdb.apdbImplementationVersion ( cls)
Return version number for current APDB implementation.

Returns
-------
version : `VersionTuple`
    Version of the code defined in implementation class.

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

Definition at line 141 of file apdb.py.

141 def apdbImplementationVersion(cls) -> VersionTuple:
142 """Return version number for current APDB implementation.
143
144 Returns
145 -------
146 version : `VersionTuple`
147 Version of the code defined in implementation class.
148 """
149 raise NotImplementedError()
150

◆ apdbSchemaVersion()

VersionTuple lsst.dax.apdb.apdb.Apdb.apdbSchemaVersion ( self)
Return schema version number as defined in config file.

Returns
-------
version : `VersionTuple`
    Version of the schema defined in schema config file.

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

Definition at line 152 of file apdb.py.

152 def apdbSchemaVersion(self) -> VersionTuple:
153 """Return schema version number as defined in config file.
154
155 Returns
156 -------
157 version : `VersionTuple`
158 Version of the schema defined in schema config file.
159 """
160 raise NotImplementedError()
161

◆ containsVisitDetector()

bool lsst.dax.apdb.apdb.Apdb.containsVisitDetector ( self,
int visit,
int detector )
Test whether data for a given visit-detector is present in the APDB.

Parameters
----------
visit, detector : `int`
    The ID of the visit-detector to search for.

Returns
-------
present : `bool`
    `True` if some DiaObject, DiaSource, or DiaForcedSource records
    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 280 of file apdb.py.

280 def containsVisitDetector(self, visit: int, detector: int) -> bool:
281 """Test whether data for a given visit-detector is present in the APDB.
282
283 Parameters
284 ----------
285 visit, detector : `int`
286 The ID of the visit-detector to search for.
287
288 Returns
289 -------
290 present : `bool`
291 `True` if some DiaObject, DiaSource, or DiaForcedSource records
292 exist for the specified observation, `False` otherwise.
293 """
294 raise NotImplementedError()
295

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

390 def countUnassociatedObjects(self) -> int:
391 """Return the number of DiaObjects that have only one DiaSource
392 associated with them.
393
394 Used as part of ap_verify metrics.
395
396 Returns
397 -------
398 count : `int`
399 Number of DiaObjects with exactly one associated DiaSource.
400
401 Notes
402 -----
403 This method can be very inefficient or slow in some implementations.
404 """
405 raise NotImplementedError()
406

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

381 def dailyJob(self) -> None:
382 """Implement daily activities like cleanup/vacuum.
383
384 What should be done during daily activities is determined by
385 specific implementation.
386 """
387 raise NotImplementedError()
388

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

91 def from_config(cls, config: ApdbConfig) -> Apdb:
92 """Create Ppdb instance from configuration object.
93
94 Parameters
95 ----------
96 config : `ApdbConfig`
97 Configuration object, type of this object determines type of the
98 Apdb implementation.
99
100 Returns
101 -------
102 apdb : `apdb`
103 Instance of `Apdb` class.
104 """
105 return make_apdb(config)
106

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

108 def from_uri(cls, uri: ResourcePathExpression) -> Apdb:
109 """Make Apdb instance from a serialized configuration.
110
111 Parameters
112 ----------
113 uri : `~lsst.resources.ResourcePathExpression`
114 URI or local file path pointing to a file with serialized
115 configuration, or a string with a "label:" prefix. In the latter
116 case, the configuration will be looked up from an APDB index file
117 using the label name that follows the prefix. The APDB index file's
118 location is determined by the ``DAX_APDB_INDEX_URI`` environment
119 variable.
120
121 Returns
122 -------
123 apdb : `apdb`
124 Instance of `Apdb` class, the type of the returned instance is
125 determined by configuration.
126 """
127 if isinstance(uri, str) and uri.startswith("label:"):
128 tag, _, label = uri.partition(":")
129 index = ApdbIndex()
130 # Current format for config files is "pex_config"
131 format = "pex_config"
132 uri = index.get_apdb_uri(label, format)
133 path = ResourcePath(uri)
134 config_str = path.read().decode()
135 # Assume that this is ApdbConfig, make_apdb will raise if not.
136 config = cast(ApdbConfig, Config._fromPython(config_str))
137 return make_apdb(config)
138

◆ 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.sql.apdbSql.ApdbSql, and lsst.dax.apdb.cassandra.apdbCassandra.ApdbCassandra.

Definition at line 238 of file apdb.py.

240 ) -> pandas.DataFrame | None:
241 """Return catalog of DiaForcedSource instances from a given region.
242
243 Parameters
244 ----------
245 region : `lsst.sphgeom.Region`
246 Region to search for DIASources.
247 object_ids : iterable [ `int` ], optional
248 List of DiaObject IDs to further constrain the set of returned
249 sources. If list is empty then empty catalog is returned with a
250 correct schema. If `None` then returned sources are not
251 constrained. Some implementations may not support latter case.
252 visit_time : `astropy.time.Time`
253 Time of the current visit.
254
255 Returns
256 -------
257 catalog : `pandas.DataFrame`, or `None`
258 Catalog containing DiaSource records. `None` is returned if
259 ``read_forced_sources_months`` configuration parameter is set to 0.
260
261 Raises
262 ------
263 NotImplementedError
264 May be raised by some implementations if ``object_ids`` is `None`.
265
266 Notes
267 -----
268 This method returns DiaForcedSource catalog for a region with
269 additional filtering based on DiaObject IDs. Only a subset of DiaSource
270 history is returned limited by ``read_forced_sources_months`` config
271 parameter, w.r.t. ``visit_time``. If ``object_ids`` is empty then an
272 empty catalog is always returned with the correct schema
273 (columns/types). If ``object_ids`` is `None` then no filtering is
274 performed and some of the returned records may be outside the specified
275 region.
276 """
277 raise NotImplementedError()
278

◆ 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. 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.sql.apdbSql.ApdbSql, and lsst.dax.apdb.cassandra.apdbCassandra.ApdbCassandra.

Definition at line 180 of file apdb.py.

180 def getDiaObjects(self, region: Region) -> pandas.DataFrame:
181 """Return catalog of DiaObject instances from a given region.
182
183 This method returns only the last version of each DiaObject. Some
184 records in a returned catalog may be outside the specified region, it
185 is up to a client to ignore those records or cleanup the catalog before
186 futher use.
187
188 Parameters
189 ----------
190 region : `lsst.sphgeom.Region`
191 Region to search for DIAObjects.
192
193 Returns
194 -------
195 catalog : `pandas.DataFrame`
196 Catalog containing DiaObject records for a region that may be a
197 superset of the specified region.
198 """
199 raise NotImplementedError()
200

◆ 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.sql.apdbSql.ApdbSql, and lsst.dax.apdb.cassandra.apdbCassandra.ApdbCassandra.

Definition at line 202 of file apdb.py.

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

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

297 def getSSObjects(self) -> pandas.DataFrame:
298 """Return catalog of SSObject instances.
299
300 Returns
301 -------
302 catalog : `pandas.DataFrame`
303 Catalog containing SSObject records, all existing records are
304 returned.
305 """
306 raise NotImplementedError()
307

◆ makeField()

ConfigurableField lsst.dax.apdb.apdb.Apdb.makeField ( cls,
str doc )
Make a `~lsst.pex.config.ConfigurableField` for Apdb.

Parameters
----------
doc : `str`
    Help text for the field.

Returns
-------
configurableField : `lsst.pex.config.ConfigurableField`
    A `~lsst.pex.config.ConfigurableField` for Apdb.

Definition at line 408 of file apdb.py.

408 def makeField(cls, doc: str) -> ConfigurableField:
409 """Make a `~lsst.pex.config.ConfigurableField` for Apdb.
410
411 Parameters
412 ----------
413 doc : `str`
414 Help text for the field.
415
416 Returns
417 -------
418 configurableField : `lsst.pex.config.ConfigurableField`
419 A `~lsst.pex.config.ConfigurableField` for Apdb.
420 """
421 return ConfigurableField(doc=doc, target=cls)
422

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

425 def metadata(self) -> ApdbMetadata:
426 """Object controlling access to APDB metadata (`ApdbMetadata`)."""
427 raise NotImplementedError()

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

364 def reassignDiaSources(self, idMap: Mapping[int, int]) -> None:
365 """Associate DiaSources with SSObjects, dis-associating them
366 from DiaObjects.
367
368 Parameters
369 ----------
370 idMap : `Mapping`
371 Maps DiaSource IDs to their new SSObject IDs.
372
373 Raises
374 ------
375 ValueError
376 Raised if DiaSource ID does not exist in the database.
377 """
378 raise NotImplementedError()
379

◆ 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

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

Definition at line 309 of file apdb.py.

315 ) -> None:
316 """Store all three types of catalogs in the database.
317
318 Parameters
319 ----------
320 visit_time : `astropy.time.Time`
321 Time of the visit.
322 objects : `pandas.DataFrame`
323 Catalog with DiaObject records.
324 sources : `pandas.DataFrame`, optional
325 Catalog with DiaSource records.
326 forced_sources : `pandas.DataFrame`, optional
327 Catalog with DiaForcedSource records.
328
329 Notes
330 -----
331 This methods takes DataFrame catalogs, their schema must be
332 compatible with the schema of APDB table:
333
334 - column names must correspond to database table columns
335 - types and units of the columns must match database definitions,
336 no unit conversion is performed presently
337 - columns that have default values in database schema can be
338 omitted from catalog
339 - this method knows how to fill interval-related columns of DiaObject
340 (validityStart, validityEnd) they do not need to appear in a
341 catalog
342 - source catalogs have ``diaObjectId`` column associating sources
343 with objects
344 """
345 raise NotImplementedError()
346

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

348 def storeSSObjects(self, objects: pandas.DataFrame) -> None:
349 """Store or update SSObject catalog.
350
351 Parameters
352 ----------
353 objects : `pandas.DataFrame`
354 Catalog with SSObject records.
355
356 Notes
357 -----
358 If SSObjects with matching IDs already exist in the database, their
359 records will be updated with the information from provided records.
360 """
361 raise NotImplementedError()
362

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

163 def tableDef(self, table: ApdbTables) -> Table | None:
164 """Return table schema definition for a given table.
165
166 Parameters
167 ----------
168 table : `ApdbTables`
169 One of the known APDB tables.
170
171 Returns
172 -------
173 tableSchema : `.schema_model.Table` or `None`
174 Table schema description, `None` is returned if table is not
175 defined by this implementation.
176 """
177 raise NotImplementedError()
178

Member Data Documentation

◆ ConfigClass

lsst.dax.apdb.apdb.Apdb.ConfigClass = ApdbConfig
static

Definition at line 88 of file apdb.py.


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