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

adding uncertainty to repr for Spectrum1D #476

Merged
merged 1 commit into from
Jul 2, 2019

Conversation

SaOgaz
Copy link
Contributor

@SaOgaz SaOgaz commented Jun 26, 2019

If people like this change I can go through all the docs and update any output that needs it.

Here's what it looks like with this change in an ipython session


In [6]: spec = Spectrum1D(spectral_axis=np.linspace(0, 50, 50) * u.AA, 
   ...: ...                   flux=np.random.randn(50) * u.Jy, 
   ...: ...                   uncertainty=StdDevUncertainty(np.random.sample(50), unit='Jy'))                                                          

In [7]: spec                                                                                                                                           
Out[7]: 
<Spectrum1D(flux=<Quantity [-0.79350782, -0.1985586 ,  0.69941613, -1.26048916, -0.30668635,
            0.22692452, -1.48539139,  0.06807652,  2.35720788,  0.08976297,
           -1.34475404, -1.12296945,  0.40057251,  1.34168387, -0.73202276,
           -0.01233865, -0.23764738, -1.18952659,  0.59660562, -2.62269804,
           -0.31162905, -0.29284552,  0.71713381,  0.13721592, -0.03311284,
            0.77818938, -0.09165447, -0.50518192, -1.36158287,  0.4004441 ,
           -1.26370512,  1.36290666,  0.20989722,  0.13344762, -0.43951508,
           -0.11195588,  0.38274015,  0.62751832, -1.4268625 , -2.33907961,
           -0.61735017,  0.16263518, -0.65331399, -0.68958623, -0.93873669,
            0.11189459,  0.1174194 ,  0.96402335,  1.37272333, -0.41412246] Jy>, spectral_axis=<Quantity [ 0.        ,  1.02040816,  2.04081633,  3.06122449,  4.08163265,
            5.10204082,  6.12244898,  7.14285714,  8.16326531,  9.18367347,
           10.20408163, 11.2244898 , 12.24489796, 13.26530612, 14.28571429,
           15.30612245, 16.32653061, 17.34693878, 18.36734694, 19.3877551 ,
           20.40816327, 21.42857143, 22.44897959, 23.46938776, 24.48979592,
           25.51020408, 26.53061224, 27.55102041, 28.57142857, 29.59183673,
           30.6122449 , 31.63265306, 32.65306122, 33.67346939, 34.69387755,
           35.71428571, 36.73469388, 37.75510204, 38.7755102 , 39.79591837,
           40.81632653, 41.83673469, 42.85714286, 43.87755102, 44.89795918,
           45.91836735, 46.93877551, 47.95918367, 48.97959184, 50.        ] Angstrom>, uncertainty=StdDevUncertainty([0.55949932, 0.7743728 , 0.89748501, 0.63007083,
                   0.11617335, 0.11122692, 0.72021224, 0.2168352 ,
                   0.49825998, 0.91373081, 0.1780643 , 0.92995308,
                   0.02226761, 0.73156982, 0.3332609 , 0.03908292,
                   0.96935045, 0.69324456, 0.45283954, 0.01795764,
                   0.3105003 , 0.33231226, 0.40595955, 0.21787728,
                   0.9849537 , 0.7775922 , 0.11466842, 0.14362938,
                   0.63796639, 0.10280555, 0.73154504, 0.57335405,
                   0.73362712, 0.05337787, 0.81576867, 0.66795002,
                   0.75455155, 0.73228133, 0.79322921, 0.25778224,
                   0.58692161, 0.83211342, 0.62523079, 0.57217811,
                   0.43043543, 0.80936413, 0.81700978, 0.63452876,
                   0.25442867, 0.23880276]))>

What it looked like before:

In [30]: new_spec3                                                                                                                                     
Out[30]: 
<Spectrum1D(flux=<Quantity [0.18278657, 0.01050715, 0.27264392, 0.69624523, 1.01334485,
           1.07064075, 0.83599236, 0.43168126, 0.12365467, 0.05162207,
           0.21706343, 0.48931305, 0.62018392, 0.55961905, 0.45844228,
           0.4132248 , 0.45743191, 0.62178518, 0.        ] Jy>, spectral_axis=<Quantity [ 1.5,  2.5,  3.5,  4.5,  5.5,  6.5,  7.5,  8.5,  9.5, 10.5,
           11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5] nm>)>

closes #470

Copy link
Contributor

@nmearl nmearl left a comment

Choose a reason for hiding this comment

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

This looks fine to me. However, I should note that there ought never be a case where the wcs is undefined.

@SaOgaz
Copy link
Contributor Author

SaOgaz commented Jun 27, 2019

@nmearl if that's truly the case, the check might be leftover from an earlier version of specutils, should I remove it?

@nmearl
Copy link
Contributor

nmearl commented Jun 28, 2019

I'm inclined to say yes, you should remove it, because if self.wcs is None, then there are definite problems, hah.

@SaOgaz
Copy link
Contributor Author

SaOgaz commented Jun 28, 2019

Test failure unrelated to this PR.

@nmearl nmearl merged commit 91041bb into astropy:master Jul 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spectrum1D repr needs to print uncertainty
2 participants