upoints.baken.Bakens

Package upoints :: Module baken :: Class Bakens |
[hide private]
[frames] | no frames]

# Class Bakens

       object --+
                |
             dict --+
                    |
    point.KeyedPoints --+
                        |
                       Bakens

Class for representing a group of Baken objects

Since: 0.5.1

Instance Methods | [hide private]
    new empty dictionary
__init__(self, baken_file=None) Initialise a new Bakens object |
`dict` |
import_locations(self, baken_file) Import baken data files |
Inherited from `point.KeyedPoints`: `__repr__`, `bearing`, `destination`, `distance`, `final_bearing`, `forward`, `inverse`, `midpoint`, `range`, `sun_events`, `sunrise`, `sunset`, `to_grid_locator` Inherited from `dict`: `__cmp__`, `__contains__`, `__delitem__`, `__eq__`, `__ge__`, `__getattribute__`, `__getitem__`, `__gt__`, `__hash__`, `__iter__`, `__le__`, `__len__`, `__lt__`, `__ne__`, `__new__`, `__setitem__`, `clear`, `copy`, `fromkeys`, `get`, `has_key`, `items`, `iteritems`, `iterkeys`, `itervalues`, `keys`, `pop`, `popitem`, `setdefault`, `update`, `values` Inherited from `object`: `__delattr__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__str__`

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, baken_file=None) (Constructor) |
Initialise a new Bakens object Parameters: `points` - Point objects to wrap `parse` - Whether to attempt import of `points` `units` - Unit type to be used for distances when parsing string locations Returns:
    new empty dictionary
Overrides: object.__init__

### import_locations(self, baken_file) |
Import baken data files import_locations() returns a dictionary with keys containing the section title, and values consisting of a collection Baken objects. It expects data files in the format used by the baken amateur radio package, which is Windows INI style files such as:
    [Abeche, Chad]
    latitude=14.460000
    longitude=20.680000
    height=0.000000

    [GB3BUX]
    frequency=50.000
    locator=IO93BF
    power=25 TX
    antenna=2 x Turnstile
    height=460
    mode=A1A
The reader uses Python's ConfigParser module, so should be reasonably robust against encodings and such. The above file processed by import_locations() will return the following `dict` object:
    {"Abeche, Chad": Baken(14.460, 20.680, None, None, None, 0.000,
                           None, None, None, None, None),
     "GB3BUX": : Baken(None, None, "2 x Turnstile", None, 50.000,
                       460.000, "IO93BF", "A1A", None, 25, None)}
    >>> locations = Bakens(open("baken_data"))
    >>> for key, value in sorted(locations.items()):
    ...     print("%s - %s" % (key, value))
    Abeche, Chad - 14°27'36"N, 020°40'48"E
    GB3BUX - IO93BF (53°13'45"N, 001°52'30"W)
    IW1RCT - JN44FH (44°18'45"N, 008°27'29"E)
    >>> locations = Bakens(open("no_valid_baken"))
    >>> len(locations)
    0
Parameters: `baken_file` (`file`, `list` or `str`) - Baken data to read Returns: `dict` Named locations and their associated values Overrides: point.KeyedPoints.import_locations