upoints.utils

Package upoints :: Module utils |
[hide private]
[frames] | no frames]

# Module utils

utils - Support code for upoints

Classes | [hide private]
| FileFormatError Error object for data parsing error

Functions | [hide private]
`list` |
dump_xearth_markers(markers, name=`'``identifier``'`) Generate an Xearth compatible marker file |
`float` |
calc_radius(latitude, ellipsoid=`'``WGS84``'`) Calculate earth radius for a given latitude |
Implementation utilities
`str` |
value_or_empty(value) Return an empty string for display when value is `None` |
repr_assist(obj, remap=None) Helper function to simplify `__repr__` methods |
`list` |
prepare_read(data) Prepare various input types for parsing |
`csv.DictReader` |
prepare_csv_read(data, field_names, *args, **kwargs) Prepare various input types for CSV parsing |
`ET.ElementTree` |
prepare_xml_read(data) Prepare various input types for XML parsing |
Angle conversion utilities
`tuple` of `int` objects for values |
to_dms(angle, style=`'``dms``'`) Convert decimal angle to degrees, minutes and possibly seconds |
`float` |
to_dd(degrees, minutes, seconds=0) Convert degrees, minutes and optionally seconds to decimal angle |
`tuple` |
__chunk(segment) Generate a tuple of compass direction names |
`str` |
angle_to_name(angle, segments=8, abbr=False) Convert angle in to direction name |
Coordinate conversion utilities
`tuple` |
from_iso6709(coordinates) Parse ISO 6709 coordinate strings |
`str` |
to_iso6709(latitude, longitude, altitude=None, format=`'``dd``'`, precision=4) Produce ISO 6709 coordinate strings |
`float` |
angle_to_distance(angle, units=`'``metric``'`) Convert angle in to distance along a great circle |
`float` |
distance_to_angle(distance, units=`'``metric``'`) Convert a distance in to an angle along a great circle |
`tuple` of `float` objects |
from_grid_locator(locator) Calculate geodesic latitude/longitude from Maidenhead locator |
`str` |
to_grid_locator(latitude, longitude, precision=`'``square``'`) Calculate Maidenhead locator from latitude and longitude |
`tuple` of `float` objects |
parse_location(location) Parse latitude and longitude from string location |
Solar event utilities
`datetime.time` or `None` |
sun_rise_set(latitude, longitude, date, mode=`'``rise``'`, timezone=0, zenith=None) Calculate sunrise or sunset for a specific location |
`tuple` of `datetime.time` |
sun_events(latitude, longitude, date, timezone=0, zenith=None) Convenience function for calculating sunrise and sunset |

