{"action":"created","comment":{"url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/pulls/comments/108810904","pull_request_review_id":29812927,"id":108810904,"diff_hunk":"@@ -515,19 +530,105 @@ def update_start_end_year(ds, config, calendar):\n     endYear = days_to_datetime(ds.Time.max().values,  calendar=calendar).year\n     changed = False\n     if startYear != requestedStartYear or endYear != requestedEndYear:\n-        warn(\"climatology start and/or end year different from requested\\n\"\n-             \"requestd: {:04d}-{:04d}\\n\"\n-             \"actual:   {:04d}-{:04d}\\n\".format(requestedStartYear,\n-                                                requestedEndYear,\n-                                                startYear,\n-                                                endYear))\n+        warnings.warn(\"climatology start and/or end year different from requested\\n\"\n+                      \"requestd: {:04d}-{:04d}\\n\"\n+                      \"actual:   {:04d}-{:04d}\\n\".format(requestedStartYear, requestedEndYear, startYear, endYear))\n         config.set('climatology', 'startYear', str(startYear))\n         config.set('climatology', 'endYear', str(endYear))\n         changed = True\n \n     return changed, startYear, endYear\n \n \n+def add_months_and_days_in_month(ds, calendar):\n+    '''\n+    Add ``months`` and ``daysInMonth`` as data arrays in ``ds``.  The number\n+    of days in each month of ``ds`` is computed either using the ``startTime``\n+    and ``endTime`` if available or assuming ``gregorian_noleap`` calendar and\n+    ignoring leap years.\n+\n+    Parameters\n+    ----------\n+    ds : ``xarray.Dataset`` object\n+        A data set with a ``Time`` coordinate expressed as days since\n+        0001-01-01\n+\n+    calendar: ``{'gregorian', 'gregorian_noleap'}``\n+        The name of one of the calendars supported by MPAS cores, used to\n+        determine ``month`` from ``Time`` coordinate\n+\n+    Returns\n+    -------\n+    ds : ``xarray.Dataset`` object\n+        The data set with ``month`` and ``daysInMonth`` data arrays added (if\n+        not already present)\n+\n+    Authors\n+    -------\n+    Xylar Asay-Davis\n+\n+    Last Modified\n+    -------------\n+    03/29/2017\n+    \"\"\"    '''\n+\n+    ds = ds.copy()\n+\n+    if 'month' not in ds.data_vars and 'month' not in ds.coords:\n+        if calendar is None:\n+            raise ValueError('calendar must be provided if month coordinate is not in ds')\n+        months = [date.month for date in days_to_datetime(ds.Time,\n+                                                          calendar=calendar)]\n+\n+        ds['month'] = ('Time', months)\n+\n+    if 'daysInMonth' not in ds.data_vars:\n+        if 'startTime' in ds.data_vars and 'endTime' in ds.data_vars:\n+            ds['daysInMonth'] = ds.endTime - ds.startTime\n+        else:\n+            # TODO: support calendar","path":"mpas_analysis/shared/climatology/climatology.py","position":241,"original_position":241,"commit_id":"fefb7aab25185983cc446b3e1faa29dc8ee06e80","original_commit_id":"fefb7aab25185983cc446b3e1faa29dc8ee06e80","user":{"login":"pwolfram","id":4295853,"avatar_url":"https://avatars0.githubusercontent.com/u/4295853?v=3","gravatar_id":"","url":"https://api.github.com/users/pwolfram","html_url":"https://github.com/pwolfram","followers_url":"https://api.github.com/users/pwolfram/followers","following_url":"https://api.github.com/users/pwolfram/following{/other_user}","gists_url":"https://api.github.com/users/pwolfram/gists{/gist_id}","starred_url":"https://api.github.com/users/pwolfram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pwolfram/subscriptions","organizations_url":"https://api.github.com/users/pwolfram/orgs","repos_url":"https://api.github.com/users/pwolfram/repos","events_url":"https://api.github.com/users/pwolfram/events{/privacy}","received_events_url":"https://api.github.com/users/pwolfram/received_events","type":"User","site_admin":false},"body":"What does this comment mean exactly?","created_at":"2017-03-29T23:23:54Z","updated_at":"2017-03-29T23:27:17Z","html_url":"https://github.com/MPAS-Dev/MPAS-Analysis/pull/165#discussion_r108810904","pull_request_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/pulls/165","_links":{"self":{"href":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/pulls/comments/108810904"},"html":{"href":"https://github.com/MPAS-Dev/MPAS-Analysis/pull/165#discussion_r108810904"},"pull_request":{"href":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/pulls/165"}}},"pull_request":{"url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/pulls/165","id":113269449,"html_url":"https://github.com/MPAS-Dev/MPAS-Analysis/pull/165","diff_url":"https://github.com/MPAS-Dev/MPAS-Analysis/pull/165.diff","patch_url":"https://github.com/MPAS-Dev/MPAS-Analysis/pull/165.patch","issue_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/issues/165","number":165,"state":"open","locked":false,"title":"Change climatologies to use xtime_start and xtime_end","user":{"login":"xylar","id":4179064,"avatar_url":"https://avatars3.githubusercontent.com/u/4179064?v=3","gravatar_id":"","url":"https://api.github.com/users/xylar","html_url":"https://github.com/xylar","followers_url":"https://api.github.com/users/xylar/followers","following_url":"https://api.github.com/users/xylar/following{/other_user}","gists_url":"https://api.github.com/users/xylar/gists{/gist_id}","starred_url":"https://api.github.com/users/xylar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xylar/subscriptions","organizations_url":"https://api.github.com/users/xylar/orgs","repos_url":"https://api.github.com/users/xylar/repos","events_url":"https://api.github.com/users/xylar/events{/privacy}","received_events_url":"https://api.github.com/users/xylar/received_events","type":"User","site_admin":false},"body":"Climatologies were being weighted by the number of days in a month without regard to which calendar.  With this merge, they are being weighted by the actual number of days associated with each time entry, as determined from `xtime_start` and `xtime_end` (or equivalent for monthly averages).\r\n\r\nThe MOC climatology was previously being computed with a straight-up time average (`.mean('Time')`), which was a change I had made to try to speed up the code.  In this merge, it is now being computed as a weighted average based on the number of days associated with each time index.\r\n\r\nThe seasonal climatologies in several analysis tasks were being computed inefficiently and slightly inaccurately for the `gregorian` calendar by first  computing a monthly climatology and then averaging again to get a seasonal or annual climatology.\r\n\r\nTo support these changes:\r\n  * `mpas_xarray` has been modified to store the `startTime` and `endTime` (if available) of each time index in addition to `Time`.  This is only possible if the time coordinate is defined based on the average of a start time and and end time (e.g xtime_start and xtime_end).\r\n* The `indexNino34` task has been updated to work with an `xarray.Dataset` instead of an `xarray.DataArray` because `climatology` calculations now only work with the former.","created_at":"2017-03-29T18:56:07Z","updated_at":"2017-03-29T23:27:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7581c46b882cfa8cb9bb163fa66b0f6ad431df67","assignee":{"login":"pwolfram","id":4295853,"avatar_url":"https://avatars0.githubusercontent.com/u/4295853?v=3","gravatar_id":"","url":"https://api.github.com/users/pwolfram","html_url":"https://github.com/pwolfram","followers_url":"https://api.github.com/users/pwolfram/followers","following_url":"https://api.github.com/users/pwolfram/following{/other_user}","gists_url":"https://api.github.com/users/pwolfram/gists{/gist_id}","starred_url":"https://api.github.com/users/pwolfram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pwolfram/subscriptions","organizations_url":"https://api.github.com/users/pwolfram/orgs","repos_url":"https://api.github.com/users/pwolfram/repos","events_url":"https://api.github.com/users/pwolfram/events{/privacy}","received_events_url":"https://api.github.com/users/pwolfram/received_events","type":"User","site_admin":false},"assignees":[{"login":"pwolfram","id":4295853,"avatar_url":"https://avatars0.githubusercontent.com/u/4295853?v=3","gravatar_id":"","url":"https://api.github.com/users/pwolfram","html_url":"https://github.com/pwolfram","followers_url":"https://api.github.com/users/pwolfram/followers","following_url":"https://api.github.com/users/pwolfram/following{/other_user}","gists_url":"https://api.github.com/users/pwolfram/gists{/gist_id}","starred_url":"https://api.github.com/users/pwolfram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pwolfram/subscriptions","organizations_url":"https://api.github.com/users/pwolfram/orgs","repos_url":"https://api.github.com/users/pwolfram/repos","events_url":"https://api.github.com/users/pwolfram/events{/privacy}","received_events_url":"https://api.github.com/users/pwolfram/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/pulls/165/commits","review_comments_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/pulls/165/comments","review_comment_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/pulls/comments{/number}","comments_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/issues/165/comments","statuses_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/statuses/fefb7aab25185983cc446b3e1faa29dc8ee06e80","head":{"label":"xylar:fix_climatology_dates","ref":"fix_climatology_dates","sha":"fefb7aab25185983cc446b3e1faa29dc8ee06e80","user":{"login":"xylar","id":4179064,"avatar_url":"https://avatars3.githubusercontent.com/u/4179064?v=3","gravatar_id":"","url":"https://api.github.com/users/xylar","html_url":"https://github.com/xylar","followers_url":"https://api.github.com/users/xylar/followers","following_url":"https://api.github.com/users/xylar/following{/other_user}","gists_url":"https://api.github.com/users/xylar/gists{/gist_id}","starred_url":"https://api.github.com/users/xylar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xylar/subscriptions","organizations_url":"https://api.github.com/users/xylar/orgs","repos_url":"https://api.github.com/users/xylar/repos","events_url":"https://api.github.com/users/xylar/events{/privacy}","received_events_url":"https://api.github.com/users/xylar/received_events","type":"User","site_admin":false},"repo":{"id":68328847,"name":"MPAS-Analysis","full_name":"xylar/MPAS-Analysis","owner":{"login":"xylar","id":4179064,"avatar_url":"https://avatars3.githubusercontent.com/u/4179064?v=3","gravatar_id":"","url":"https://api.github.com/users/xylar","html_url":"https://github.com/xylar","followers_url":"https://api.github.com/users/xylar/followers","following_url":"https://api.github.com/users/xylar/following{/other_user}","gists_url":"https://api.github.com/users/xylar/gists{/gist_id}","starred_url":"https://api.github.com/users/xylar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xylar/subscriptions","organizations_url":"https://api.github.com/users/xylar/orgs","repos_url":"https://api.github.com/users/xylar/repos","events_url":"https://api.github.com/users/xylar/events{/privacy}","received_events_url":"https://api.github.com/users/xylar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/xylar/MPAS-Analysis","description":"Provides analysis for the MPAS components of ACME","fork":true,"url":"https://api.github.com/repos/xylar/MPAS-Analysis","forks_url":"https://api.github.com/repos/xylar/MPAS-Analysis/forks","keys_url":"https://api.github.com/repos/xylar/MPAS-Analysis/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xylar/MPAS-Analysis/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xylar/MPAS-Analysis/teams","hooks_url":"https://api.github.com/repos/xylar/MPAS-Analysis/hooks","issue_events_url":"https://api.github.com/repos/xylar/MPAS-Analysis/issues/events{/number}","events_url":"https://api.github.com/repos/xylar/MPAS-Analysis/events","assignees_url":"https://api.github.com/repos/xylar/MPAS-Analysis/assignees{/user}","branches_url":"https://api.github.com/repos/xylar/MPAS-Analysis/branches{/branch}","tags_url":"https://api.github.com/repos/xylar/MPAS-Analysis/tags","blobs_url":"https://api.github.com/repos/xylar/MPAS-Analysis/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xylar/MPAS-Analysis/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xylar/MPAS-Analysis/git/refs{/sha}","trees_url":"https://api.github.com/repos/xylar/MPAS-Analysis/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xylar/MPAS-Analysis/statuses/{sha}","languages_url":"https://api.github.com/repos/xylar/MPAS-Analysis/languages","stargazers_url":"https://api.github.com/repos/xylar/MPAS-Analysis/stargazers","contributors_url":"https://api.github.com/repos/xylar/MPAS-Analysis/contributors","subscribers_url":"https://api.github.com/repos/xylar/MPAS-Analysis/subscribers","subscription_url":"https://api.github.com/repos/xylar/MPAS-Analysis/subscription","commits_url":"https://api.github.com/repos/xylar/MPAS-Analysis/commits{/sha}","git_commits_url":"https://api.github.com/repos/xylar/MPAS-Analysis/git/commits{/sha}","comments_url":"https://api.github.com/repos/xylar/MPAS-Analysis/comments{/number}","issue_comment_url":"https://api.github.com/repos/xylar/MPAS-Analysis/issues/comments{/number}","contents_url":"https://api.github.com/repos/xylar/MPAS-Analysis/contents/{+path}","compare_url":"https://api.github.com/repos/xylar/MPAS-Analysis/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xylar/MPAS-Analysis/merges","archive_url":"https://api.github.com/repos/xylar/MPAS-Analysis/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xylar/MPAS-Analysis/downloads","issues_url":"https://api.github.com/repos/xylar/MPAS-Analysis/issues{/number}","pulls_url":"https://api.github.com/repos/xylar/MPAS-Analysis/pulls{/number}","milestones_url":"https://api.github.com/repos/xylar/MPAS-Analysis/milestones{/number}","notifications_url":"https://api.github.com/repos/xylar/MPAS-Analysis/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xylar/MPAS-Analysis/labels{/name}","releases_url":"https://api.github.com/repos/xylar/MPAS-Analysis/releases{/id}","deployments_url":"https://api.github.com/repos/xylar/MPAS-Analysis/deployments","created_at":"2016-09-15T20:28:35Z","updated_at":"2017-03-27T07:27:10Z","pushed_at":"2017-03-29T18:34:22Z","git_url":"git://github.com/xylar/MPAS-Analysis.git","ssh_url":"git@github.com:xylar/MPAS-Analysis.git","clone_url":"https://github.com/xylar/MPAS-Analysis.git","svn_url":"https://github.com/xylar/MPAS-Analysis","homepage":null,"size":1656,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"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":"MPAS-Dev:develop","ref":"develop","sha":"64abea53dd084c988cc162e438e09cb33986b7f8","user":{"login":"MPAS-Dev","id":4063217,"avatar_url":"https://avatars3.githubusercontent.com/u/4063217?v=3","gravatar_id":"","url":"https://api.github.com/users/MPAS-Dev","html_url":"https://github.com/MPAS-Dev","followers_url":"https://api.github.com/users/MPAS-Dev/followers","following_url":"https://api.github.com/users/MPAS-Dev/following{/other_user}","gists_url":"https://api.github.com/users/MPAS-Dev/gists{/gist_id}","starred_url":"https://api.github.com/users/MPAS-Dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MPAS-Dev/subscriptions","organizations_url":"https://api.github.com/users/MPAS-Dev/orgs","repos_url":"https://api.github.com/users/MPAS-Dev/repos","events_url":"https://api.github.com/users/MPAS-Dev/events{/privacy}","received_events_url":"https://api.github.com/users/MPAS-Dev/received_events","type":"Organization","site_admin":false},"repo":{"id":61749446,"name":"MPAS-Analysis","full_name":"MPAS-Dev/MPAS-Analysis","owner":{"login":"MPAS-Dev","id":4063217,"avatar_url":"https://avatars3.githubusercontent.com/u/4063217?v=3","gravatar_id":"","url":"https://api.github.com/users/MPAS-Dev","html_url":"https://github.com/MPAS-Dev","followers_url":"https://api.github.com/users/MPAS-Dev/followers","following_url":"https://api.github.com/users/MPAS-Dev/following{/other_user}","gists_url":"https://api.github.com/users/MPAS-Dev/gists{/gist_id}","starred_url":"https://api.github.com/users/MPAS-Dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MPAS-Dev/subscriptions","organizations_url":"https://api.github.com/users/MPAS-Dev/orgs","repos_url":"https://api.github.com/users/MPAS-Dev/repos","events_url":"https://api.github.com/users/MPAS-Dev/events{/privacy}","received_events_url":"https://api.github.com/users/MPAS-Dev/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MPAS-Dev/MPAS-Analysis","description":"Provides analysis for the MPAS components of ACME","fork":false,"url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis","forks_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/forks","keys_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/teams","hooks_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/hooks","issue_events_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/issues/events{/number}","events_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/events","assignees_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/assignees{/user}","branches_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/branches{/branch}","tags_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/tags","blobs_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/git/refs{/sha}","trees_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/statuses/{sha}","languages_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/languages","stargazers_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/stargazers","contributors_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/contributors","subscribers_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/subscribers","subscription_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/subscription","commits_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/commits{/sha}","git_commits_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/git/commits{/sha}","comments_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/comments{/number}","issue_comment_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/issues/comments{/number}","contents_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/contents/{+path}","compare_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/merges","archive_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/downloads","issues_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/issues{/number}","pulls_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/pulls{/number}","milestones_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/milestones{/number}","notifications_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/labels{/name}","releases_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/releases{/id}","deployments_url":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/deployments","created_at":"2016-06-22T20:29:57Z","updated_at":"2016-11-09T23:14:30Z","pushed_at":"2017-03-29T23:18:37Z","git_url":"git://github.com/MPAS-Dev/MPAS-Analysis.git","ssh_url":"git@github.com:MPAS-Dev/MPAS-Analysis.git","clone_url":"https://github.com/MPAS-Dev/MPAS-Analysis.git","svn_url":"https://github.com/MPAS-Dev/MPAS-Analysis","homepage":null,"size":1517,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":34,"forks":8,"open_issues":34,"watchers":2,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/pulls/165"},"html":{"href":"https://github.com/MPAS-Dev/MPAS-Analysis/pull/165"},"issue":{"href":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/issues/165"},"comments":{"href":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/issues/165/comments"},"review_comments":{"href":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/pulls/165/comments"},"review_comment":{"href":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/pulls/165/commits"},"statuses":{"href":"https://api.github.com/repos/MPAS-Dev/MPAS-Analysis/statuses/fefb7aab25185983cc446b3e1faa29dc8ee06e80"}}}}
{"actor":{"display_login":"pwolfram"}}