-
Notifications
You must be signed in to change notification settings - Fork 25
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
Computing distances from z1 to z2 #24
Conversation
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.
Thank you so much for the contribution, much appreciated! I suggest to simplify the code a little bit to avoid a lot of duplication.
It would be also great if you could update the documentation in the README.md
Dear Giordano, thank you for your quick reply! Yes, indeed we could unify the code and use a single function with a default argument. The only issue is that the default argument has to be z₂, because the "natural" way of indicating the distances would be from z₁ to z₂, but, logically, it would be z₁. We should therefore do, within the various functions involved, something like
I am not entirely sure that is better than having the dispatch mechanism handling the one-redshift case: to me this looks more involved than defining a new (one line effectively) function. What do you think? |
Maybe I'm missing something, but if we default |
Maybe I was unclear in my explanation. The current implementation, i.e. the signature
computes the angular diameter distance from redshift
If we want the user to be able to use this function without the 0 argument (which surely is something desirable, also for compatibility with respect to the current implementation), we cannot just set a default value, because that would have to be I see three possible solutions
Regards, |
I think the order of the arguments you suggest is totally reasonable, but the code duplication is a bit unfortunate. Could you please add tests for the new method and address the few unresolved comments above? Then we can merge this and maybe I'll try to work out a way to reduce code duplication later. Edit: ok, I have a working way to reduce the code duplication. I'm happy to merge this PR with the current implementation, provided that you add the tests. |
|
||
angular_diameter_dist(c::AbstractCosmology, z; kws...) = | ||
comoving_transverse_dist(c, z; kws...)/(1 + z) | ||
angular_diameter_dist(c::AbstractCosmology, z₁, z₂; kws...) = | ||
comoving_transverse_dist(c, z₁, z₂; kws...)/(1 + z₂) | ||
|
||
luminosity_dist(c::AbstractCosmology, z; kws...) = |
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.
Should luminosity_dist
and distmod
have the new method?
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.
Probably not: I never saw a luminosity distance between two different redshifts, and I cannot easily imagine a situation where such a quantity would be used. But, for completeness, one could also include it. FYI, the Python astrolib package does not include it.
Anyway, let me know your decision, and I will modify the code (and the Readme file) accordingly.
P.S. Not sure how it works: if I make a new commit to the code and push it to the repository, is the pull request automatically updated or should I make a new pull request?
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, no need to add these methods, but please add tests. You can just keep pushing to the same branch, the pull request will be updated
Just to let you know that I pushed a commit with the fixes you requested (no deprecations for the new functions, readme updated, and new tests for the 2-redshift argument). |
Awesome, thank you so much! |
Thank you for your quick reaction! I am happy I could contribute somehow (even if to such a small degree) to the library. Regards, Marco |
Hi,
I am asking to include in the computation of various distances, the distances between two redshifts. This kind of computation is important for gravitational lensing and is indeed included already in the Python astrolib package.
Regards,
Marco Lombardi