Basic FLRW cosmological distance, time, and age calculations in Go.
wmwv / cosmo Goto Github PK
View Code? Open in Web Editor NEWGo cosmology library
License: MIT License
Go cosmology library
License: MIT License
Clean up godoc.org presentation. Mostly line breaks.
cosmo
summarize the cosmologies supported.Make HubbleTime
and TElliptic
not exported.
Make w0
exported from the Cosmology
struct.
Make a fmt.Println(cos)
format nicely. E.g.,
{H0: 70, Om0: 0.27, Ol0: 0.73, W0: -0.9, WA: 3}
Using elliptic integrals to speed of comoving distance calculation.
See if it's worth casting, e.g., a flat WCDM into FlatLCDM to reduce the redundancy between function calculations.
Check and correct test cases for wcdm_test, wacdm_test
w0=-1
instead of w0=-1.2
. Use astropy.cosmology.wCDM
, w0waCDM
to correct the expected values.wcdm_test.go
wacdm_test.go
Remove LookbackTimeIntegrate from FLRW interface
This is an implementation choice that doesn't need to be exposed in the public interface.
Rename Cosmology
interface to FLRW
. That's more specifically the interface that the methods have to fine. And the name of the package cosmo
already captures that part of the name.
Want to be able to interrogate FLRW types about their flatness in a generic way.
Could imagine having a generic Getter framework, but let's restrict this issue to just Ok0()
.
[No Setters in any case as the cosmology structs should be immutable.]
There is some code in to vectorize Evec calculations, but there's not a clear use model informing the design. The Evec function is not otherwise used internally.
Remove Evec functions and associated tests.
The WCDM.ComovingDistance
is currently wrong for Nonflat LCDM cases.
wcdm.go
lambdacdm.go
, wacdm.go
as well.Add AngularDiameterDistance function
Add special case analytic comoving distance for Omega_M-only (Omega_Lambda)=0.
Make the quad.Fixed
-calling functions:
func (cos *Cosmology) ComovingDistanceZ1Z2Integrate(z1, z2 float64) (distance float64)
func (cos *Cosmology) LookbackTimeIntegrate(z float64) (time float64)
func (cos *Cosmology) AgeIntegrate(z float64) (time float64)
accept an argument specifying the number of integration points.
This isn't particularly likely to be used, and it would be better to instead specify relative or absolute tolerance, but having n
hardcoded is worse.
All cosmologies need H0, then Om0, then Ol0, then W0, then WA.
Reorder struct attributes to put H0 to match this so that one can have
EdS(H0)
FlatLCDM(H0, Om0)
LambdaCDM(H0, Om0, Ol0)
WCDM(H0, Om0, Ol0, W0)
WACDM(H0, Om0, Ol0, W0, WA)
Note that EdS doesn't current exist as a type listing it here captures the point of why there's a certain natural order to the arguments.
I think that LambdaCDM doesn't correctly calculate luminosity distance in non-flat cosmologies.
Cosmology
interface.FlatLCDM
struct in Cosmology
interface.LambdaCDM
struct in Cosmology
interface.Current types don't actually do anything with Tcmb0
.
FlatLCDM
, LambdaCDM
, WCDM
, and WACDM
.Add benchmarks for wcdm, wacdm
Add performance benchmarks
if
or switch
statement to avoid the math.Sinh
calculation for Omega_curvature = 0.Satisfy the Go linter, golang/lint/golint
Define structs and methods for
E.g., the current test says this:
var answersWCDM = map[string][]float64{
// wCDM(70, 0.3, 0.7, -1.2).distmod(z)
"WCDMDistanceModulus": []float64{42.32710911, 44.17957201, 46.03118144, 47.09228735},
// wCDM(70, 0.3, 0.7, -1.1).luminosity_distance(z)
"WCDMLuminosityDistanceFlat": []float64{2877.10314183, 6734.38177991, 15823.59621899, 25841.56448508},
}
Change to something more like
var answersWCDM = []struct {
H0 float64
Om0 float64
Ol0 float64
W0 float64
name string
out float64
}{
// wCDM(70, 0.3, 0.7, -1.2).distmod(z)
{70, 0.3, 0.7, -1.2, "WCDMDistanceModulus", []float64{42.32710911, 44.17957201, 46.03118144, 47.09228735}},
// wCDM(70, 0.3, 0.7, -1.1).luminosity_distance(z)
{70, 0.3, 0.7, -1.1, "WCDMLuminosityDistanceFlat", []float64{2877.10314183, 6734.38177991, 15823.59621899, 25841.56448508},
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.