Last active
December 7, 2019 08:19
-
-
Save ntessore/640649a60ef7f3008e7583ad5d449862 to your computer and use it in GitHub Desktop.
download a file if not already downloaded
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# download file if not already downloaded | |
def dl(url, file=None): | |
from urllib.request import urlretrieve | |
from urllib.parse import urlparse | |
import os.path | |
if file is None: | |
file = os.path.basename(urlparse(url).path) | |
if not os.path.exists(file): | |
urlretrieve(url, file) | |
return file | |
# get SED templates | |
sed_fits = fits.open(dl('https://github.com/blanton144/kcorrect/raw/master/data/templates/k_nmf_derived.default.fits')) | |
# can specify name of downloaded file as well | |
sed_fits = fits.open(dl('https://github.com/blanton144/kcorrect/raw/master/data/templates/k_nmf_derived.default.fits', 'templates.fits')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment