{"action":"created","issue":{"url":"https://api.github.com/repos/sherpa/sherpa/issues/106","repository_url":"https://api.github.com/repos/sherpa/sherpa","labels_url":"https://api.github.com/repos/sherpa/sherpa/issues/106/labels{/name}","comments_url":"https://api.github.com/repos/sherpa/sherpa/issues/106/comments","events_url":"https://api.github.com/repos/sherpa/sherpa/issues/106/events","html_url":"https://github.com/sherpa/sherpa/issues/106","id":107364458,"number":106,"title":"axis differences between plot_source() and plot('source') and issues with model plots","user":{"login":"DougBurke","id":224638,"avatar_url":"https://avatars.githubusercontent.com/u/224638?v=3","gravatar_id":"","url":"https://api.github.com/users/DougBurke","html_url":"https://github.com/DougBurke","followers_url":"https://api.github.com/users/DougBurke/followers","following_url":"https://api.github.com/users/DougBurke/following{/other_user}","gists_url":"https://api.github.com/users/DougBurke/gists{/gist_id}","starred_url":"https://api.github.com/users/DougBurke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DougBurke/subscriptions","organizations_url":"https://api.github.com/users/DougBurke/orgs","repos_url":"https://api.github.com/users/DougBurke/repos","events_url":"https://api.github.com/users/DougBurke/events{/privacy}","received_events_url":"https://api.github.com/users/DougBurke/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/sherpa/sherpa/labels/area:code","name":"area:code","color":"d4c5f9"},{"url":"https://api.github.com/repos/sherpa/sherpa/labels/priority:medium","name":"priority:medium","color":"fef2c0"},{"url":"https://api.github.com/repos/sherpa/sherpa/labels/type:bug","name":"type:bug","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/sherpa/sherpa/milestones/3","html_url":"https://github.com/sherpa/sherpa/milestones/4.8.2","labels_url":"https://api.github.com/repos/sherpa/sherpa/milestones/3/labels","id":1652200,"number":3,"title":"4.8.2","description":"","creator":{"login":"olaurino","id":5692321,"avatar_url":"https://avatars.githubusercontent.com/u/5692321?v=3","gravatar_id":"","url":"https://api.github.com/users/olaurino","html_url":"https://github.com/olaurino","followers_url":"https://api.github.com/users/olaurino/followers","following_url":"https://api.github.com/users/olaurino/following{/other_user}","gists_url":"https://api.github.com/users/olaurino/gists{/gist_id}","starred_url":"https://api.github.com/users/olaurino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olaurino/subscriptions","organizations_url":"https://api.github.com/users/olaurino/orgs","repos_url":"https://api.github.com/users/olaurino/repos","events_url":"https://api.github.com/users/olaurino/events{/privacy}","received_events_url":"https://api.github.com/users/olaurino/received_events","type":"User","site_admin":false},"open_issues":18,"closed_issues":11,"state":"open","created_at":"2016-03-17T20:37:49Z","updated_at":"2016-09-01T16:24:36Z","due_on":"2016-09-01T04:00:00Z","closed_at":null},"comments":5,"created_at":"2015-09-20T00:41:01Z","updated_at":"2016-09-02T03:10:12Z","closed_at":null,"body":"# Summary\r\n\r\nThe data and axis labels are not the same for\r\n\r\n- `plot_source()` compared to `plot('source')`\r\n- `plot_model()` compared to `plot('model')`\r\n\r\nwhen using PHA data sets. It's not clear whether it's the same issue for the two, but we need to look at what the `plot` command is doing.\r\n\r\n# Details\r\n\r\nThe following is seen with the ChIPS backend (CIAO 4.7) and master with the `master` branch. I've seen it with multiple PHA data sets.\r\n\r\n```\r\n% ipython --pylab\r\nPython 2.7.10 |Continuum Analytics, Inc.| (default, Sep 15 2015, 14:50:01) \r\nType \"copyright\", \"credits\" or \"license\" for more information.\r\n\r\nIPython 4.0.0 -- An enhanced Interactive Python.\r\n?         -> Introduction and overview of IPython's features.\r\n%quickref -> Quick reference.\r\nhelp      -> Python's own help system.\r\nobject?   -> Details about 'object', use 'object??' for extra details.\r\nUsing matplotlib backend: Qt4Agg\r\n\r\nIn [1]: from sherpa.astro import ui\r\n/home/naridge/local/anaconda/envs/sherpa-astropy-fits-gzip/lib/python2.7/site-packages/IPython/kernel/__init__.py:13: ShimWarning: The `IPython.kernel` package has been deprecated. You should import from ipykernel or jupyter_client instead.\r\n  \"You should import from ipykernel or jupyter_client instead.\", ShimWarning)\r\nWARNING: failed to import sherpa.astro.xspec; XSPEC models will not be available\r\n\r\nIn [2]: ui.load_pha(1, 'sherpa-test-data/sherpatest/threads/pha_intro/3c273.pi') \r\nWARNING: systematic errors were not found in file 'sherpa-test-data/sherpatest/threads/pha_intro/3c273.pi'\r\nstatistical errors were found in file 'sherpa-test-data/sherpatest/threads/pha_intro/3c273.pi' \r\nbut not used; to use them, re-read with use_errors=True\r\nread ARF file sherpa-test-data/sherpatest/threads/pha_intro/3c273.arf\r\nread RMF file sherpa-test-data/sherpatest/threads/pha_intro/3c273.rmf\r\nWARNING: systematic errors were not found in file 'sherpa-test-data/sherpatest/threads/pha_intro/3c273_bg.pi'\r\nstatistical errors were found in file 'sherpa-test-data/sherpatest/threads/pha_intro/3c273_bg.pi' \r\nbut not used; to use them, re-read with use_errors=True\r\nread background file sherpa-test-data/sherpatest/threads/pha_intro/3c273_bg.pi\r\n\r\nIn [3]: ui.load_pha(2, 'sherpa-test-data/sherpatest/threads/pha_intro/3c273.pi') \r\nWARNING: systematic errors were not found in file 'sherpa-test-data/sherpatest/threads/pha_intro/3c273.pi'\r\nstatistical errors were found in file 'sherpa-test-data/sherpatest/threads/pha_intro/3c273.pi' \r\nbut not used; to use them, re-read with use_errors=True\r\nread ARF file sherpa-test-data/sherpatest/threads/pha_intro/3c273.arf\r\nread RMF file sherpa-test-data/sherpatest/threads/pha_intro/3c273.rmf\r\nWARNING: systematic errors were not found in file 'sherpa-test-data/sherpatest/threads/pha_intro/3c273_bg.pi'\r\nstatistical errors were found in file 'sherpa-test-data/sherpatest/threads/pha_intro/3c273_bg.pi' \r\nbut not used; to use them, re-read with use_errors=True\r\nread background file sherpa-test-data/sherpatest/threads/pha_intro/3c273_bg.pi\r\n\r\nIn [4]: ui.set_source(1, ui.powlaw1d.pl1)\r\n\r\nIn [5]: ui.set_source(2, ui.powlaw1d.pl2)\r\n\r\nIn [6]: ui.set_analysis(1, 'energy')\r\n\r\nIn [7]: ui.set_analysis(2, 'wave')\r\n\r\nIn [8]: ui.plot_source(1)\r\n\r\nIn [9]: plt.ylim()\r\nOut[9]: (0.0, 10.0)\r\n```\r\n\r\nThe X axis is labelled `Energy (keV)` and the Y axis `f(E)  Photons/sec/cm^2/keV` (for the matplotlib backend this is not converted to a superscript; I'll have a PR about that).\r\n\r\n```\r\nIn [10]: ui.plot_source(2)\r\n\r\nIn [11]: plt.ylim()\r\nOut[11]: (0.0, 0.90000000000000002)\r\n```\r\n\r\nSwitching to wavelength gives an X axis label of `Wavelength (\\AA)` and Y axis label of `f(\\lambda)  Photons/sec/cm^2/\\AA`.\r\n\r\nIf I now switch to the `plot` command, I get different axis labels *and* ranges displayed on the Y axis:\r\n\r\n```\r\nIn [12]: ui.plot('source', 1)\r\n\r\nIn [13]: plt.ylim()\r\nOut[13]: (0.0, 0.00040000000000000002)\r\n```\r\n\r\nThe Y axis label is now `Counts/sec/keV`- i.e. it looks like it thinks it is plotting the model - but you can see that the model is still a plain power law (i.e. not multiplied by an ARF). Not sure what the Yaxis range indicates, but it is *significantly* different to the `plot_source` values shown above. You see similar things with the wavelength version:\r\n\r\n```\r\nIn [14]: ui.plot('source', 2)\r\n\r\nIn [15]: plt.ylim()\r\nOut[15]: (0.0, 2.9999999999999997e-05)\r\n```\r\n\r\nThe Y axis label now is (if you can see it) `Counts/sec/Angstrom` and the X axis is `Wavelength (Angstrom)`.\r\n\r\nif I compare `ui.plot_model(1)` to `ui.plot('model', 1)` then there's much less difference, but they aren't quite the same (it looks like the points the model is evaluated over are different, so that the X axis range is slightly different).\r\n\r\nThe plot for `ui.plot_model(2)` looks very wrong (the X axis is 0 to 5000!), whereas `ui.plot('model', 2)` covers 0 to 800.\r\n"},"comment":{"url":"https://api.github.com/repos/sherpa/sherpa/issues/comments/244272354","html_url":"https://github.com/sherpa/sherpa/issues/106#issuecomment-244272354","issue_url":"https://api.github.com/repos/sherpa/sherpa/issues/106","id":244272354,"user":{"login":"olaurino","id":5692321,"avatar_url":"https://avatars.githubusercontent.com/u/5692321?v=3","gravatar_id":"","url":"https://api.github.com/users/olaurino","html_url":"https://github.com/olaurino","followers_url":"https://api.github.com/users/olaurino/followers","following_url":"https://api.github.com/users/olaurino/following{/other_user}","gists_url":"https://api.github.com/users/olaurino/gists{/gist_id}","starred_url":"https://api.github.com/users/olaurino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olaurino/subscriptions","organizations_url":"https://api.github.com/users/olaurino/orgs","repos_url":"https://api.github.com/users/olaurino/repos","events_url":"https://api.github.com/users/olaurino/events{/privacy}","received_events_url":"https://api.github.com/users/olaurino/received_events","type":"User","site_admin":false},"created_at":"2016-09-02T03:10:12Z","updated_at":"2016-09-02T03:10:12Z","body":"One way might be to override `plot` in `sherpa.astro...Session`, code the exceptions to the parent's cases, i.e. if the data is `DataPHA` and fall back on the parent's method if the data is not `DataPHA`. This might work, but it goes in the wrong direction, increasing the complexity rather than reducing it."}}
{"actor":{"display_login":"olaurino"}}