Skip to content
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

Rhessi returns database files of multiple months . #2418

Closed
wants to merge 6 commits into from

Conversation

yashkgp
Copy link
Contributor

@yashkgp yashkgp commented Jan 22, 2018

Fixes #2382
Made a new function that returns Rhessi files for multiple months

@pep8speaks
Copy link

pep8speaks commented Jan 22, 2018

Hello @yashkgp! Thanks for updating the PR.

Line 89:101: E501 line too long (101 > 100 characters)
Line 132:101: E501 line too long (101 > 100 characters)
Line 210:5: E303 too many blank lines (2)
Line 222:9: E128 continuation line under-indented for visual indent
Line 256:7: E271 multiple spaces after keyword
Line 256:98: E203 whitespace before ':'
Line 257:51: E231 missing whitespace after ','
Line 257:74: E251 unexpected spaces around keyword / parameter equals
Line 257:76: E251 unexpected spaces around keyword / parameter equals
Line 257:86: E251 unexpected spaces around keyword / parameter equals
Line 257:97: E251 unexpected spaces around keyword / parameter equals
Line 257:99: E251 unexpected spaces around keyword / parameter equals
Line 257:101: E501 line too long (105 > 100 characters)
Line 258:69: E251 unexpected spaces around keyword / parameter equals
Line 258:71: E251 unexpected spaces around keyword / parameter equals
Line 258:81: E251 unexpected spaces around keyword / parameter equals
Line 258:87: E231 missing whitespace after ','
Line 258:101: E501 line too long (105 > 100 characters)
Line 258:102: E202 whitespace before ')'
Line 260:9: E203 whitespace before ':'
Line 263:59: E231 missing whitespace after ','
Line 265:17: E203 whitespace before ':'
Line 266:59: E231 missing whitespace after ','
Line 266:82: E251 unexpected spaces around keyword / parameter equals
Line 266:84: E251 unexpected spaces around keyword / parameter equals
Line 266:94: E251 unexpected spaces around keyword / parameter equals
Line 266:101: E501 line too long (113 > 100 characters)
Line 266:105: E251 unexpected spaces around keyword / parameter equals
Line 266:107: E251 unexpected spaces around keyword / parameter equals
Line 268:38: E251 unexpected spaces around keyword / parameter equals
Line 268:40: E251 unexpected spaces around keyword / parameter equals
Line 268:50: E251 unexpected spaces around keyword / parameter equals
Line 402:101: E501 line too long (122 > 100 characters)

Comment last updated on February 17, 2018 at 09:54 Hours UTC

@nabobalis
Copy link
Contributor

Unfortunately, the change breaks a test we have in SunPy. test_get_obssumm_file_timerange_warnings which tests to make sure that get_obssumm_file only returns one file.

Either this test would need to be changed or removed.

Before that however, since I am unsure if this fixes the issue (rhessi is a strange part of SunPy), could you provide a code example and show me the output before and after this fix has been applied?

@nabobalis nabobalis added [BugFix] instr Affects the instr submodule labels Jan 23, 2018
@yashkgp
Copy link
Contributor Author

yashkgp commented Jan 24, 2018

Here is a code snippet :

>>> import sunpy.instr.rhessi as rhessi
>>> fname = rhessi.get_obssumm_file(('2011/04/04', '2011/04/06'))
>>> print (fname)

The result was a list , containing the directory of saved file and info() method returned by the urlopen

[('/tmp/tmpmelg3cw4', <http.client.HTTPMessage object at 0x7fa17be9b160>), ('/tmp/tmp6_8b69li', <http.client.HTTPMessage object at 0x7fa17be9b0b8>)]

If this doesn't fixes,could you help me out ?

@nabobalis
Copy link
Contributor

Comparing it current master that does seem to now provide more than one day.

The next step is to fix the test that is failing. Then update the documentation where possible about this change.

@ehsteve or @Cadair, can you recall why only one day was supported in the first place?

@yashkgp What I will say is that this does not seem to close #2382. That issue is about FIDO unable to search for more than one month worth of data. You would have to test that.

@nabobalis nabobalis added [WIP] and removed [BugFix] labels Jan 24, 2018
@nabobalis
Copy link
Contributor

I suspect that changing it there means other changes in the file need to be made.

@yashkgp
Copy link
Contributor Author

yashkgp commented Jan 29, 2018

Hey @nabobalis , I have made a commit that solves issue #2382
I have made a new function get_obssum_filename_multiple_months which returns database filenames for multiple months . Here is a code snippets that shows the working of function

>>> import sunpy.instr.rhessi as rhessi
>>> rhessi.get_obssum_filename_multiple_months(('2011/04/04', '2011/05/09'))

And the output was

/home/yash_jain/Desktop/sunpy_env/sunpy/sunpy/instr/rhessi.py:100: UserWarning: Currently only support providing data from one whole day. Only data for 2011-05-01 will be returned
  _check_one_day(_time_range)
