{"action":"created","comment":{"url":"https://api.github.com/repos/sunpy/sunpy/pulls/comments/70185856","id":70185856,"diff_hunk":"@@ -0,0 +1,163 @@\n+\"\"\"\n+This module implements SOLIS VSM.\n+\"\"\"\n+#This module was developed with funding provided by\n+#the Google Summer of Code 2016.\n+\n+__author__ = \"Sudarshan Konge\"\n+__email__ = \"sudk1896@gmail.com\"\n+\n+import datetime\n+import urllib2\n+import re\n+from bs4 import BeautifulSoup\n+import numpy as np\n+\n+from sunpy.net.dataretriever.client import GenericClient\n+from sunpy.util.scraper import Scraper\n+\n+_all__ = ['VSMClient']\n+\n+class VSMClient(GenericClient):\n+    \"\"\"\n+    Returns a list of URLS to SOLIS VSM files corresponding to value of input timerange.\n+    URL source: `http://gong2.nso.edu/pubkeep/`.\n+    Parameters\n+    ----------\n+    timerange: sunpy.time.TimeRange\n+        time range for which data is to be downloaded.\n+        Example value - TimeRange('2015-12-30 00:00:00','2015-12-31 00:01:00')\n+\n+    Instrument: Fixed argument - 'vsm' ,case insensitive.\n+\n+    Wavelength: Any of 6302, 8542 or 10830 Angstrom units or equivalent values in different units.\n+                Expects a Wavelength object.\n+                e.g. 6302*u.AA, 630.2*u.nm etc.\n+\n+    Physobs: Optional, includes 'LOS_MAGNETIC_FIELD', \"VECTOR_MAGNETIC_FIELD'\n+             'EQUIVALENT_WIDTH'.\n+\n+    Examples\n+    --------\n+    >>> from sunpy.net import Fido\n+    >>> from sunpy.net import attrs as a\n+    >>> res = Fido.search(a.Time('2016/6/4', '2016/6/4 00:10:00'), a.Instrument('vsm'),\n+                          a.Wavelength(6302*u.AA), a.Physobs('VECTOR_MAGNETIC_FIELD'))\n+    >>> print (res)\n+    [<Table length=6>\n+         Start Time           End Time      Source Instrument\n+           str19               str19         str5     str3\n+    ------------------- ------------------- ------ ----------\n+    2015-01-03 00:00:00 2015-01-04 00:00:00  SOLIS        vsm\n+    2015-01-04 00:00:00 2015-01-05 00:00:00  SOLIS        vsm\n+    2015-01-05 00:00:00 2015-01-06 00:00:00  SOLIS        vsm\n+    2015-01-06 00:00:00 2015-01-07 00:00:00  SOLIS        vsm\n+    2015-01-07 00:00:00 2015-01-08 00:00:00  SOLIS        vsm\n+    2015-01-08 00:00:00 2015-01-09 00:00:00  SOLIS        vsm]\n+    \"\"\"\n+    def _get_url_for_timerange(self, timerange, **kwargs):\n+        \"\"\"\n+        returns list of urls corresponding to given TimeRange.\n+        \"\"\"\n+        table_physobs = ['EQUIVALENT_WIDTH', 'LOS_MAGNETIC_FIELD', 'VECTOR_MAGNETIC_FIELD']\n+        table_wave = {6302:'v72', 8542:'v82', 10830:'v22'}\n+\n+        physobs_in = ('physobs' in kwargs.keys() and kwargs['physobs'] in table_physobs)\n+##        url_pattern = 'http://gong2.nso.edu/pubkeep/{dtype}/%Y%m/k4{dtype}%y%m%d/k4{dtype}%y%m%dt%H%M%S{suffix}'\n+\n+        wave_float = kwargs['wavelength'].min.value\n+\n+        #The isclose function in numpy can only check two arrays if they\n+        #are close to each other within some precision. Standalone values such\n+        #as int, doubles etc can't be checked that way. In order to do that, we put the\n+        #two indiviual values in two seperate arrays da and db and then apply\n+        #isclose on both those arrays.\n+        da = list()\n+        da.append(wave_float)\n+        for wave_nums in table_wave.keys():\n+            db = list()\n+            db.append(wave_nums)\n+            if np.isclose(da, db, 1e-10, 1e-10):\n+                wave = wave_nums\n+                break\n+\n+        if wave is None:\n+            raise ValueError(\"Enter correct wavelength values and units\")\n+\n+        def download_from_nso(dtype, suffix, timerange):\n+            tmp_pattern = 'k4{dtype}%y%m%dt%H%M%S{suffix}'\n+            result = list()\n+            base_url = 'http://gong2.nso.edu/pubkeep/{dtype}/{date:%Y%m}/k4{dtype}{date:%y%m%d}/'\n+            total_days = (timerange.end - timerange.start).days + 1\n+            all_dates = timerange.split(total_days)\n+            for day in all_dates:\n+                try:\n+                    html = urllib2.urlopen(base_url.format(dtype=dtype, date=day.end))\n+                    soup = BeautifulSoup(html)\n+                    for link in soup.findAll(\"a\"):\n+                        crawler = Scraper(tmp_pattern, dtype=dtype, suffix=suffix)\n+                        simple_pattern = '%y%m%d_%H%M%S'\n+                        url = str(link.get('href'))\n+                        if crawler._URL_followsPattern(url):\n+                            tmp = re.sub('k4'+dtype, '', url)","path":"sunpy/net/dataretriever/sources/vsm.py","position":null,"original_position":102,"commit_id":"603d12461efccb91aeb0f4bae7a23296034f928e","original_commit_id":"a8840e24d39c5f8af9654d9f26b08db292dde633","user":{"login":"dpshelio","id":963242,"avatar_url":"https://avatars.githubusercontent.com/u/963242?v=3","gravatar_id":"","url":"https://api.github.com/users/dpshelio","html_url":"https://github.com/dpshelio","followers_url":"https://api.github.com/users/dpshelio/followers","following_url":"https://api.github.com/users/dpshelio/following{/other_user}","gists_url":"https://api.github.com/users/dpshelio/gists{/gist_id}","starred_url":"https://api.github.com/users/dpshelio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpshelio/subscriptions","organizations_url":"https://api.github.com/users/dpshelio/orgs","repos_url":"https://api.github.com/users/dpshelio/repos","events_url":"https://api.github.com/users/dpshelio/events{/privacy}","received_events_url":"https://api.github.com/users/dpshelio/received_events","type":"User","site_admin":false},"body":"Then I tell you so :)","created_at":"2016-07-10T17:53:35Z","updated_at":"2016-07-10T17:53:35Z","html_url":"https://github.com/sunpy/sunpy/pull/1831#discussion_r70185856","pull_request_url":"https://api.github.com/repos/sunpy/sunpy/pulls/1831","_links":{"self":{"href":"https://api.github.com/repos/sunpy/sunpy/pulls/comments/70185856"},"html":{"href":"https://github.com/sunpy/sunpy/pull/1831#discussion_r70185856"},"pull_request":{"href":"https://api.github.com/repos/sunpy/sunpy/pulls/1831"}}},"pull_request":{"url":"https://api.github.com/repos/sunpy/sunpy/pulls/1831","id":73776856,"html_url":"https://github.com/sunpy/sunpy/pull/1831","diff_url":"https://github.com/sunpy/sunpy/pull/1831.diff","patch_url":"https://github.com/sunpy/sunpy/pull/1831.patch","issue_url":"https://api.github.com/repos/sunpy/sunpy/issues/1831","number":1831,"state":"open","locked":false,"title":"[unidown]SOLIS VSM Client implemented. Test and docs included.","user":{"login":"sudk1896","id":6025419,"avatar_url":"https://avatars.githubusercontent.com/u/6025419?v=3","gravatar_id":"","url":"https://api.github.com/users/sudk1896","html_url":"https://github.com/sudk1896","followers_url":"https://api.github.com/users/sudk1896/followers","following_url":"https://api.github.com/users/sudk1896/following{/other_user}","gists_url":"https://api.github.com/users/sudk1896/gists{/gist_id}","starred_url":"https://api.github.com/users/sudk1896/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sudk1896/subscriptions","organizations_url":"https://api.github.com/users/sudk1896/orgs","repos_url":"https://api.github.com/users/sudk1896/repos","events_url":"https://api.github.com/users/sudk1896/events{/privacy}","received_events_url":"https://api.github.com/users/sudk1896/received_events","type":"User","site_admin":false},"body":"This implements SOLIS VSM Client. It supports query by ```Wavelength``` and includes an optional argument for ```Physobs```. The implementation is different from how we would normally implement via ```Scarper``` in ```sunpy.util```. But it still uses the scraper implementation.\r\n\r\nThe user needs to provide a wavelength object (defined in ```vso.attrs```) with arguments as ```6302, 8542 or 10830 ``` in Angstrom units or the equivalent values in different units.\r\n\r\n```Physobs``` takes three values ```LOS_MAGNETIC_FIELD, VECTOR_MAGNETIC_FIELD and INTENSITY```. \r\n\r\n## Usage\r\nTo download fits files for 6302 Angstroms for both physical observation.\r\n```\r\nqr = Fido.search(a.Time, a.Instrument('vsm'), a.Wavelength(630.2*u.nm) )\r\n```\r\nTo download data for 8542 or 10830 Angstroms, simply\r\n\r\n```\r\nqr = Fido.search(a.Time, a.Instrument('vsm'), a.Wavelength(8542*u.AA) )\r\n\r\nor\r\n\r\nqr = qr = Fido.search(a.Time, a.Instrument('vsm'), a.Wavelength(10830*u.AA) )\r\n```\r\n\r\nTo download data for ```Physobs``` , ```VECTOR_MAGNETIC_FIELD```.\r\n\r\n```\r\nqr = Fido.search(a.Time, a.Instrument('vsm'), a.Wavelength(6302*u.AA), \r\n                            a.Physobs('VECTOR_MAGNETIC_FIELD') )\r\n```\r\n\r\n```Physobs``` are all Case-sensitive due to VSO naming conventions.\r\n\r\n","created_at":"2016-06-14T17:02:15Z","updated_at":"2016-07-10T17:53:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d212985ec80f33c0fe27417b9d7a5cb3166923ac","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/sunpy/sunpy/pulls/1831/commits","review_comments_url":"https://api.github.com/repos/sunpy/sunpy/pulls/1831/comments","review_comment_url":"https://api.github.com/repos/sunpy/sunpy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sunpy/sunpy/issues/1831/comments","statuses_url":"https://api.github.com/repos/sunpy/sunpy/statuses/603d12461efccb91aeb0f4bae7a23296034f928e","head":{"label":"sudk1896:vsm","ref":"vsm","sha":"603d12461efccb91aeb0f4bae7a23296034f928e","user":{"login":"sudk1896","id":6025419,"avatar_url":"https://avatars.githubusercontent.com/u/6025419?v=3","gravatar_id":"","url":"https://api.github.com/users/sudk1896","html_url":"https://github.com/sudk1896","followers_url":"https://api.github.com/users/sudk1896/followers","following_url":"https://api.github.com/users/sudk1896/following{/other_user}","gists_url":"https://api.github.com/users/sudk1896/gists{/gist_id}","starred_url":"https://api.github.com/users/sudk1896/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sudk1896/subscriptions","organizations_url":"https://api.github.com/users/sudk1896/orgs","repos_url":"https://api.github.com/users/sudk1896/repos","events_url":"https://api.github.com/users/sudk1896/events{/privacy}","received_events_url":"https://api.github.com/users/sudk1896/received_events","type":"User","site_admin":false},"repo":{"id":44807807,"name":"sunpy","full_name":"sudk1896/sunpy","owner":{"login":"sudk1896","id":6025419,"avatar_url":"https://avatars.githubusercontent.com/u/6025419?v=3","gravatar_id":"","url":"https://api.github.com/users/sudk1896","html_url":"https://github.com/sudk1896","followers_url":"https://api.github.com/users/sudk1896/followers","following_url":"https://api.github.com/users/sudk1896/following{/other_user}","gists_url":"https://api.github.com/users/sudk1896/gists{/gist_id}","starred_url":"https://api.github.com/users/sudk1896/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sudk1896/subscriptions","organizations_url":"https://api.github.com/users/sudk1896/orgs","repos_url":"https://api.github.com/users/sudk1896/repos","events_url":"https://api.github.com/users/sudk1896/events{/privacy}","received_events_url":"https://api.github.com/users/sudk1896/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sudk1896/sunpy","description":"SunPy - Python for solar physics","fork":true,"url":"https://api.github.com/repos/sudk1896/sunpy","forks_url":"https://api.github.com/repos/sudk1896/sunpy/forks","keys_url":"https://api.github.com/repos/sudk1896/sunpy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sudk1896/sunpy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sudk1896/sunpy/teams","hooks_url":"https://api.github.com/repos/sudk1896/sunpy/hooks","issue_events_url":"https://api.github.com/repos/sudk1896/sunpy/issues/events{/number}","events_url":"https://api.github.com/repos/sudk1896/sunpy/events","assignees_url":"https://api.github.com/repos/sudk1896/sunpy/assignees{/user}","branches_url":"https://api.github.com/repos/sudk1896/sunpy/branches{/branch}","tags_url":"https://api.github.com/repos/sudk1896/sunpy/tags","blobs_url":"https://api.github.com/repos/sudk1896/sunpy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sudk1896/sunpy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sudk1896/sunpy/git/refs{/sha}","trees_url":"https://api.github.com/repos/sudk1896/sunpy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sudk1896/sunpy/statuses/{sha}","languages_url":"https://api.github.com/repos/sudk1896/sunpy/languages","stargazers_url":"https://api.github.com/repos/sudk1896/sunpy/stargazers","contributors_url":"https://api.github.com/repos/sudk1896/sunpy/contributors","subscribers_url":"https://api.github.com/repos/sudk1896/sunpy/subscribers","subscription_url":"https://api.github.com/repos/sudk1896/sunpy/subscription","commits_url":"https://api.github.com/repos/sudk1896/sunpy/commits{/sha}","git_commits_url":"https://api.github.com/repos/sudk1896/sunpy/git/commits{/sha}","comments_url":"https://api.github.com/repos/sudk1896/sunpy/comments{/number}","issue_comment_url":"https://api.github.com/repos/sudk1896/sunpy/issues/comments{/number}","contents_url":"https://api.github.com/repos/sudk1896/sunpy/contents/{+path}","compare_url":"https://api.github.com/repos/sudk1896/sunpy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sudk1896/sunpy/merges","archive_url":"https://api.github.com/repos/sudk1896/sunpy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sudk1896/sunpy/downloads","issues_url":"https://api.github.com/repos/sudk1896/sunpy/issues{/number}","pulls_url":"https://api.github.com/repos/sudk1896/sunpy/pulls{/number}","milestones_url":"https://api.github.com/repos/sudk1896/sunpy/milestones{/number}","notifications_url":"https://api.github.com/repos/sudk1896/sunpy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sudk1896/sunpy/labels{/name}","releases_url":"https://api.github.com/repos/sudk1896/sunpy/releases{/id}","deployments_url":"https://api.github.com/repos/sudk1896/sunpy/deployments","created_at":"2015-10-23T11:00:28Z","updated_at":"2016-03-02T14:59:27Z","pushed_at":"2016-07-10T11:04:01Z","git_url":"git://github.com/sudk1896/sunpy.git","ssh_url":"git@github.com:sudk1896/sunpy.git","clone_url":"https://github.com/sudk1896/sunpy.git","svn_url":"https://github.com/sudk1896/sunpy","homepage":"http://www.sunpy.org","size":38517,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"sunpy:unidown","ref":"unidown","sha":"2c57069fe4f4450607063ec4e85255d20adde3ea","user":{"login":"sunpy","id":963197,"avatar_url":"https://avatars.githubusercontent.com/u/963197?v=3","gravatar_id":"","url":"https://api.github.com/users/sunpy","html_url":"https://github.com/sunpy","followers_url":"https://api.github.com/users/sunpy/followers","following_url":"https://api.github.com/users/sunpy/following{/other_user}","gists_url":"https://api.github.com/users/sunpy/gists{/gist_id}","starred_url":"https://api.github.com/users/sunpy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sunpy/subscriptions","organizations_url":"https://api.github.com/users/sunpy/orgs","repos_url":"https://api.github.com/users/sunpy/repos","events_url":"https://api.github.com/users/sunpy/events{/privacy}","received_events_url":"https://api.github.com/users/sunpy/received_events","type":"Organization","site_admin":false},"repo":{"id":2165383,"name":"sunpy","full_name":"sunpy/sunpy","owner":{"login":"sunpy","id":963197,"avatar_url":"https://avatars.githubusercontent.com/u/963197?v=3","gravatar_id":"","url":"https://api.github.com/users/sunpy","html_url":"https://github.com/sunpy","followers_url":"https://api.github.com/users/sunpy/followers","following_url":"https://api.github.com/users/sunpy/following{/other_user}","gists_url":"https://api.github.com/users/sunpy/gists{/gist_id}","starred_url":"https://api.github.com/users/sunpy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sunpy/subscriptions","organizations_url":"https://api.github.com/users/sunpy/orgs","repos_url":"https://api.github.com/users/sunpy/repos","events_url":"https://api.github.com/users/sunpy/events{/privacy}","received_events_url":"https://api.github.com/users/sunpy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sunpy/sunpy","description":"SunPy - Python for Solar Physics","fork":false,"url":"https://api.github.com/repos/sunpy/sunpy","forks_url":"https://api.github.com/repos/sunpy/sunpy/forks","keys_url":"https://api.github.com/repos/sunpy/sunpy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sunpy/sunpy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sunpy/sunpy/teams","hooks_url":"https://api.github.com/repos/sunpy/sunpy/hooks","issue_events_url":"https://api.github.com/repos/sunpy/sunpy/issues/events{/number}","events_url":"https://api.github.com/repos/sunpy/sunpy/events","assignees_url":"https://api.github.com/repos/sunpy/sunpy/assignees{/user}","branches_url":"https://api.github.com/repos/sunpy/sunpy/branches{/branch}","tags_url":"https://api.github.com/repos/sunpy/sunpy/tags","blobs_url":"https://api.github.com/repos/sunpy/sunpy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sunpy/sunpy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sunpy/sunpy/git/refs{/sha}","trees_url":"https://api.github.com/repos/sunpy/sunpy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sunpy/sunpy/statuses/{sha}","languages_url":"https://api.github.com/repos/sunpy/sunpy/languages","stargazers_url":"https://api.github.com/repos/sunpy/sunpy/stargazers","contributors_url":"https://api.github.com/repos/sunpy/sunpy/contributors","subscribers_url":"https://api.github.com/repos/sunpy/sunpy/subscribers","subscription_url":"https://api.github.com/repos/sunpy/sunpy/subscription","commits_url":"https://api.github.com/repos/sunpy/sunpy/commits{/sha}","git_commits_url":"https://api.github.com/repos/sunpy/sunpy/git/commits{/sha}","comments_url":"https://api.github.com/repos/sunpy/sunpy/comments{/number}","issue_comment_url":"https://api.github.com/repos/sunpy/sunpy/issues/comments{/number}","contents_url":"https://api.github.com/repos/sunpy/sunpy/contents/{+path}","compare_url":"https://api.github.com/repos/sunpy/sunpy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sunpy/sunpy/merges","archive_url":"https://api.github.com/repos/sunpy/sunpy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sunpy/sunpy/downloads","issues_url":"https://api.github.com/repos/sunpy/sunpy/issues{/number}","pulls_url":"https://api.github.com/repos/sunpy/sunpy/pulls{/number}","milestones_url":"https://api.github.com/repos/sunpy/sunpy/milestones{/number}","notifications_url":"https://api.github.com/repos/sunpy/sunpy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sunpy/sunpy/labels{/name}","releases_url":"https://api.github.com/repos/sunpy/sunpy/releases{/id}","deployments_url":"https://api.github.com/repos/sunpy/sunpy/deployments","created_at":"2011-08-06T15:34:08Z","updated_at":"2016-07-05T03:46:00Z","pushed_at":"2016-07-10T11:04:01Z","git_url":"git://github.com/sunpy/sunpy.git","ssh_url":"git@github.com:sunpy/sunpy.git","clone_url":"https://github.com/sunpy/sunpy.git","svn_url":"https://github.com/sunpy/sunpy","homepage":"http://www.sunpy.org","size":142395,"stargazers_count":229,"watchers_count":229,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":160,"mirror_url":null,"open_issues_count":261,"forks":160,"open_issues":261,"watchers":229,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sunpy/sunpy/pulls/1831"},"html":{"href":"https://github.com/sunpy/sunpy/pull/1831"},"issue":{"href":"https://api.github.com/repos/sunpy/sunpy/issues/1831"},"comments":{"href":"https://api.github.com/repos/sunpy/sunpy/issues/1831/comments"},"review_comments":{"href":"https://api.github.com/repos/sunpy/sunpy/pulls/1831/comments"},"review_comment":{"href":"https://api.github.com/repos/sunpy/sunpy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sunpy/sunpy/pulls/1831/commits"},"statuses":{"href":"https://api.github.com/repos/sunpy/sunpy/statuses/603d12461efccb91aeb0f4bae7a23296034f928e"}}}}
{"actor":{"display_login":"dpshelio"}}