Skip to content

Commit

Permalink
Merge pull request #6 from dstansby/latest-product
Browse files Browse the repository at this point in the history
Fix client to only return latest product
  • Loading branch information
dstansby committed Aug 14, 2021
2 parents 4ca0f0a + cf6eaa9 commit 389cd71
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
11 changes: 10 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ PyPI using:
.. code-block:: bash
pip install sunpy-soar
or conda using

.. code-block:: bash
Expand Down Expand Up @@ -70,3 +70,12 @@ Other search attributes can be used too; sunpy-soar recognises the following:
- ``sunpy.net.attrs.Instrument``
- ``sunpy.net.attrs.Level``
- ``sunpy_soar.attrs.Identifier``


Changelog
---------
1.1
~~~
- Fixed download of data where multiple versions of the requested file are
available. Only the most recent version will be downloaded.
- Added some log messages to the sunpy logger at DEBUG level
5 changes: 4 additions & 1 deletion sunpy_soar/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import astropy.table

from sunpy import log
import sunpy.net.attrs as a
from sunpy.net.attr import and_
from sunpy.net.base_client import BaseClient, QueryResponseTable
Expand Down Expand Up @@ -55,6 +56,7 @@ def _do_search(query):
request_str = '&'.join(request_str)

url = base_url + request_str
log.debug(f'Getting request from URL: {url}')
# Get request info
r = requests.get(url)
r.raise_for_status()
Expand Down Expand Up @@ -82,12 +84,13 @@ def _do_search(query):

def fetch(self, query_results, *, path, downloader, **kwargs):
base_url = ('http://soar.esac.esa.int/soar-sl-tap/data?'
f'retrieval_type=PRODUCT&product_type=SCIENCE&'
f'retrieval_type=LAST_PRODUCT&product_type=SCIENCE&'
'data_item_id=')

for row in query_results:
url = base_url + row['Data item ID']
filepath = str(path).format(file=row['Filename'])
log.debug(f'Queing URL: {url}')
downloader.enqueue_file(url, filename=filepath)

@classmethod
Expand Down

0 comments on commit 389cd71

Please sign in to comment.