2014-06-15 09:06:17 +02:00
# pyhamtools
2014-04-24 13:48:38 +02:00
2021-06-01 03:27:32 +02:00

2018-01-28 02:30:15 +01:00
[](https://codecov.io/gh/dh1tw/pyhamtools)
[](https://badge.fury.io/py/pyhamtools)
2018-01-27 23:55:57 +01:00
2023-12-28 21:02:41 +01:00
Pyhamtools is a set of functions and classes for Amateur Radio purposes.
2021-06-01 03:27:32 +02:00
Currently, the core part is the Callsign Lookup which decodes any amateur radio
2018-01-27 23:55:57 +01:00
callsign string and provides the corresponding information (Country, DXCC
entity, CQ Zone...etc). This basic functionality is needed for Logbooks,
2018-01-28 00:30:34 +01:00
DX-Clusters or Log Checking. This and additional convenience features are
provided for the following sources:
2014-06-15 10:13:09 +02:00
Currently,
2021-12-08 23:57:40 +01:00
* [AD1C's Amateur Radio Country Files ](https://www.country-files.com )
2014-06-15 09:06:17 +02:00
* [Clublog Prefixes & Exceptions XML File ](https://clublog.freshdesk.com/support/articles/54902-downloading-the-prefixes-and-exceptions-as )
* [Clublog DXCC Query API ](http://clublog.freshdesk.com/support/articles/54904-how-to-query-club-log-for-dxcc )
2015-04-06 20:05:18 +02:00
* [QRZ.com XML API ](http://www.qrz.com/XML/current_spec.html )
2014-06-15 09:06:17 +02:00
* [Redis.io ](http://redis.io )
2021-12-08 23:57:40 +01:00
* [ARRL Logbook of the World (LOTW) ](https://lotw.arrl.org )
2018-01-28 00:30:34 +01:00
* [eQSL.cc user list ](https://www.eqsl.cc )
* [Clublog & OQRS user list ](http://clublog.freshdesk.com/support/solutions/articles/3000064883-list-of-club-log-and-lotw-users )
2014-04-24 17:46:46 +02:00
2021-06-01 03:27:32 +02:00
Other modules include location-based calculations (e.g. distance,
heading between Maidenhead locators) or frequency-based calculations
2018-01-27 23:55:57 +01:00
(e.g. frequency to band).
2014-09-21 20:42:52 +02:00
2014-06-15 10:18:48 +02:00
## References
2018-01-27 23:55:57 +01:00
This Library is used in production at the [DXHeat.com DX Cluster ](https://dxheat.com ), performing several thousand lookups and calculations per day.
## Compatibility
2023-12-28 21:02:41 +01:00
Pyhamtools is compatible with Python >=3.6.
We check compatibility on OSX, Windows, and Linux with the following Python versions:
2018-01-28 00:30:34 +01:00
2019-11-27 03:10:08 +01:00
* Python 3.8
2021-06-01 03:27:32 +02:00
* Python 3.9
2022-12-05 01:01:45 +01:00
* Python 3.10
* Python 3.11
2023-12-28 21:02:41 +01:00
* Python 3.12
2025-03-02 00:10:44 +01:00
* Python 3.13
2022-12-05 01:01:45 +01:00
* [pypy3.8 ](https://pypy.org/ )
* [pypy3.9 ](https://pypy.org/ )
2023-12-28 21:02:41 +01:00
* [pypy3.10 ](https://pypy.org/ )
2025-06-10 01:34:16 +02:00
### depreciated: Python 2.7 & Python 3.5
The support for Python 2.7 and 3.5 has been deprecated at the end of 2023. The last version which supports Python 2.7 and Python 3.5 is 0.8.7.
### depricated: Python 3.6 & Python 3.7
Support for Python 3.6 and Python 3.7 has been deprecated in June 2025. The last version which support Python 3.6 and Python 3.7 is 0.11.0.
2014-06-15 10:13:09 +02:00
## Documentation
2018-01-27 23:55:57 +01:00
2018-01-28 00:30:34 +01:00
Check out the full documentation including the changelog at:
[pyhamtools.readthedocs.org ](http://pyhamtools.readthedocs.org/en/latest/index.html )
2014-06-15 09:06:17 +02:00
2016-08-26 05:00:48 +02:00
## License
2018-01-27 23:55:57 +01:00
2018-01-28 00:30:34 +01:00
Pyhamtools is published under the permissive [MIT License ](http://choosealicense.com/licenses/mit/ ). You can find a good comparison of
2018-01-27 23:55:57 +01:00
Open Source Software licenses, including the MIT license at [choosealicense.com ](http://choosealicense.com/licenses/ )
2016-08-26 05:00:48 +02:00
2022-12-05 01:01:45 +01:00
## Dependencies
Starting with version 0.8.0, `libxml2-dev` and `libxslt-dev` are required dependencies.
2024-01-03 22:09:42 +01:00
There is a good change that the libraries are already installed on your system. If not, you can install them with the package manager of your distro. For example on Debian / Ubuntu based distros the corresponding command is:
2022-12-05 01:01:45 +01:00
```bash
$ sudo apt-get install libxml2-dev libxslt-dev
```
2024-01-03 22:09:42 +01:00
You don't need to install these libraries manually on Windows / MacOS.
## Installation
2021-06-01 03:27:32 +02:00
The easiest way to install pyhamtools is through the packet manager `pip` :
2018-01-28 00:30:34 +01:00
```bash
$ pip install pyhamtools
2014-06-15 10:25:16 +02:00
2018-01-28 00:30:34 +01:00
```
2014-06-15 09:06:17 +02:00
2022-12-05 01:12:52 +01:00
Christoph, [@df7cb ](https://github.com/df7cb ) is kindly maintaining a Debian package as an alternative way to install pyhamtools:
2022-12-05 01:01:45 +01:00
```bash
$ sudo apt-get install pyhamtools
```
2014-06-15 10:18:48 +02:00
## Example: How to use pyhamtools
2014-06-15 09:06:17 +02:00
2018-01-27 23:55:57 +01:00
``` python
2014-09-21 20:42:52 +02:00
>>> from pyhamtools.locator import calculate_heading
>>> calculate_heading("JN48QM", "QF67bf")
74.3136
2014-06-15 09:06:17 +02:00
>>> from pyhamtools import LookupLib, Callinfo
>>> my_lookuplib = LookupLib(lookuptype="countryfile")
>>> cic = Callinfo(my_lookuplib)
>>> cic.get_all("DH1TW")
{
'country': 'Fed. Rep. of Germany',
'adif': 230,
'continent': 'EU',
'latitude': 51.0,
2018-01-28 00:39:01 +01:00
'longitude': 10.0,
2014-06-15 09:06:17 +02:00
'cqz': 14,
'ituz': 28
}
```
2014-06-15 10:13:09 +02:00
## Testing
2018-01-27 23:55:57 +01:00
2016-08-26 05:00:48 +02:00
An extensive set of unit tests has been created for all Classes & Methods.
2021-06-01 03:27:32 +02:00
To be able to perform all tests, you need a QRZ.com account and a
2018-01-27 23:55:57 +01:00
[Clublog API key ](http://clublog.freshdesk.com/support/solutions/articles/54910-api-keys ).
pyhamtools rely on the [pytest ](https://docs.pytest.org/en/latest/ ) testing
2021-06-01 03:27:32 +02:00
framework. To install it with all the needed dependencies run:
2018-01-27 23:55:57 +01:00
```bash
$ pip install -r requirements-pytest.txt
```
2021-06-01 03:27:32 +02:00
The QRZ.com credentials and the Clublog API key have to be set in the environment
2018-01-27 23:55:57 +01:00
variables:
```bash
$ export CLUBLOG_APIKEY="< your API key > "
$ export QRZ_USERNAME="< your qrz . com username > "
$ export QRZ_PWD="< your qrz . com password > "
```
2021-06-01 03:27:32 +02:00
To perform the tests related to the [redis ](https://redis.io/ ) key/value
store, a Redis server has to be up & running.
2018-01-28 13:06:26 +01:00
```bash
$ sudo apt install redis-server
$ redis-server
```
2018-01-27 23:55:57 +01:00
To run the tests, simply execute:
```bash
2018-01-28 13:06:26 +01:00
$ pytest --cov pyhamtools
2018-01-27 23:55:57 +01:00
```
## Generate the documentation
You can generate the documentation of pyhamtools with the following commands:
```bash
$ pip install -r requirements-docs.txt
$ cd docs
$ make html
```