Skip to main content

A pure-Python package to download data from SWEET-Cat

Project description

A pure-Python package to download data from SWEET-Cat.

This small package was developed as an exercise in a Python course (see CONTRIBUTORS). It downloads all the data from the SWEET-Cat online catalogue of stellar parameters and builds a (custom) dictionary with each column. It is a pure-Python package with no extra dependencies (see below).

License MIT Travis build PyPI version

How to use

Install it from pip (pySWEETCat has no extra depencies)

pip install pySWEETCat

and it’s ready to use from Python

import pysweetcat

pySWEETCat has one simple function, get_data(), which downloads the data from the online archive and returns it in a dictionary.

>>> data = pysweetcat.get_data()
Downloading SWEET-Cat data
Saved SWEET-Cat data to $HOME/.pysweetcat/SWEET_cat.tsv
Data in `SWEET_cat.tsv` is recent.
There are 25 columns with 2627 entries each in `SWEET_cat.tsv`

where $HOME will be your home directory. The second time you call get_data() it will check if the data was downloaded recently, and only conditionally download it again.

>>> data = pysweetcat.get_data()
Data in `SWEET_cat.tsv` is recent.
There are 25 columns with 2627 entries each in `SWEET_cat.tsv`

Now, data is (basically) a Python dictionary with the each column as keys. But it has a couple extra methods and properties. For example

data.size
2627

returns the number of values in each column.

The columns can be accessed as in a normal dictionary, as in

data['feh']   # stellar metallicity
data['name']  # name of the star

and both of these will work

data['σ_vmag']
data['sigma_vmag']

Also, to drop the NaN values in a column (for some columns there will be quite a few) we can use

data['teff_nonan']

np.isnan(data['teff']).any()       # True
np.isnan(data['teff_nonan']).any() # False

which allows us to more easily do histograms of the values.

Finnally, the .to_numpy(inplace=True) method converts all the columns to numpy arrays, either in place or not (this is the only function in pySWEETCat that requires numpy).

License

Copyright 2018 João Faria.

pySWEETCat is free software made available under the MIT License. For details see the LICENSE file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pySWEETCat, version 1.0.2
Filename, size & hash File type Python version Upload date
pySWEETCat-1.0.2-py3-none-any.whl (7.1 kB) View hashes Wheel py3
pySWEETCat-1.0.2.tar.gz (4.5 kB) View hashes Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page