Variables | [hide private]
| __bug_report__ = ``'``James Rowe <jnrowe@ukfsn.org>``'`` Address for use in messages
| BODIES = ``{``'``Ceres``'``:` 475`,` `'``Earth``'``:` 6367`,` `'``Eris``'``:` 1200`,` `'``Jupiter``'``...`` Body radii of various solar system objects
| BODY_RADIUS = `6367` Default body radius to use for calculations
| NAUTICAL_MILE = `1.852` Number of kilometres per nautical mile
| STATUTE_MILE = `1.609` Number of kilometres per statute mile
| LONGITUDE_FIELD = `20` Longitude field 1 multiplier
| LATITUDE_FIELD = `10` Latitude field 1 multiplier
| LONGITUDE_SQUARE = `2.0` Longitude field 2 multiplier
| LATITUDE_SQUARE = `1.0` Latitude field 2 multiplier
| LONGITUDE_SUBSQUARE = `0.0833333333333` Longitude field 3 multiplier
| LATITUDE_SUBSQUARE = `0.0416666666667` Latitude field 3 multiplier
| LONGITUDE_EXTSQUARE = `0.00833333333333` Longitude field 4 multiplier
| LATITUDE_EXTSQUARE = `0.00416666666667` Latitude field 4 multiplier
Angle conversion utilities
| COMPASS_NAMES = ``(``'``North``'``,` `'``North-north-east``'``,` `'``North-east``'``,` `'``E``...``
Solar event utilities
| ZENITH = ``{`None`:` -0.833333333333`,` `'``astronomical``'``:` -18`,` `'``civil``'``:``...`` Sunrise/-set mappings from name to angle

Function Details | [hide private]

### value_or_empty(value) |
Return an empty string for display when value is `None`
    >>> value_or_empty(None)
    ''
    >>> value_or_empty("test")
    'test'
Parameters: `value` (`None`, `str` or coercible to `str`) - Value to prepare for display Returns: `str` String representation of `value`

### repr_assist(obj, remap=None) |
Helper function to simplify `__repr__` methods Parameters: `obj` (Any) - Object to pull arg values for `remap` (`dict`) - Arg pairs to remap before output

### prepare_read(data) |
Prepare various input types for parsing
    >>> prepare_read(open("real_file"))
    ['This is a test file-type object\n']
    >>> test_list = ['This is a test list-type object', 'with two elements']
    >>> prepare_read(test_list)
    ['This is a test list-type object', 'with two elements']
Parameters: `data` (`file` like object, `list`, `str`) - Data to read Returns: `list` List suitable for parsing Raises: `TypeError` - Invalid value for data

### prepare_csv_read(data, field_names, *args, **kwargs) |
Prepare various input types for CSV parsing
    >>> list(prepare_csv_read(open("real_file.csv"),
    ...                       ("type", "bool", "string")))
    [{'bool': 'true', 'type': 'file', 'string': 'test'}]
    >>> test_list = ['James,Rowe', 'ell,caro']
    >>> list(prepare_csv_read(test_list, ("first", "last")))
    [{'last': 'Rowe', 'first': 'James'}, {'last': 'caro', 'first': 'ell'}]
Parameters: `data` (`file` like object, `list`, `str`) - Data to read `field_names` (`tuple` of `str`) - Ordered names to assign to fields Returns: `csv.DictReader` CSV reader suitable for parsing Raises: `TypeError` - Invalid value for data

### prepare_xml_read(data) |
Prepare various input types for XML parsing
    >>> prepare_xml_read(open("real_file.xml")).find("tag").text
    'This is a test file-type object'
    >>> test_list = ['<xml>', '<tag>This is a test list</tag>', '</xml>']
    >>> prepare_xml_read(test_list).find("tag").text
    'This is a test list'
Parameters: `data` (`file` like object, `list`, `str`) - Data to read Returns: `ET.ElementTree` Tree suitable for parsing Raises: `TypeError` - Invalid value for data

### to_dms(angle, style=`'``dms``'`) |
Convert decimal angle to degrees, minutes and possibly seconds
    >>> to_dms(52.015)
    (52, 0, 54.0)
    >>> to_dms(-0.221)
    (0, -13, -15.600000000000023)
    >>> to_dms(-0.221, style="dm")
    (0, -13.26)
    >>> to_dms(-0.221, style=None)
    Traceback (most recent call last):
        ...
    ValueError: Unknown style type `None'
Parameters: `angle` (`float` or coercible to `float`) - Angle to convert `style` (`str`) - Return fractional or whole minutes values Returns: `tuple` of `int` objects for values Angle converted to degrees, minutes and possibly seconds Raises: `ValueError` - Unknown value for `style`

### to_dd(degrees, minutes, seconds=0) |
Convert degrees, minutes and optionally seconds to decimal angle
    >>> "%.3f" % to_dd(52, 0, 54)
    '52.015'
    >>> "%.3f" % to_dd(0, -13, -15)
    '-0.221'
    >>> "%.3f" % to_dd(0, -13.25)
    '-0.221'
Parameters: `degrees` (`float` or coercible to `float`) - Number of degrees `minutes` (`float` or coercible to `float`) - Number of minutes `seconds` (`float` or coercible to `float`) - Number of seconds Returns: `float` Angle converted to decimal degrees

### __chunk(segment) |
Generate a tuple of compass direction names Parameters: `segment` (`int`) - Compass segment to generate names for Returns: `tuple` Direction names for compass segment

### angle_to_name(angle, segments=8, abbr=False) |
Convert angle in to direction name
    >>> angle_to_name(0)
    'North'
    >>> angle_to_name(360)
    'North'
    >>> angle_to_name(45)
    'North-east'
    >>> angle_to_name(292)
    'West'
    >>> angle_to_name(293)
    'North-west'
    >>> angle_to_name(0, 4)
    'North'
    >>> angle_to_name(360, 16)
    'North'
    >>> angle_to_name(45, 4, True)
    'NE'
    >>> angle_to_name(292, 16, True)
    'WNW'
Parameters: `angle` (`float` or coercible to `float`) - Angle in degrees to convert to direction name `segments` (`int`) - Number of segments to split compass in to `abbr` (`bool`) - Whether to return abbreviated direction string Returns: `str` Direction name for `angle`

### from_iso6709(coordinates) |
Parse ISO 6709 coordinate strings This function will parse ISO 6709-1983(E) "Standard representation of latitude, longitude and altitude for geographic point locations" elements. Unfortunately, the standard is rather convoluted and this implementation is incomplete, but it does support most of the common formats in the wild. The W3C has a simplified profile for ISO 6709 in Latitude, Longitude and Altitude format for geospatial information. It unfortunately hasn't received widespread support as yet, but hopefully it will grow just as the simplified ISO 8601 profile has. The following tests are from the examples contained in the wikipedia ISO 6709 page.
    >>> from_iso6709("+00-025/") # Atlantic Ocean
    (0.0, -25.0, None)
    >>> from_iso6709("+46+002/") # France
    (46.0, 2.0, None)
    >>> from_iso6709("+4852+00220/") # Paris
    (48.866666666666667, 2.3333333333333335, None)
    >>> from_iso6709("+48.8577+002.295/") # Eiffel Tower
    (48.857700000000001, 2.2949999999999999, None)
    >>> from_iso6709("+27.5916+086.5640+8850/") # Mount Everest
    (27.5916, 86.563999999999993, 8850.0)
    >>> from_iso6709("+90+000/") # North Pole
    (90.0, 0.0, None)
    >>> from_iso6709("+00-160/") # Pacific Ocean
    (0.0, -160.0, None)
    >>> from_iso6709("-90+000+2800/") # South Pole
    (-90.0, 0.0, 2800.0)
    >>> from_iso6709("+38-097/") # United States
    (38.0, -97.0, None)
    >>> from_iso6709("+40.75-074.00/") # New York City
    (40.75, -74.0, None)
    >>> from_iso6709("+40.6894-074.0447/") # Statue of Liberty
    (40.689399999999999, -74.044700000000006, None)
The following tests are from the Latitude, Longitude and Altitude format for geospatial information page.
    >>> from_iso6709("+27.5916+086.5640+8850/") # Mount Everest
    (27.5916, 86.563999999999993, 8850.0)
    >>> from_iso6709("-90+000+2800/") # South Pole
    (-90.0, 0.0, 2800.0)
    >>> from_iso6709("+40.75-074.00/") # New York City
    (40.75, -74.0, None)
    >>> from_iso6709("+352139+1384339+3776/") # Mount Fuji
    (35.360833333333332, 138.72749999999999, 3776.0)
    >>> from_iso6709("+35.658632+139.745411/") # Tokyo Tower
    (35.658631999999997, 139.74541099999999, None)
    >>> from_iso6709("+35.658632+1/") # Broken
    Traceback (most recent call last):
        ...
    ValueError: Incorrect format for longitude `+1'
Parameters: `coordinates` (`str`) - ISO 6709 coordinates string Returns: `tuple` A tuple consisting of latitude and longitude in degrees, along with the elevation in metres Raises: `ValueError` - Input string is not ISO 6709 compliant `ValueError` - Invalid value for latitude `ValueError` - Invalid value for longitude See Also: to_iso6709

### to_iso6709(latitude, longitude, altitude=None, format=`'``dd``'`, precision=4) |
Produce ISO 6709 coordinate strings This function will produce ISO 6709-1983(E) "Standard representation of latitude, longitude and altitude for geographic point locations" elements. The following tests are from the examples contained in the wikipedia ISO 6709 page.
    >>> to_iso6709(0.0, -25.0, None, "d") # Atlantic Ocean
    '+00-025/'
    >>> to_iso6709(46.0, 2.0, None, "d") # France
    '+46+002/'
    >>> to_iso6709(48.866666666666667, 2.3333333333333335, None, "dm") # Paris
    '+4852+00220/'
    >>> # The following test is skipped, because the example from wikipedia uses
    >>> # differing precision widths for latitude and longitude. Also, that
    >>> # degree of formatting flexibility is not seen anywhere else and adds
    >>> # very little.
    >>> to_iso6709(48.857700000000001, 2.2949999999999999, None) # Eiffel Tower # doctest: +SKIP
    '+48.8577+002.295/'
    >>> to_iso6709(27.5916, 86.563999999999993, 8850.0) # Mount Everest
    '+27.5916+086.5640+8850/'
    >>> to_iso6709(90.0, 0.0, None, "d") # North Pole
    '+90+000/'
    >>> to_iso6709(0.0, -160.0, None, "d") # Pacific Ocean
    '+00-160/'
    >>> to_iso6709(-90.0, 0.0, 2800.0, "d") # South Pole
    '-90+000+2800/'
    >>> to_iso6709(38.0, -97.0, None, "d") # United States
    '+38-097/'
    >>> to_iso6709(40.75, -74.0, None, precision=2) # New York City
    '+40.75-074.00/'
    >>> to_iso6709(40.689399999999999, -74.044700000000006, None) # Statue of Liberty
    '+40.6894-074.0447/'
The following tests are from the Latitude, Longitude and Altitude format for geospatial information page.
    >>> to_iso6709(27.5916, 86.563999999999993, 8850.0) # Mount Everest
    '+27.5916+086.5640+8850/'
    >>> to_iso6709(-90.0, 0.0, 2800.0, "d") # South Pole
    '-90+000+2800/'
    >>> to_iso6709(40.75, -74.0, None, precision=2) # New York City
    '+40.75-074.00/'
    >>> to_iso6709(35.360833333333332, 138.72749999999999, 3776.0, "dms") # Mount Fuji
    '+352139+1384339+3776/'
    >>> to_iso6709(35.658631999999997, 139.74541099999999, None, precision=6) # Tokyo Tower
    '+35.658632+139.745411/'
Parameters: `latitude` (`float` or coercible to `float`) - Location's latitude `longitude` (`float` or coercible to `float`) - Location's longitude `altitude` (`float` or coercible to `float`) - Location's altitude `format` (`str`) - Format type for string `precision` (`int`) - Latitude/longitude precision Returns: `str` ISO 6709 coordinates string Raises: `ValueError` - Unknown value for `format` See Also: from_iso6709

### angle_to_distance(angle, units=`'``metric``'`) |
Convert angle in to distance along a great circle
    >>> "%.3f" % angle_to_distance(1)
    '111.125'
    >>> "%i" % angle_to_distance(360, "imperial")
    '24863'
    >>> "%i" % angle_to_distance(1.0/60, "nautical")
    '1'
    >>> "%i" % angle_to_distance(10, "baseless")
    Traceback (most recent call last):
        ...
    ValueError: Unknown units type `baseless'
Parameters: `angle` (`float` or coercible to `float`) - Angle in degrees to convert to distance `units` (`str`) - Unit type to be used for distances Returns: `float` Distance in `units` Raises: `ValueError` - Unknown value for `units`

### distance_to_angle(distance, units=`'``metric``'`) |
Convert a distance in to an angle along a great circle
    >>> "%.3f" % round(distance_to_angle(111.212))
    '1.000'
    >>> "%i" % round(distance_to_angle(24882, "imperial"))
    '360'
    >>> "%i" % round(distance_to_angle(60, "nautical"))
    '1'
Parameters: `distance` (`float` or coercible to `float`) - Distance to convert to degrees `units` (`str`) - Unit type to be used for distances Returns: `float` Angle in degrees Raises: `ValueError` - Unknown value for `units`

### from_grid_locator(locator) |
Calculate geodesic latitude/longitude from Maidenhead locator
    >>> "%.3f, %.3f" % from_grid_locator("BL11bh16")
    '21.319, -157.904'
    >>> "%.3f, %.3f" % from_grid_locator("IO92va")
    '52.021, -0.208'
    >>> "%.3f, %.3f" % from_grid_locator("IO92")
    '52.021, -1.958'
Parameters: `locator` (`str`) - Maidenhead locator string Returns: `tuple` of `float` objects Geodesic latitude and longitude values Raises: `ValueError` - Incorrect grid locator length `ValueError` - Invalid values in locator string

### to_grid_locator(latitude, longitude, precision=`'``square``'`) |
Calculate Maidenhead locator from latitude and longitude
    >>> to_grid_locator(21.319, -157.904, "extsquare")
    'BL11bh16'
    >>> to_grid_locator(52.021, -0.208, "subsquare")
    'IO92va'
    >>> to_grid_locator(52.021, -1.958)
    'IO92'
Parameters: `latitude` (`float`) - Position's latitude `longitude` (`float`) - Position's longitude `precision` (`str`) - Precision with which generate locator string Returns: `str` Maidenhead locator for latitude and longitude Raises: `ValueError` - Invalid precision identifier `ValueError` - Invalid latitude or longitude value

### parse_location(location) |
Parse latitude and longitude from string location
    >>> "%.3f;%.3f" % parse_location("52.015;-0.221")
    '52.015;-0.221'
    >>> "%.3f;%.3f" % parse_location("52.015,-0.221")
    '52.015;-0.221'
    >>> "%.3f;%.3f" % parse_location("52.015 -0.221")
    '52.015;-0.221'
    >>> "%.3f;%.3f" % parse_location("52.015N 0.221W")
    '52.015;-0.221'
    >>> "%.3f;%.3f" % parse_location("52.015 N 0.221 W")
    '52.015;-0.221'
    >>> "%.3f;%.3f" % parse_location("52d00m54s N 0d13m15s W")
    '52.015;-0.221'
    >>> "%.3f;%.3f" % parse_location("52d0m54s N 000d13m15s W")
    '52.015;-0.221'
    >>> "%.3f;%.3f" % parse_location('''52d0'54" N 000d13'15" W''')
    '52.015;-0.221'
Parameters: `location` (`str`) - String to parse Returns: `tuple` of `float` objects Latitude and longitude of location

### sun_rise_set(latitude, longitude, date, mode=`'``rise``'`, timezone=0, zenith=None) |
Calculate sunrise or sunset for a specific location This function calculates the time sunrise or sunset, or optionally the beginning or end of a specified twilight period. Source:
    Almanac for Computers, 1990
    published by Nautical Almanac Office
    United States Naval Observatory
    Washington, DC 20392
    >>> sun_rise_set(52.015, -0.221, datetime.date(2007, 6, 15))
    datetime.time(3, 40)
    >>> sun_rise_set(52.015, -0.221, datetime.date(2007, 6, 15), "set")
    datetime.time(20, 23)
    >>> sun_rise_set(52.015, -0.221, datetime.date(2007, 6, 15), timezone=60)
    datetime.time(4, 40)
    >>> sun_rise_set(52.015, -0.221, datetime.date(2007, 6, 15), "set", 60)
    datetime.time(21, 23)
    >>> sun_rise_set(52.015, -0.221, datetime.date(1993, 12, 11))
    datetime.time(7, 58)
    >>> sun_rise_set(52.015, -0.221, datetime.date(1993, 12, 11), "set")
    datetime.time(15, 50)
    >>> sun_rise_set(89, 0, datetime.date(2007, 12, 21))
    >>> sun_rise_set(52.015, -0.221, datetime.date(2007, 2, 21))
    datetime.time(7, 4)
    >>> sun_rise_set(52.015, -0.221, datetime.date(2007, 1, 21))
    datetime.time(7, 56)
Parameters: `latitude` (`float` or coercible to `float`) - Location's latitude `longitude` (`float` or coercible to `float`) - Location's longitude `date` (`datetime.date`) - Calculate rise or set for given date `mode` (`str`) - Which time to calculate `timezone` (`int`) - Offset from UTC in minutes `zenith` (`None` or `str`) - Calculate rise/set events, or twilight times Returns: `datetime.time` or `None` The time for the given event in the specified timezone, or `None` if the event doesn't occur on the given date Raises: `ValueError` - Unknown value for `mode`

### sun_events(latitude, longitude, date, timezone=0, zenith=None) |
Convenience function for calculating sunrise and sunset
    >>> sun_events(52.015, -0.221, datetime.date(2007, 6, 15))
    (datetime.time(3, 40), datetime.time(20, 23))
    >>> sun_events(52.015, -0.221, datetime.date(2007, 6, 15), 60)
    (datetime.time(4, 40), datetime.time(21, 23))
    >>> sun_events(52.015, -0.221, datetime.date(1993, 12, 11))
    (datetime.time(7, 58), datetime.time(15, 50))
    >>> sun_events(52.015, -0.221, datetime.date(2007, 6, 15))
    (datetime.time(3, 40), datetime.time(20, 23))
    >>> sun_events(40.638611, -73.762222, datetime.date(2007, 6, 15)) # JFK
    (datetime.time(9, 23), datetime.time(0, 27))
    >>> sun_events(49.016666, -2.5333333, datetime.date(2007, 6, 15)) # CDG
    (datetime.time(4, 5), datetime.time(20, 16))
    >>> sun_events(35.549999, 139.78333333, datetime.date(2007, 6, 15)) # TIA
    (datetime.time(19, 25), datetime.time(9, 58))
Civil twilight starts/ends when the Sun's center is 6 degrees below the horizon.
    >>> sun_events(52.015, -0.221, datetime.date(2007, 6, 15), zenith="civil")
    (datetime.time(2, 51), datetime.time(21, 12))
    >>> sun_events(40.638611, -73.762222, datetime.date(2007, 6, 15),
    ...            zenith="civil") # JFK
    (datetime.time(8, 50), datetime.time(1, 0))
    >>> sun_events(49.016666, -2.5333333, datetime.date(2007, 6, 15),
    ...            zenith="civil") # CDG
    (datetime.time(3, 22), datetime.time(20, 59))
    >>> sun_events(35.549999, 139.78333333, datetime.date(2007, 6, 15),
    ...            zenith="civil") # TIA
    (datetime.time(18, 55), datetime.time(10, 28))
Nautical twilight starts/ends when the Sun's center is 12 degrees below the horizon.
    >>> sun_events(52.015, -0.221, datetime.date(2007, 6, 15),
    ...            zenith="nautical")
    (datetime.time(1, 32), datetime.time(22, 31))
    >>> sun_events(40.638611, -73.762222, datetime.date(2007, 6, 15),
    ...            zenith="nautical") # JFK
    (datetime.time(8, 7), datetime.time(1, 44))
    >>> sun_events(49.016666, -2.5333333, datetime.date(2007, 6, 15),
    ...            zenith="nautical") # CDG
    (datetime.time(2, 20), datetime.time(22, 1))
    >>> sun_events(35.549999, 139.78333333, datetime.date(2007, 6, 15),
    ...            zenith="nautical") # TIA
    (datetime.time(18, 18), datetime.time(11, 6))
Astronomical twilight starts/ends when the Sun's centre is 18 degrees below the horizon.
    >>> sun_events(52.015, -0.221, datetime.date(2007, 6, 15),
    ...            zenith="astronomical")
    (None, None)
    >>> sun_events(40.638611, -73.762222, datetime.date(2007, 6, 15),
    ...            zenith="astronomical") # JFK
    (datetime.time(7, 14), datetime.time(2, 36))
    >>> sun_events(49.016666, -2.5333333, datetime.date(2007, 6, 15),
    ...            zenith="astronomical") # CDG
    (None, None)
    >>> sun_events(35.549999, 139.78333333, datetime.date(2007, 6, 15),
    ...            zenith="astronomical") # TIA
    (datetime.time(17, 35), datetime.time(11, 49))
Parameters: `latitude` (`float` or coercible to `float`) - Location's latitude `longitude` (`float` or coercible to `float`) - Location's longitude `date` (`datetime.date`) - Calculate rise or set for given date `timezone` (`int`) - Offset from UTC in minutes `zenith` (`None` or `str`) - Calculate rise/set events, or twilight times Returns: `tuple` of `datetime.time` The time for the given events in the specified timezone

### dump_xearth_markers(markers, name=`'``identifier``'`) |
Generate an Xearth compatible marker file dump_xearth_markers() writes a simple Xearth marker file from a dictionary of trigpoints.Trigpoint objects. It expects a dictionary in one of the following formats. For support of Trigpoint that is:
    {500936: Trigpoint(52.066035, -0.281449, 37.0, "Broom Farm"),
     501097: Trigpoint(52.010585, -0.173443, 97.0, "Bygrave"),
     505392: Trigpoint(51.910886, -0.186462, 136.0, "Sish Lane")}
And generates output of the form:
    52.066035 -0.281449 "500936" # Broom Farm, alt 37m
    52.010585 -0.173443 "501097" # Bygrave, alt 97m
    51.910886 -0.186462 "205392" # Sish Lane, alt 136m
Or similar to the following if the `name` parameter is set to `name`:
    52.066035 -0.281449 "Broom Farm" # 500936 alt 37m
    52.010585 -0.173443 "Bygrave" # 501097 alt 97m
    51.910886 -0.186462 "Sish Lane" # 205392 alt 136m
Point objects should be provided in the following format:
    {"Broom Farm": Point(52.066035, -0.281449),
     "Bygrave": Point(52.010585, -0.173443),
     "Sish Lane": Point(51.910886, -0.186462)}
And generates output of the form:
    52.066035 -0.281449 "Broom Farm"
    52.010585 -0.173443 "Bygrave"
    51.910886 -0.186462 "Sish Lane"
    >>> from upoints.trigpoints import Trigpoint
    >>> markers = {
    ...     500936: Trigpoint(52.066035, -0.281449, 37.000000, "Broom Farm"),
    ...     501097: Trigpoint(52.010585, -0.173443, 97.000000, "Bygrave"),
    ...     505392: Trigpoint(51.910886, -0.186462, 136.000000, "Sish Lane")
    ... }
    >>> print("\n".join(dump_xearth_markers(markers)))
    52.066035 -0.281449 "500936" # Broom Farm, alt 37m
    52.010585 -0.173443 "501097" # Bygrave, alt 97m
    51.910886 -0.186462 "505392" # Sish Lane, alt 136m
    >>> print("\n".join(dump_xearth_markers(markers, "name")))
    52.066035 -0.281449 "Broom Farm" # 500936, alt 37m
    52.010585 -0.173443 "Bygrave" # 501097, alt 97m
    51.910886 -0.186462 "Sish Lane" # 505392, alt 136m
    >>> print("\n".join(dump_xearth_markers(markers, "falseKey")))
    Traceback (most recent call last):
        ...
    ValueError: Unknown name type `falseKey'
    >>> from upoints.point import Point
    >>> points = {
    ...     "Broom Farm": Point(52.066035, -0.281449),
    ...     "Bygrave": Point(52.010585, -0.173443),
    ...     "Sish Lane": Point(51.910886, -0.186462)
    ... }
    >>> print("\n".join(dump_xearth_markers(points)))
    52.066035 -0.281449 "Broom Farm"
    52.010585 -0.173443 "Bygrave"
    51.910886 -0.186462 "Sish Lane"
Parameters: `markers` (`dict`) - Dictionary of identifer keys, with Trigpoint values `name` (`str`) - Value to use as Xearth display string Returns: `list` List of strings representing an Xearth marker file Raises: `ValueError` - Unsupported value for `name` Note: xplanet also supports xearth marker files, and as such can use the output from this function. See Also: upoints.xearth.Xearths.import_locations

### calc_radius(latitude, ellipsoid=`'``WGS84``'`) |
Calculate earth radius for a given latitude This function is most useful when dealing with datasets that are very localised and require the accuracy of an ellipsoid model without the complexity of code necessary to actually use one. The results are meant to be used as a BODY_RADIUS replacement when the simple geocentric value is not good enough. The original use for calc_radius is to set a more accurate radius value for use with trigpointing databases that are keyed on the OSGB36 datum, but it has been expanded to cover other ellipsoids.
    >>> calc_radius(52.015)
    6375.1660253118571
    >>> calc_radius(0)
    6335.4387009096872
    >>> calc_radius(90)
    6399.5939421215426
    >>> calc_radius(52.015, "FAI sphere")
    6371.0
    >>> calc_radius(0, "Airy (1830)")
    6335.0221785420217
    >>> calc_radius(90, "International")
    6399.9365538714392
Parameters: `latitude` (`float`) - Latitude to calculate earth radius for `ellipsoid` (`tuple` of `float` objects) - Ellipsoid model to use for calculation Returns: `float` Approximated Earth radius at the given latitude

Variables Details | [hide private]

  ### BODIES Body radii of various solar system objects Value:
      {'Ceres': 475,
       'Earth': 6367,
       'Eris': 1200,
       'Jupiter': 69911,
       'Mars': 3390,
       'Mercury': 2440,
       'Moon': 1738,
       'Neptune': 24622,
      ...

  ### COMPASS_NAMES Value:
      ('North',
       'North-north-east',
       'North-east',
       'East-north-east',
       'East',
       'East-south-east',
       'South-east',
       'South-south-east',
      ...

  ### ZENITH Sunrise/-set mappings from name to angle Value:
      {None: -0.833333333333,
       'astronomical': -18,
       'civil': -6,
       'nautical': -12}