-
Notifications
You must be signed in to change notification settings - Fork 103
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
clean up shearing conventions #134
Comments
To add to the confusion, I'll point out that applyShear explicitly uses the (g1,g2) definition rather than the (e1,e2) definition, which I think is what we want "shear" to mean. But that should be part of the conversation here. |
Yes, good point, that's a worrisome inconsistency. |
When I wrote the code for applyShear, I didn't realize that the Shear class was wrapped, so I thought I was just changing the convention between python and c++ (which is worrisome enough, but I thought manageable for the time being). But since you pointed out that the Shear class is wrapped, it's definitely a problem. |
Just a short note: I was looking through Doxygen notes on galsim.psfcorr.EstimateShearHSM (from issue #151), and the otherwise crystal-clear example given has the shear/distortion convention issue that confused me for a bit. But I guess the issue is already raised here. |
What about the new version that I just pushed (to master)? It's more explicit about what the conventions are. On May 15, 2012, at 4:42 PM, Reiko Nakajima wrote:
Rachel Mandelbaum |
This issue on shearing conventions is one that I would like to get cleared up as part of this 2-week cleanup period between milestones. So, I'm going to ping some of the people who have been actively coding or discussing recently - @barnabytprowe @rmjarvis @TallJimbo @gbernstein @joergdietrich @pmelchior @joezuntz (apologies to those I might have left off accidentally). I'll start by summarizing the problem and then proposing a way to address it. Let's discuss in this issue, and once we have a plan we can decide who is implementing it and when. (Or, please feel free to let me know if you think this is not worth dealing with now...!)
would give a value of 0.0501.
So as a consequence, if we work with our base classes and do this:
then the equivalent operation in terms of SBProfiles would be
In a word, yuck. Are there any other aspects to the problem that I'm missing? Given that statement of the problem, I think that we have a few possible approaches:
would apply a shear g1=0.1, g2=0.0, whereas
would correspond to specifying a distortion of (0.1, 0.0). (We would do this at the C++ level as well, presumably.)
Are there other options I'm missing? |
I think my preference is to use the word "shear" to always mean g1,g2 and the word "distortion" to always mean e1,e2. Then we can have parallel methods like The only problem with this is that there is already an On the C++ side, I'd have the current Shear class be renamed to something like GenShear, which would be a base class for two derived classes Shear and Distortion (or three if we want one for conformal shear), which mostly just change the meaning of the constructor. Everything else (e.g. the getG1G2 methods) would be done via GenShear. In fact, we could just let Distortion be the base class rather than GenShear, and have Shear be a derived class from that. Either way. |
The approach I took in LSST-land was to have different ellipse, You can find the headers here: http://dev.lsstcorp.org/cgit/LSST/DMS/afw.git/tree/include/lsst/afw/geom/ellipses I'd do some things differently if I were to do it again, of course, and I'd
|
I'm with Mike: "shear" needs to mean (g1, g2). Anything else is just confusing. If |
Okay, first of all: I realize now that I expressed a preference for (2) but I didn't say which quantity I would like as default. I want shear to mean (g1, g2), so it seems like so far we're all in agreement on that point. I need to think some more about these suggestions -- more tonight / tomorrow... |
Also, I notice that the documentation on |
I actually did not mean to suggest that, but as long as |
Really sorry for misrepresenting your opinion, I misread the end of your second sentence. I do think that having |
How about adding |
To enter the fray, I definitely agree that Shear should be (g1, g2) and refer to (a - b)(a + b) ellipticities. I think it makes sense to also adopt eta = conformal shear as per B&J 2002 and this leaves (e1, e2) up for grabs by the commonly adopted |e| = (a^2 - b^2)/(a^2 + b^2) -type ellipticity definition. This latter I also think should be called "Distortion" (or perhaps "Polarization"), although what exact name we choose is less important than that we document clearly and precisely what we mean by each term. If we go for Distortion as the name for these (e1, e2) ellipticities, then we need to steer well clear of talking about distortions when we mean the full Affine transformation, so I would back talking about In terms of 1), 2) or 3) in the choices you mention above Rachel, I'm afraid I'm also somewhat undecided between 2 and 3. I think I prefer 3... (Jim, while I found it very interesting and instructive to look at I can't help but think that the approach you took in LSST would be a lot of overhead here, but I'm willing to be outvoted on that! Oh, I think the docs for ReducedShear.h actually refers to the ConformalShear while I look at it...!) |
My opinion on the shear conventions is that you should have a consistent default that people can enter as a pair of numbers, but a means to use another and have it be clear that you're doing so (Rachel's #2 basically). Having required classes for angles, radii, shears, etc makes the usage more ornate and may deter new users from just jumping in and trying the code to do their simple tasks first. Jim, I wrote classes for spherical coordinates that work like the scheme you describe, that I'm very happy with - all transforms between any two coordinate systems are done transparently by assigning coordinates from one derived class to another. So it's elegant. But I also think it's overkill for this job (there are only 3 systems of shear that are likely to be used) and erects another level of complication for future people who might want to learn to use & alter the code. And I say this as someone who usually errs on the side of wasting too much time trying to be elegant ! |
Rachel: the update on the Doxygen text (as seen in the diff) is now clear. From a "new user's" perspective: I think Gary's note on "having a consistent default that people can enter as a pair of numbers" is the way to go, and it would make sense that that be the (g1, g2) shear. It would be great to have an option of specifying (e1,e1), (eta1,eta2) and/or shifts and dilations, via Mike's functions-with-explicit-function-names. Although the few examples I've seen so far have been, really, amazingly crystal-clear. |
I'm happy to concede that a lot of new classes may be overkill for this purpose. Barney, thanks for catching the documentation bug in the LSST code; you're absolutely right. |
In comparison with the cases of radii and angles, both of which we've dealt with recently: a) We dealt with different radius specifications by preserving the SBProfile C++ almost completely, modifying the wrappers in pysrc/ and the base classes instead. b) We dealt with angles by making an We can't take the analogy with those cases too far, and here we already have a
However, I'm undecided as to how to implement this. That is, we could imagine completely preserving the C++ as is and introducing all changes at the level of the wrappers and the various python base classes and their methods, just as for radii. But - since there is a As for |
I mostly agree with the growing consensus, except that I still think that
is clearer than
As for the C++ side, the easiest implementation would be to just change all "distort" to "transform" and "shear" to "distortion". Then if we want, we can add a Shear class that derives from Distortion that would have the regular shear definition for its constructor. |
Mike, I agree with that in the context of this issue, but in a more general context I think Likewise, I don't want to change On May 17, 2012, at 12:16 AM, Mike Jarvis wrote:
Rachel Mandelbaum |
I get the sense that there's a reasonable consensus for what we should do, with the main sticking point being names of functions and so on. I usually think of the quantity (a^2-b^2)/(a^2+b^2) as either ellipticity or distortion. Distortion seems like a bad choice for the reasons already mentioned above (too general a term, could mean a few things) and ellipticity seems like a bad choice because there are a gazillion different ellipticity definitions (okay, not a gazillion, but at least 3). I do think it is okay/non-confusing to take the current Unless someone else particularly wants to take this on, then I am going to volunteer myself because I'm interested in the work and I think it's a reasonable fit for my coding skills. Due to timing constraints (moving in 5 weeks!) I can't promise to finish it all next week before starting the next milestone, but I don't think it's a big problem if this issue takes a little bit longer than that. |
On May 17, 2012, at 12:01 AM, Rachel Mandelbaum wrote:
It would not be difficult to change the C++ Shear class to treat g1/g2 as its default language rather than e1/e2. And I think it's a good idea to have the same convention in all parts of the package. The somewhat harder part would be finding all the code that uses it and making sure it's consistent with the new convention, that's not too bad either though. If it gets to the point where you want to make this change and no one else has eagerly volunteered to learn how Shear class works and change it, then I could do this work in a few hours. |
Gary - I'm quite happy to do it. I agree that it's not tricky, just a bit of tediousness in making sure to find all the relevant bits (and for me, there's an additional advantage in that it forces me to go over bits of the code, some of which I'm still learning). I think that the only subtleties left are what to call some of the methods - e.g., There's also Mike's idea which I like of having a class for e1/e2 |
Given the ambiguity of the word distortion, and nobody jumping in with a name they prefer, I think it's worth taking another look at Rachel's option 3 (or maybe a modification thereof). We could just have one set of functions for shearing, so no If we want, we could have the default meaning be Then all the different functions that take a shear would just pass the (args, kwargs) to the Shear class constructor for parsing, so that would only need to be done once. And maybe if something takes a shear and also other things (do we have any of those? If not, we might someday), we could require that the argument be an explicit Shear object, so you'd have to write In C++, we'd have to implement this a bit differently of course, and we can discuss what would make the most sense. But I think on the python side, this would be fairly clear in all cases. |
So when it comes to the As for the I guess the only remaining question is then the C++ I like this. Let's leave a final decision for the telecon Tues, but I think it's a reasonable compromise. |
… version rather than the g1/g2 version (#134)
Conflicts: galsim/base.py galsim/real.py tests/test_SBProfile.py
…or the Shear class. Ellipse is still not well documented though, and I should make some minor changes to the shear.py module to reflect use here.
Conflicts: examples/MultiObjectDemo.py
As discussed in a few issues (e.g., #71) there are some ambiguities in the definitions of shears. For example, the following code snippet:
results in a shear value of 0.0501256289338. That's because in the first line, the 0.1 is being interpreted as a distortion (a^2-b^2)/(a^2+b^2). This could easily get confusing, so it should be revisited after the 2nd milestone.
We might also revisit some of the naming decisions we've made, e.g. applyShear/createSheared.
The text was updated successfully, but these errors were encountered: