https://github.com/brews/tellervo-python
Python client to the Tellervo dendrochronology suite.
https://github.com/brews/tellervo-python
dendrochronology python
Last synced: 3 months ago
JSON representation
Python client to the Tellervo dendrochronology suite.
- Host: GitHub
- URL: https://github.com/brews/tellervo-python
- Owner: brews
- License: gpl-3.0
- Created: 2015-09-25T17:40:33.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-03-04T21:19:04.000Z (over 9 years ago)
- Last Synced: 2025-07-05T02:57:17.338Z (3 months ago)
- Topics: dendrochronology, python
- Language: Python
- Homepage:
- Size: 48.8 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
#tellervo-python
[](https://travis-ci.org/brews/tellervo-python)Python client to the [Tellervo dendrochronology suite](http://tellervo.org/).
Note that this software is under development. It may eat your pet hamster.
## Installation
Releases are in the [Python Package Index](https://pypi.python.org/pypi?:action=display&name=tellervo-python). You can install the package with `pip install tellervo-python`. This package requires a copy of Python 3.3 or more recent, so on some linux distros you might need to use `pip3`.
Bleeding-edge development can be found on [Github](https://github.com/brews/tellervo-python), if you like being in the danger zone.
##Example
Here is a quick example that queries a Tellervo server with a search request. The server replies with [TRiDaS XML](http://www.tridas.org/). We gather the fields we want from the XML reply and stick the information into a list of dictionaries.```python
import tellervo as telUSERNAME = 'username'
SERVER_URL = "https://tellervo.example.edu/ourserver/"
# Password is entered when we setup the connection below.# Build a search query.
# Here we're looking for a comprehensive sample form any sample with a
# sampling date is after 2015-01-01.
search_query = tel.build_searchrequest(return_object = 'sample',
search_name = 'samplingdate',
search_operator = '>',
search_value = '2015-01-01',
results_format = 'comprehensive')# Open connection to Tellervo server, throw our query at it, close connection.
# Note that using the `with as` statement will close the connection to the
# server, even if something goes wrong.
with tel.Connection(SERVER_URL, USERNAME, 'MyPassword!') as con:
reply = con.execute(search_query)# Parse TRiDaS XML from server.
select_data = []
for site in reply.body.content.iterchildren():
sample_dict = {'site_name': site.title.text,
'tree_name': site.element.title.text,
'tree_taxon': site.element.taxon.get('normal'),
'sample_name': site.element.sample.title.text}
select_data.append(sample_dict)
```For more on parsing the XML replies, see [lxml](http://lxml.de/).
If you want to refine things further, we can easily take our `select_data` list and turn it into a [pandas](http://pandas.pydata.org/) DataFrame. We then sort the data.
```python
import pandas as pdd = pd.DataFrame(select_data, dtype = 'str')
d = d.sort_values(by = ['site_name', 'tree_name', 'sample_name'])
```