New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Download from fido search result implemented #1877
Conversation
Hello @Punyaslok! Thanks for updating the PR.
Comment last updated on May 03, 2018 at 19:58 Hours UTC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to move Database.fetch
over to using Fido.
Here is a non suspicious patch in a zip. Will not fix the online tests though. |
Looks like a real test failure.
|
…_result_block in tables.py
…as in path, then fname was not assigned any value as both if and elif were skipped.
|
||
>>> from sunpy.net import Fido, attrs as a # doctest: +REMOTE_DATA | ||
>>> search_result = Fido.search(a.Time("2012/1/1", "2012/1/2"), | ||
... a.Instrument('lyra')) # doctest: +REMOTE_DATA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation error
resulting search result determines the number of entries that will be added | ||
to the database. The number of entries that will be added depends on the total | ||
number of FITS headers. The :meth:`Database.download_from_fido_search_result()` | ||
method also accepts an optional keyword argument `path` which determines the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be two backticks as it's not a code reference
|
||
>>> database.download_from_fido_search_result(search_result) # doctest: +REMOTE_DATA | ||
>>> print(display_entries(database, ['id', 'observation_time_start', | ||
... 'observation_time_end', 'instrument', 'source'])) # doctest: +REMOTE_DATA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation
for sr_entry, temp in zip(search_result, entries_list): | ||
for database_entry in self: | ||
if database_entry.path is not None and sr_entry._compare_attributes(database_entry, | ||
["source", "provider", "physobs", "fileid", "observation_time_start", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would indent this a but more so it dosen't align to the following lines.
delete_entries.append(database_entry) | ||
|
||
for temp in remove_list: | ||
search_result = [x for x in search_result if x != temp] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could re-write this using sets rather than the for loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remembered the reason not to use set difference for this. It will not maintain the ordering of the elements. Should I leave it as it is ?
for (path, sr_entry) in zip(paths, entries_list): | ||
|
||
try: | ||
read_file_header(path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed this probably shouldn't be here, as entries_from_file
should raise if there is an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My commit means you don't need this line anymore, I think
if os.path.isfile(path): | ||
entries = tables.entries_from_file(path, self.default_waveunit) | ||
elif os.path.isdir(path): | ||
entries = tables.entries_from_dir(path, self.default_waveunit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should modify entries_from_dir
to support returning a bare bones entry for non-sunpy io supported files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so path should never actually be a directory, so we can probably just drop this line or replace it with an exception.
@@ -147,6 +147,8 @@ def download(self, url, path=None, callback=None, errback=None): | |||
server = self._get_server(url) | |||
|
|||
# Create function to compute the filepath to download to if not set | |||
#if path is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these supposed to be here?
try: | ||
instrument_name = next(x for x in entry.fits_header_entries if x.key == 'TELESCOP').value | ||
except Exception: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be instrument_name = ''
so that it's defined below.
if 'goes' in instrument_name.lower(): | ||
entry.observation_time_end = datetime.strptime(value, | ||
'%d/%m/%Y') | ||
# else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uncomment this
if 'goes' in instrument_name.lower(): | ||
entry.observation_time_start = datetime.strptime(value, | ||
'%d/%m/%Y') | ||
# else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this
dobj.download(aurl, fname, ncall, error_callback) | ||
# dobj.download(aurl, kwargs.get('path', None), ncall, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete?
This pull request has been automatically marked as stale because it has not had any activity for the past five months. It will be closed if no further activity occurs. If the ideas in this pull request are still worth implementing, please make sure you open an issue to keep track of that idea! |
This pull request has been automatically closed since there was no activity for a month since it was marked as stale. If the ideas in this pull request are still worth implementing, please make sure you open an issue to keep track of that idea! |
This PR also contains the commits in #1830 and #1785 and #1856
@Cadair