-
Notifications
You must be signed in to change notification settings - Fork 10
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
Piff 114 moments #115
Piff 114 moments #115
Conversation
Hmm. The python 2.7 test is failing in installing the dependencies. |
tests/test_moments.py
Outdated
np.testing.assert_equal(np.array(moments)[mask_4r], np.array(moments_4r)) | ||
|
||
if test_mask: | ||
copy_star = piff.Star(noisy_star.data, noisy_star.fit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy_star = noise_star.copy()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Star doesn't actually have a copy method. If I add one
def copy(self):
return copy.deepcopy(self)
This works fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry. My mistake. I thought we had one. I'm pretty sure we don't want deepcopy
here though. Just copy
. We normally want to leave it as shallow as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's doesn't work with the current code. It fails unless I use this line in test_moments.py:
noisy_star = copy.deepcopy(noiseless_star)
If I leave that line as a shallow copy the variance of the moments distributions are all zero. Offhand it isn't clear to my why that should fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Strange. I thought the line you had here would have been equivalent to a shallow copy. Just copying the pointers to data and fit. I thought that was basically what copy.copy
did -- just shallow copy all the attributes.
…ot regression values
fcc398e
to
f463669
Compare
FYI, I decided to try to close out this issue that's been lingering for over a year now. I did all the things I had suggested in my review from back then, since I think Eric has moved on to other projects. I also decided to tackle the derivations of the variances, since I'd never been happy with the fudge factors that were in there. So now the math is all included in inline comments, and the analytic variance estimates are all accurate, at least for small e1,e2. (I may try to add the ellipticity terms while the math is all still fresh, but they get pretty complicated for a lot of the moments, so I started with just getting things accurate for roundish stars.) There is a script in the devel directory called calibrate_moment_errors.py, which I had written as a way to figure out the right fudge factors, but now, with the improved formulae, is rather a script to verify that no fudge factors are required anymore. |
I have been swamped by my new LSST responsibilities – but I will look at what you have.
If you have an analytic version that includes the terms dependent on the kernel that would be awesome…
…_________________________________________________________________________
Prof. Aaron Roodman
Dept. of Particle Physics & Astrophysics
Kavli Institute for Particle Astrophysics & Cosmology
SLAC National Accelerator Laboratory
Stanford University
SLAC National Accelerator Laboratory E-mail: ***@***.******@***.***>
2575 Sand Hill Rd. Phone: 650-926-2705
MS 29
Menlo Park, CA 94025 URL: http://www.slac.stanford.edu/~roodman
_________________________________________________________________________
From: Mike Jarvis ***@***.***>
Date: Tuesday, October 26, 2021 at 4:56 PM
To: rmjarvis/Piff ***@***.***>
Cc: Subscribed ***@***.***>
Subject: Re: [rmjarvis/Piff] Piff 114 moments (#115)
FYI, I decided to try to close out this issue that's been lingering for over a year now. I did all the things I had suggested in my review from back then, since I think Eric has moved on to other projects.
I also decided to tackle the derivations of the variances, since I'd never been happy with the fudge factors that were in there. So now the math is all included in inline comments, and the analytic variance estimates are all accurate, at least for small e1,e2. (I may try to add the ellipticity terms while the math is all still fresh, but they get pretty complicated for a lot of the moments, so I started with just getting things accurate for roundish stars.)
There is a script in the devel directory called calibrate_moment_errors.py, which I had written as a way to figure out the right fudge factors, but now, with the improved formulae, is rather a script to verify that no fudge factors are required anymore.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#115 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABARV4ZMSQYIX7J6XIBAFZDUI45ZPANCNFSM4OHUL3FA>.
Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Yep, that's the main thing that was required to make things work out. Figuring out dW/dI_k. Basically, we have dW/dI_k = dW/du0 du0/dI_k + dW/dv0 dv0/dI_k + dW/dssq dssq/dI_k + dW/de1 de1/dI_k + dW/de2 de2/dI_k. The first factor in each is fairly straightforward, coming from the Gaussian form of W. The math is all there in comments. Some of the algebra is left to the reader, but hopefully it's complete enough to be relatively followable. |
Two comments...
`def get_moment_names(third_order=False, fourth_order=False, radial=False, errors=False, kernel=None):
` |
|
|
BTW, in the dict version, you could still reproduce the full list with |
Returning a dict would be ok. I wrote some code for OptAtmo to parse the moment names based on the yaml configuration, to pull out just the values used in the Chi2, and could modify that to use the keys and items of a dict. For the moment-based fitting this gets called a lot, but I guess there isn't that much overhead in forming a small dictionary each time. As to the error checking, I would have to change my code that calls this to adjust to the error condition, as would any other user of it. Not a big modification of course, and you are right that it ensures that the failure is noticed by the calling code. I already have a method that calls this given a list of stars, and can put the checking there. So thats ok with me too. |
OK, I switched it to return a dict for the moments, and if requested a second dict with the same keys for the variances. I think that's a nicer API than returning a long opaque list of values. The values in the dict are ordered, so you can turn it back to a long list if you want, with the same ordering that we currently have. But I suspect user code will be significantly more legible using the key names for access. |
I also looked into getting the ellipticity terms correct, but they quickly got out of hand as lots of high order moments became relevant (M42, M24, M04, M40, etc.). So I think we should be content that the variances are pretty good for round stars, but maybe not so great when the ellipticity is more than a few percent. |
Probably need to iterate a bit to get full coverage.