question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Downloading certain data products does not work for Kepler and K2

See original GitHub issue

Problem description

lk.search_lightcurvefile().download_all() raises a FileNotFoundError when specifying a custom download_dir only when the mission is Kepler or K2. On the contrary, a custom download_dir works for TESS lightcurve files (see examples below).

Example

When downloading Kepler lightcurve files to a specified download_dir I get the following error, e.g.

import lightkurve as lk

LK_CACHE_DIR = 'test/lightkurve-cache'
ID = 'KIC4448777'
MISSION = 'Kepler'

lcc = lk.search_lightcurvefile(ID, mission=MISSION).download_all(download_dir=LK_CACHE_DIR)
Traceback (most recent call last):
  File "/Users/ajl573/Repos/alexlyttle/jam-ensemble/test_lk_cache.py", line 7, in <module>
    lcc = lk.search_lightcurvefile(ID, mission=MISSION).download_all(download_dir=LK_CACHE_DIR)
  File "/Users/ajl573/.virtualenvs/base/lib/python3.7/site-packages/lightkurve/utils.py", line 473, in wrapper
    return f(*args, **kwargs)
  File "/Users/ajl573/.virtualenvs/base/lib/python3.7/site-packages/lightkurve/search.py", line 293, in download_all
    cutout_size=cutout_size))
  File "/Users/ajl573/.virtualenvs/base/lib/python3.7/site-packages/lightkurve/search.py", line 179, in _download_one
    return _open_downloaded_file(path, quality_bitmask=quality_bitmask)
  File "/Users/ajl573/.virtualenvs/base/lib/python3.7/site-packages/lightkurve/search.py", line 1013, in _open_downloaded_file
    return open(path, **kwargs)
  File "/Users/ajl573/.virtualenvs/base/lib/python3.7/site-packages/lightkurve/search.py", line 997, in open
    raise e
  File "/Users/ajl573/.virtualenvs/base/lib/python3.7/site-packages/lightkurve/search.py", line 990, in open
    with fits.open(path_or_url) as temp:
  File "/Users/ajl573/.virtualenvs/base/lib/python3.7/site-packages/astropy/io/fits/hdu/hdulist.py", line 151, in fitsopen
    lazy_load_hdus, **kwargs)
  File "/Users/ajl573/.virtualenvs/base/lib/python3.7/site-packages/astropy/io/fits/hdu/hdulist.py", line 390, in fromfile
    lazy_load_hdus=lazy_load_hdus, **kwargs)
  File "/Users/ajl573/.virtualenvs/base/lib/python3.7/site-packages/astropy/io/fits/hdu/hdulist.py", line 1039, in _readfrom
    fileobj = _File(fileobj, mode=mode, memmap=memmap, cache=cache)
  File "/Users/ajl573/.virtualenvs/base/lib/python3.7/site-packages/astropy/utils/decorators.py", line 521, in wrapper
    return function(*args, **kwargs)
  File "/Users/ajl573/.virtualenvs/base/lib/python3.7/site-packages/astropy/io/fits/file.py", line 178, in __init__
    self._open_filename(fileobj, mode, overwrite)
  File "/Users/ajl573/.virtualenvs/base/lib/python3.7/site-packages/astropy/io/fits/file.py", line 555, in _open_filename
    self._file = fileobj_open(self.name, IO_FITS_MODES[mode])
  File "/Users/ajl573/.virtualenvs/base/lib/python3.7/site-packages/astropy/io/fits/util.py", line 397, in fileobj_open
    return open(filename, mode, buffering=0)
FileNotFoundError: [Errno 2] No such file or directory: 'test/lightkurve-cache/mastDownload/Kepler/kplr004448777_lc_Q111111111111111111/kplr004448777-2009131105131_llc.fits'

and the same error occurs with K2 lightcurve files, e.g.

ID = '220397845'
MISSION = 'K2'

Lightkurve creates the download directories but not files are present.

Expected behavior

The above works with TESS lightcurves, I expect it to run without exceptions, e.g.

import lightkurve as lk

LK_CACHE_DIR = 'test/lightkurve-cache'
ID = 'TIC146264536'
MISSION = 'TESS'

lcc = lk.search_lightcurvefile(ID, mission=MISSION).download_all(download_dir=LK_CACHE_DIR)

This runs fine and I see the cached files under ‘test/lightkurve-cache/mastDownload…’.

Environment

  • platform: macOS 10.15.3 Catalina
  • lightkurve version: 1.8 (I have tested this on previous versions)
  • installation method: pip

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
ceb8commented, Feb 12, 2020

I am seeing this same problem using the default cache location. (I verified that I can download Kepler light curves from MAST directly using Astroquery).

Environment

  • platform: macOS 10.13.6 High Sierra
  • lightkurve version: 1.8 (also encountered this behavior on 1.1.1)
  • installation method: pip
0reactions
barentsencommented, Feb 12, 2020

Thank you @ceb8. I confirm all seems fine again!

@alexlyttle Thank you so much for taking the time to report! 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Searching & downloading Kepler, K2, and TESS data
The Lightkurve Python package has functions to search for and download observations from Kepler/K2 and TESS. These tools are built to make accessing...
Read more >
Kepler and K2 data products - GitHub Pages
There is documentation specific to the Kepler data products and to the K2 ... products and catalogs are available through MAST and can...
Read more >
Download Options for Kepler Data and Catalogs - MAST Archive
For individual files, both FTP and HTTP can be used to download Kepler data and catalogs. For FTP, connect to archive.stsci.edu anonymously ...
Read more >
Kepler Data Products Overview - NASA Exoplanet Archive
Location: Go to Kepler TCE Documentation (NASA Exoplanet Archive) and select the data release of choice. Bulk download is available at >Bulk  ......
Read more >
Kadenza: Kepler/K2 Cadence Data Reader - GitHub
Most users of Kepler/K2 data will not require this tool, because it does ... If you have a working installation of Python on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found