Models

Abstract base class

class calibration.models.Model(**kwargs)

The base class for the database access model. The initializer takes a set of keyword arguments defining the object. The model needs to be fully specified (i.e. all of the columns need to be provided (except for the id) otherwise, a ModelError is thrown.

classmethod find(q='', args=[], order=None, limit=None)

Find a list of objects in the table that match a particular set of query parameters.

This is just a shortcut to run SELECT * FROM {{ table }} WHERE {{ q }}.

Parameters:
  • q – (optional) The SQL query to run.
  • args – (optional) The positional arguments for the query.
  • order – (optional) Which column should the results be sorted on?
  • limit – (optional) How many objects should the results be limited to?
Returns:

A list of Model objects (or subclasses thereof) returned by the query. This will return an empty list if nothing was found.

classmethod find_one(**kwargs)

Takes the same arguments as find() but only returns a single result. This will return None if nothing matches the query.

get(k)

Get the value of a given attribute.

Parameters:k – The name of the attribute to get.
save()

Upsert the object into the database.

SDSS data access

class calibration.models.Run(**kwargs)

Access objects in the runs table. This class is essentially a pointer to an calibration.data.SDSSRun object with a few database helpers. One entry corresponds to a (run, camcol) pair from the SDSS catalog. It has the following attributes:

  • id (integer primary key): The id of this run.
  • run (integer): The SDSS run number.
  • camcol (integer): The SDSS camcol number (1-6 inclusive).
  • field_min (integer): The first field contained in this run.
  • field_max (integer): The last field contained in this run (inclusive).
  • band (integer): The SDSS filter (0-4 inclusive).
  • ramin (real): The absolute minimum R.A. hit by the run.
  • ramax (real): The absolute maximum R.A. hit by the run.
  • decmin (real): The absolute minimum Dec. hit by the run.
  • decmax (real): The absolute maximum Dec. hit by the run.
data

Lazily access the interface to the HDF5 data file.

Returns:A calibration.data.SDSSRun object pointing to the right data file.
do_photometry()

Do the photometry for all of the stars in the run.

classmethod find(q='', args=[], order=None, limit=None)

Find a list of objects in the table that match a particular set of query parameters.

This is just a shortcut to run SELECT * FROM {{ table }} WHERE {{ q }}.

Parameters:
  • q – (optional) The SQL query to run.
  • args – (optional) The positional arguments for the query.
  • order – (optional) Which column should the results be sorted on?
  • limit – (optional) How many objects should the results be limited to?
Returns:

A list of Model objects (or subclasses thereof) returned by the query. This will return an empty list if nothing was found.

classmethod find_one(**kwargs)

Takes the same arguments as find() but only returns a single result. This will return None if nothing matches the query.

get(k)

Get the value of a given attribute.

Parameters:k – The name of the attribute to get.
get_stars()

Get all the stars within the “bounds” of this run as defined by ramin, ramax, decmin and decmax.

Returns:The list of Star objects within the bounds of the run.
classmethod point(ra, dec, q='', **kwargs)

Find all of the runs that overlap with a given point.

Parameters:
  • ra – The R.A. coordinate to search for.
  • dec – The Dec. coordinate to search for.
  • q – (optional) An additional SQL query that results must satisfy.
Returns:

A list of Run objects returned by the query or None if nothing was found.

save()

Upsert the object into the database.

class calibration.models.Star(**kwargs)

Access objects in the stars table. These are objects from the SDSS co-add catalog. This object and the associated table have the following attributes:

  • id (integer primary key): The SDSS id of this star.
  • ra (real): The R.A. position of the star.
  • dec (real): The Dec. position of the star.
  • u (real): The CAS flux in the u-band.
  • g (real): The CAS flux in the g-band.
  • r (real): The CAS flux in the r-band.
  • i (real): The CAS flux in the i-band.
  • z (real): The CAS flux in the z-band.
  • has_lightcurve (bool): Does this star have a calibrated light curve?
classmethod find(q='', args=[], order=None, limit=None)

Find a list of objects in the table that match a particular set of query parameters.

This is just a shortcut to run SELECT * FROM {{ table }} WHERE {{ q }}.

Parameters:
  • q – (optional) The SQL query to run.
  • args – (optional) The positional arguments for the query.
  • order – (optional) Which column should the results be sorted on?
  • limit – (optional) How many objects should the results be limited to?
Returns:

A list of Model objects (or subclasses thereof) returned by the query. This will return an empty list if nothing was found.

classmethod find_one(**kwargs)

Takes the same arguments as find() but only returns a single result. This will return None if nothing matches the query.

get(k)

Get the value of a given attribute.

Parameters:k – The name of the attribute to get.
save()

Upsert the object into the database.

Raw Photometry

class calibration.models.Measurement(**kwargs)

Access objects in the raw table. These objects are raw photometric measurements of point sources. The object as the following attributes:

  • id (integer primary key): The id of this measurement.
  • runid (integer): The associated [run](/models/runs).
  • starid (integer): The associated [star](/models/stars).
  • ra (real): The R.A. position of the measurement (based on the associated Star model.
  • dec (real): The Dec. position of the measurement.
  • tai (real): The time of the measurement (based on the interpolation of times associated with the Run model). The units are seconds.
  • band (integer): The SDSS filter.
  • flux (real): The measured counts of the source.
  • fluxivar (real): The inverse variance in flux.
  • sky (real): The measured background sky level.
  • skyivar (real): The inverse variance in sky.
  • dx (real): The offset of the center of the star along the “x” coordinate measured in pixels.
  • dxivar (real): The inverse variance in dx.
  • dy (real): The offset of the center of the star along the “y” coordinate measured in pixels.
  • dyivar (real): The inverse variance in dy.
classmethod find(q='', args=[], order=None, limit=None)

Find a list of objects in the table that match a particular set of query parameters.

This is just a shortcut to run SELECT * FROM {{ table }} WHERE {{ q }}.

Parameters:
  • q – (optional) The SQL query to run.
  • args – (optional) The positional arguments for the query.
  • order – (optional) Which column should the results be sorted on?
  • limit – (optional) How many objects should the results be limited to?
Returns:

A list of Model objects (or subclasses thereof) returned by the query. This will return an empty list if nothing was found.

classmethod find_one(**kwargs)

Takes the same arguments as find() but only returns a single result. This will return None if nothing matches the query.

get(k)

Get the value of a given attribute.

Parameters:k – The name of the attribute to get.
classmethod measure(run, star)

Measure the photometry of a particular star in a particular run.

Parameters:
  • run – A Run object.
  • star – A Star object.
Returns:

The Measurement object.

save()

Upsert the object into the database.

Exceptions

class calibration.models.ModelError

An exception thrown if a model is not fully specified.

For some reason, I decided to re-calibrate SDSS Stripe 82—oops! Maybe I'll find some faint variable stars.

Table Of Contents

Related Topics

Fork me on GitHub