gcr
A common reader interface for accessing generic catalogs
Science Score: 10.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
2 of 4 committers (50.0%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.5%) to scientific vocabulary
Keywords
Repository
A common reader interface for accessing generic catalogs
Basic Info
- Host: GitHub
- Owner: yymao
- License: mit
- Language: Python
- Default Branch: master
- Homepage: https://yymao.github.io/generic-catalog-reader/index.html
- Size: 722 KB
Statistics
- Stars: 7
- Watchers: 2
- Forks: 8
- Open Issues: 1
- Releases: 27
Topics
Metadata Files
README.md
Generic Catalog Reader (GCR)
A ready-to-use, abstract base class for creating a common reader interface that accesses generic table-like catalogs.
This project was started in response to the need of the DESCQA framework. It is now used in the LSST DESC GCR Catalogs.
Installation
You can install GCR from conda-forge:
bash
conda install gcr --channel conda-forge
Or from PyPI:
bash
pip install GCR
Concept
The reader should specify: (1) how to translate (assemble) requested quantities from the native quantities; and (2) how to access native quantities from the underlying data format.

Usage
You can find API documentation here. However, looking at some real examples is probably more useful.
Basically, you will subclass GCR.BaseGenericCatalog and then set the member dict _quantity_modifiers inside _subclass_init, and implement the member methods _generate_native_quantity_list and _iter_native_dataset. Here's an minimal example.
```python import h5py import GCR
class YourCatalogReader(GCR.BaseGenericCatalog):
def _subclass_init(self, **kwargs):
self._file = kwargs['filename']
self._quantity_modifiers = {
'galaxy_id' : 'galaxyID',
'ra': (lambda x: x/3600.0, 'ra'),
'dec': (lambda x: x/3600.0, 'dec'),
'is_central': (lambda x, y: x == y, 'haloId', 'parentHaloId'),
}
def _generate_native_quantity_list(self):
"""
Must return an iterable of all native quantity names.
"""
with h5py.File(self._file, 'r') as fh:
return fh.keys()
def _iter_native_dataset(self, native_filters=None):
"""
Must be a generator.
Must yield a callable, *native_quantity_getter*.
This function must iterate over subsets of rows, not columns!
Below are specifications of *native_quantity_getter*
---
Must take a single argument of a native quantity name.
Should assume the argument is valid.
Must return a numpy 1d array.
"""
assert not native_filters, '*native_filters* is not supported'
with h5py.File(self._file, 'r') as fh:
def native_quantity_getter(native_quantity):
return fh[native_quantity].value
yield native_quantity_getter
```
Owner
- Name: Yao-Yuan Mao
- Login: yymao
- Kind: user
- Location: Salt Lake City, UT, USA
- Company: University of Utah
- Website: https://yymao.github.io/
- Twitter: yaoyuanmao
- Repositories: 14
- Profile: https://github.com/yymao
茅耀元. Astrophysicist at U of Utah studying dark matter & galaxies with astronomical surveys & simulations. Programmer. they/he
GitHub Events
Total
Last Year
Committers
Last synced: about 2 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| Yao-Yuan Mao | y****o@g****m | 120 |
| P Larsen | p****n@a****v | 6 |
| Yao-Yuan Mao | y****o | 1 |
| Michael Wood-Vasey | w****v@p****u | 1 |
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 6
- Total pull requests: 34
- Average time to close issues: 2 days
- Average time to close pull requests: 11 days
- Total issue authors: 5
- Total pull request authors: 4
- Average comments per issue: 0.83
- Average comments per pull request: 0.26
- Merged pull requests: 33
- Bot issues: 0
- Bot pull requests: 4
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- evevkovacs (2)
- danielsf (1)
- wmwv (1)
- joezuntz (1)
- yymao (1)
Pull Request Authors
- yymao (27)
- github-actions[bot] (4)
- patricialarsen (2)
- wmwv (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- pypi 1,029 last-month
-
Total dependent packages: 1
(may contain duplicates) -
Total dependent repositories: 1
(may contain duplicates) - Total versions: 32
- Total maintainers: 1
pypi.org: gcr
Generic Catalog Reader: A common reader interface for accessing generic catalogs
- Homepage: https://github.com/yymao/generic-catalog-reader
- Documentation: https://gcr.readthedocs.io/
- License: MIT
-
Latest release: 0.9.2
published about 5 years ago
Rankings
Maintainers (1)
conda-forge.org: gcr
- Homepage: https://github.com/yymao/generic-catalog-reader
- License: MIT
-
Latest release: 0.9.2
published about 5 years ago
Rankings
Dependencies
- easyquery >=0.1.3
- numpy *