[['https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110404_042.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110405_031.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110406_041.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110407_031.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110408_038.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110409_030.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110410_028.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110411_024.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110412_024.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110413_022.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110414_017.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110415_020.fits', 'http://hessi.ssl.berkeley.edu/hessidata/metadata/catalog/hsi_obssumm_20110416_016.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110417_017.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110418_017.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110419_024.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110420_029.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110421_025.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110422_029.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110423_030.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110424_025.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110425_026.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110426_022.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110427_029.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110428_021.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110429_028.fits'], ['https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110501_021.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110502_023.fits', 'http://hessi.ssl.berkeley.edu/hessidata/metadata/catalog/hsi_obssumm_20110503_027.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110504_032.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110505_028.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110506_031.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110507_024.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110508_022.fits']]

Filenames of different months in the time range as list

@yashkgp
Copy link
Contributor Author

yashkgp commented Jan 29, 2018

And for the get_obssumm_file function issue (function only spans a single day ), what are the other changes that I have to make in rhessi.py . Should I send another PR for this issue ?

@yashkgp yashkgp changed the title Rhessi returns database files of multiple whole days . Rhessi returns database files of multiple months . Jan 29, 2018
@nabobalis
Copy link
Contributor

The first issue is that your changes broke one of the tests and that needs to be addressed.

I am unsure we need another function within the code, we seem to have 3 functions for returning rhessi data. We seem to have, get_obssumm_file, get_obssumm_file and now get_obssum_filename_multiple_months. I do not see why we need these all.

Also if the changes mean we can return more than one day, does _check_one_day need to be left in the code?

I am not very familiar with this code, @ehsteve, what do you think about the changes?

Copy link
Member

@ehsteve ehsteve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, I think I would suggest that the original get_obssum_filename be modified to return multiple files if needed as opposed to creating a new function.


Parameters
----------
time_range : str, TimeRange
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Cadair is this a standard that we always also accept a string version of a time range?


Returns
-------
out : list of lists
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this a list of lists? The examples shows only a list.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats a typo in the example ,The function return list of lists with each list containing data for a single month in the given time range . I'll just update it. Here is a code snippet on how this function works :

>>> import sunpy.instr.rhessi as rhessi
>>> rhessi.get_obssum_filename_multiple_months(('2011/04/04', '2011/05/09'))

And the output was

/home/yash_jain/Desktop/sunpy_env/sunpy/sunpy/instr/rhessi.py:100: UserWarning: Currently only support providing data from one whole day. Only data for 2011-05-01 will be returned
  _check_one_day(_time_range)
[['https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110404_042.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110405_031.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110406_041.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110407_031.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110408_038.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110409_030.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110410_028.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110411_024.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110412_024.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110413_022.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110414_017.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110415_020.fits', 'http://hessi.ssl.berkeley.edu/hessidata/metadata/catalog/hsi_obssumm_20110416_016.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110417_017.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110418_017.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110419_024.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110420_029.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110421_025.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110422_029.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110423_030.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110424_025.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110425_026.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110426_022.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110427_029.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110428_021.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110429_028.fits'], ['https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110501_021.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110502_023.fits', 'http://hessi.ssl.berkeley.edu/hessidata/metadata/catalog/hsi_obssumm_20110503_027.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110504_032.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110505_028.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110506_031.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110507_024.fits', 'https://hesperia.gsfc.nasa.gov/hessidata/metadata/catalog/hsi_obssumm_20110508_022.fits']]

Filenames of different months in the time range as list

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be useful for the function to clean this up and make it just a simple list.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done !
Could you suggest a name for the method or the current one is fine ?

"""
time_range = TimeRange(time_range)
filenames = []
delta = relativedelta(time_range.end, time_range.start)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to use this function as opposed to just

delta = time_range.end - time_range.start

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. I've educated myself using stackoverflow and now I'm wondering if TimeRange should be using that rather than timeldeta since it's so much more useful, @Cadair?

filenames = []
delta = relativedelta(time_range.end, time_range.start)
date = time_range.start
if delta.years <= 0 and delta.months <= 0 and time_range.start.month != time_range.end.month :
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this code here just to check that the time_range here is less than one month and which case the user should not be using this function at all, correct?

Copy link
Contributor Author

@yashkgp yashkgp Feb 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its partially true , Actually get_obssum_filename cannot return filenames spanning over multiple months even when its less than 1 month. (Ex . Time_range(("2011/04/28"),("2011/05/05")) ). Rhessi servers return data of a single month when get_obssum_filename is called ,so this code makes sure that if time_range is less than a month and spans over 2 month then get_obssum_filename should be called 2 times .

@wafels
Copy link
Member

wafels commented Feb 13, 2018 via email

@ehsteve
Copy link
Member

ehsteve commented Feb 13, 2018

@wafels, FYI, I used that short-hand (obssumm) because it is a term often used on the RHESSI side though that should not stop us from changing it.

@nabobalis
Copy link
Contributor

This PR has been superseded by #2468.

Sorry about this @yashkgp. Your commits are still in the new PR.

@nabobalis nabobalis closed this Feb 20, 2018
@nabobalis nabobalis removed the [WIP] label Apr 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
instr Affects the instr submodule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants