{"action":"created","issue":{"url":"https://api.github.com/repos/pvlib/pvlib-python/issues/115","repository_url":"https://api.github.com/repos/pvlib/pvlib-python","labels_url":"https://api.github.com/repos/pvlib/pvlib-python/issues/115/labels{/name}","comments_url":"https://api.github.com/repos/pvlib/pvlib-python/issues/115/comments","events_url":"https://api.github.com/repos/pvlib/pvlib-python/issues/115/events","html_url":"https://github.com/pvlib/pvlib-python/pull/115","id":128043479,"number":115,"title":"Add pw and spectral correction code from pvlib matlab 1.3","user":{"login":"wholmgren","id":4383303,"avatar_url":"https://avatars.githubusercontent.com/u/4383303?v=3","gravatar_id":"","url":"https://api.github.com/users/wholmgren","html_url":"https://github.com/wholmgren","followers_url":"https://api.github.com/users/wholmgren/followers","following_url":"https://api.github.com/users/wholmgren/following{/other_user}","gists_url":"https://api.github.com/users/wholmgren/gists{/gist_id}","starred_url":"https://api.github.com/users/wholmgren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wholmgren/subscriptions","organizations_url":"https://api.github.com/users/wholmgren/orgs","repos_url":"https://api.github.com/users/wholmgren/repos","events_url":"https://api.github.com/users/wholmgren/events{/privacy}","received_events_url":"https://api.github.com/users/wholmgren/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pvlib/pvlib-python/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/pvlib/pvlib-python/milestones/8","html_url":"https://github.com/pvlib/pvlib-python/milestones/0.4.0","labels_url":"https://api.github.com/repos/pvlib/pvlib-python/milestones/8/labels","id":1641412,"number":8,"title":"0.4.0","description":"","creator":{"login":"wholmgren","id":4383303,"avatar_url":"https://avatars.githubusercontent.com/u/4383303?v=3","gravatar_id":"","url":"https://api.github.com/users/wholmgren","html_url":"https://github.com/wholmgren","followers_url":"https://api.github.com/users/wholmgren/followers","following_url":"https://api.github.com/users/wholmgren/following{/other_user}","gists_url":"https://api.github.com/users/wholmgren/gists{/gist_id}","starred_url":"https://api.github.com/users/wholmgren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wholmgren/subscriptions","organizations_url":"https://api.github.com/users/wholmgren/orgs","repos_url":"https://api.github.com/users/wholmgren/repos","events_url":"https://api.github.com/users/wholmgren/events{/privacy}","received_events_url":"https://api.github.com/users/wholmgren/received_events","type":"User","site_admin":false},"open_issues":11,"closed_issues":3,"state":"open","created_at":"2016-03-13T20:05:51Z","updated_at":"2016-05-22T21:50:15Z","due_on":"2016-06-30T07:00:00Z","closed_at":null},"comments":7,"created_at":"2016-01-21T23:12:02Z","updated_at":"2016-06-10T22:46:17Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/pvlib/pvlib-python/pulls/115","html_url":"https://github.com/pvlib/pvlib-python/pull/115","diff_url":"https://github.com/pvlib/pvlib-python/pull/115.diff","patch_url":"https://github.com/pvlib/pvlib-python/pull/115.patch"},"body":"This PR is a very quick port of the PVLIB Matlab 1.3 functions ``pvl_calcPwat`` and ``pvl_FSspeccorr``. I'm implementing these quickly to add a little more substance to a pvsc abstract.\r\n\r\nProblems:\r\n\r\n1. The PW function will not return values less than 0.1 cm. What!?\r\n2. The spectral correction function diverges as PW goes to 0. What!?\r\n2. No unit tests yet.\r\n2. Haven't checked that the doc strings compile correctly.\r\n2. The new function and variable names are up for debate. I used ``pw``, but ``precipitable_water`` is probably better aligned with our style.\r\n\r\ncc @cwhanse @jforbess. ref #2.\r\n\r\n```python\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nfrom pvlib.atmosphere import calc_pw, first_solar_spectral_correction\r\n\r\nairmasss = np.linspace(1.2, 5)\r\nrhs = np.linspace(20, 100, 5)\r\npws = calc_pw(25, rhs)\r\nfor pw in pws:\r\n    cdte = first_solar_spectral_correction(pw, airmasss, 'CdTe')\r\n    xsi = first_solar_spectral_correction(pw, airmasss, 'xSi')\r\n    plt.plot(airmasss, cdte, 'r-')\r\n    plt.plot(airmasss, xsi, 'b-')\r\n\r\nplt.xlabel('Air mass')\r\nplt.ylabel('Spectral mismatch modifier')\r\nplt.title('Effect of Relative Humidity on Spectral Mismatch')\r\nplt.legend(['x-Si', 'CdTe'], loc='lower center')\r\nplt.text(4, .995, 'RH = 100%', color='r')\r\nplt.text(3.6, .92, 'RH = 20%', color='r')\r\nplt.text(2.5, 1.046, 'RH = 100%', color='b')\r\nplt.text(3.5, 1.024, 'RH = 20%', color='b')\r\n```\r\n![effect of spectral mismatch](https://cloud.githubusercontent.com/assets/4383303/12497361/8cdc885e-c058-11e5-8619-a5557a336ce5.png)"},"comment":{"url":"https://api.github.com/repos/pvlib/pvlib-python/issues/comments/225313665","html_url":"https://github.com/pvlib/pvlib-python/pull/115#issuecomment-225313665","issue_url":"https://api.github.com/repos/pvlib/pvlib-python/issues/115","id":225313665,"user":{"login":"wholmgren","id":4383303,"avatar_url":"https://avatars.githubusercontent.com/u/4383303?v=3","gravatar_id":"","url":"https://api.github.com/users/wholmgren","html_url":"https://github.com/wholmgren","followers_url":"https://api.github.com/users/wholmgren/followers","following_url":"https://api.github.com/users/wholmgren/following{/other_user}","gists_url":"https://api.github.com/users/wholmgren/gists{/gist_id}","starred_url":"https://api.github.com/users/wholmgren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wholmgren/subscriptions","organizations_url":"https://api.github.com/users/wholmgren/orgs","repos_url":"https://api.github.com/users/wholmgren/repos","events_url":"https://api.github.com/users/wholmgren/events{/privacy}","received_events_url":"https://api.github.com/users/wholmgren/received_events","type":"User","site_admin":false},"created_at":"2016-06-10T22:46:17Z","updated_at":"2016-06-10T22:46:17Z","body":"Hi Mitch, thanks for commenting. Just so there's no confusion... did you click on the [Files changed](https://github.com/pvlib/pvlib-python/pull/115/files) tab to see my implementation of the algorithm? I have no problem discarding my python code in favor of yours. Another option is that you can start with my code, make changes, and then make a new pull request. It sounded like you have a git expert on your team so I’ll leave it at that for now.\r\n\r\nHere's the code that made those plots...\r\n\r\n```python\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nfrom pvlib.atmosphere import first_solar_spectral_correction, gueymard94_pw\r\n\r\ntemp_air = np.linspace(-10, 40, 51)\r\nrelative_humidity = np.linspace(0, 100, 51)\r\n\r\ntemps_humids = np.meshgrid(temp_air, relative_humidity)\r\n\r\npws = gueymard94_pw(temps_humids[0], temps_humids[1])\r\n\r\nfig, ax = plt.subplots(figsize=(12,9), subplot_kw=dict(aspect=0.5))\r\nim = ax.contourf(temps_humids[0], temps_humids[1], pws, 50, cmap=plt.get_cmap('viridis'), vmin=0, vmax=5)\r\nax.set_ylabel('relative humidity (%)')\r\nax.set_xlabel('temperature (C)')\r\nfig.colorbar(im, label='pw (cm)')\r\n\r\nfig, ax = plt.subplots(figsize=(12,9), subplot_kw=dict(aspect=0.5))\r\nim = ax.contourf(temps_humids[0], temps_humids[1], pws, 50, cmap=plt.get_cmap('viridis'))\r\nax.set_ylabel('relative humidity (%)')\r\nax.set_xlabel('temperature (C)')\r\nfig.colorbar(im, label='pw (cm)')\r\n\r\nams = np.linspace(1, 5, 51)\r\npws = np.linspace(0, 5, 51)\r\nams, pws = np.meshgrid(ams, pws)\r\n\r\ncmap = plt.get_cmap('viridis')\r\nn = 15\r\nvmin = .94\r\nvmax = 1.05\r\n\r\nfor module_type in ['cdte', 'xsi', 'polysi']:\r\n    mods = first_solar_spectral_correction(pws, ams, module_type=module_type)\r\n\r\n    fig, ax = plt.subplots(figsize=(10,7))\r\n    \r\n    im = ax.contour(ams, pws, mods, n, cmap=cmap, vmin=vmin, vmax=vmax)\r\n    im2 = ax.contourf(ams, pws, mods, n, cmap=cmap, vmin=vmin, vmax=vmax)\r\n    ax.set_ylabel('preciptable water (cm)')\r\n    ax.set_xlabel('airmass')\r\n    ax.clabel(im, colors='k', fmt='%.2f')\r\n    fig.colorbar(im2, label='modifier')\r\n    ax.set_title(module_type)\r\n```"}}
{"actor":{"display_login":"wholmgren"}}