Repository navigation
Cosmo read/write ECSV - #12321
Cosmo read/write ECSV#12321
Conversation
|
Hello @nstarman 👋! It looks like you've made some changes in your pull request, so I've checked the code again for style. There are no PEP8 style issues with this pull request - thanks! 🎉 Comment last updated at 2021-10-30 16:38:46 UTC |
16ada4e to
89c75f5
Compare
e6b160c to
f3c6299
Compare
464c4a0 to
c843604
Compare
|
@nstarman @taldcroft |
5788a76 to
cdcdf5d
Compare
Signed-off-by: Nathaniel Starkman (@nstarman) <[email protected]>
cdcdf5d to
4854646
Compare
Signed-off-by: Nathaniel Starkman (@nstarman) <[email protected]>
4854646 to
85dc20d
Compare
taldcroft
left a comment
There was a problem hiding this comment.
Just a few docs comments for now, will try to get to the rest soon.
| registered. Details are discussed in an addition to the docs. | ||
|
|
||
| Currently no file formats are registered, but the syntax is as follows: | ||
| Currently the only registered read/write format is "ascii.ecsv", like for Table. |
There was a problem hiding this comment.
No need to sound apologetic, the one format is great and this can be where we try to define the new standard. 😄
| Currently the only registered read/write format is "ascii.ecsv", like for Table. | |
| For writing the representation of a ``Cosmology`` to a file, the ECSV [link to APE-6] table format | |
| is available. Astropy is encouraging the use of this format as a standard interoperable | |
| way of storing and communicating cosmology parameters. |
| >>> | ||
| >>> from astropy.cosmology import Cosmology | ||
| >>> cosmo = Cosmology.read('<file name>.<format>') | ||
| >>> cosmo = Cosmology.read('<file name>.ecsv') |
There was a problem hiding this comment.
| >>> cosmo = Cosmology.read('<file name>.ecsv') | |
| >>> cosmo = Cosmology.read('plank18.ecsv') |
There was a problem hiding this comment.
I didn't think whatsnew was skipped in tests. This makes examples much better.
| >>> cosmo = Cosmology.read('<file name>.ecsv') | ||
| >>> cosmo == Planck18 | ||
| True | ||
|
|
There was a problem hiding this comment.
I think the examples below are a bit long for the What's New. The idea is not to comprehensively show the capabilities but just highlight things enough for interested people to click through to the docs link. I think each What's New entry should fit comfortably on one laptop screen (and maybe half the people are reading on mobile?). So maybe just:
Transformations between ``Cosmology`` and `dict`, ``QTable``, and``Model`` are
pre-registered, enabling for example::
>>> from astropy.cosmology import Cosmology, Planck18
>>> cm = Planck18.to_format("mapping")
>>> cm
{'cosmology': <class 'astropy.cosmology.flrw.FlatLambdaCDM'>,
'name': 'Planck18',
'H0': <Quantity 67.66 km / (Mpc s)>,
'Om0': 0.30966,
...
For details see :ref:`whatever`.
There was a problem hiding this comment.
SGTM. I would like to show Table and Model. I think those are the compelling examples.
023ab91 to
9a52d7a
Compare
Co-authored-by: Tom Aldcroft <[email protected]> Signed-off-by: Nathaniel Starkman (@nstarman) <[email protected]>
9a52d7a to
2a4e468
Compare
|
Thanks @taldcroft for pushing to get this in for v5.0! |
Description
A Cosmology can be read from / written to an ECSV file. This keeps all units and metadata and will work when Cosmology is enhanced to be able to be array-valued.
Requires #12213 . Will be rebased when that it is merged. Test failing because there is more than 1 changelog fragment.Merged.
Checklist for package maintainer(s)
This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.
Extra CIlabel.no-changelog-entry-neededlabel. If this is a manual backport, use theskip-changelog-checkslabel unless special changelog handling is necessary.astropy-botcheck might be missing; do not let the green checkmark fool you.backport-X.Y.xlabel(s) before merge.