Next / Previous / Contents / NM Tech homepage

6.12. The censuses table

Represents a number of birds of the same kind seen in a circle-year.

pycbc.py
    censuses_table = schema.Table('censuses', meta,
        schema.Column('lat',         types.CHAR(4)),
        schema.Column('lon',         types.CHAR(5)),
        schema.Column('year_no',     types.CHAR(3),  nullable=False),
        schema.Column('year_key',    types.CHAR(5),  nullable=False),
        schema.Column('seq_no',      types.SMALLINT,  nullable=False),
        schema.Column('form',        types.CHAR(6),  nullable=False),
        schema.Column('rel',         types.CHAR(1)),
        schema.Column('alt_form',    types.CHAR(6)),
        schema.Column('age',         types.CHAR(1)),
        schema.Column('sex',         types.CHAR(1)),
        schema.Column('plus',        types.CHAR(1)),
        schema.Column('q',           types.CHAR(1)),
        schema.Column('census',      types.INTEGER,  nullable=False),
        schema.PrimaryKeyConstraint('lat', 'lon', 'year_no',
                                    'year_key', 'seq_no'),
        schema.ForeignKeyConstraint(
            ('lat', 'lon', 'year_no', 'year_key'),
            ('efforts.lat', 'efforts.lon', 'efforts.year_no',
             'efforts.year_key'),
            name='cen_eff_x'))
    schema.Index('cen_form_x',
        censuses_table.c.form, censuses_table.c.rel,
        censuses_table.c.alt_form)

    class Census(object):
        def __init__(self, lat, lon, year_no, year_key, seq_no,
                form, rel, alt_form, age, sex, plus, q, census):
            self.lat = lat
            self.lon = lon
            self.year_no = year_no
            self.year_key = year_key
            self.seq_no = seq_no
            self.form = form
            self.rel = rel
            self.alt_form = alt_form
            self.age = age
            self.sex = sex
            self.plus = plus
            self.q = q
            self.census = census
        def __repr__(self):
            formKey = ( self.form + (self.rel or "") +
                        (self.alt_form or "") )
            suffixes = ((self.age or "") + (self.sex or "") +
                        (self.plus or "") + (self.q or ""))
            return ( "<Census(%sn %sw[%s-%s.%s] %s%d%s)>"  %
                     (self.lat, self.lon, self.year_no, self.year_key,
                      self.seq_no, formKey, self.census, suffixes) )