Science Score: 77.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 3 DOI reference(s) in README -
✓Academic publication links
Links to: zenodo.org -
✓Committers with academic emails
1 of 5 committers (20.0%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (7.4%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
A python client for Kowalski
Basic Info
Statistics
- Stars: 6
- Watchers: 3
- Forks: 8
- Open Issues: 3
- Releases: 6
Topics
Metadata Files
readme.md
penquins: a python client for Kowalski
penquins is a python client for Kowalski, a multi-survey data archive and alert broker for time-domain astronomy.
Quickstart
Install penquins from PyPI:
bash
pip install penquins --upgrade
Connect to a Kowalski instance:
```python from penquins import Kowalski
username = "
protocol, host, port = "https", "
kowalski = Kowalski( username=username, password=password, protocol=protocol, host=host, port=port ) ``` When connecting to only one instance, it will be labeled as "default". Keep this in mind when retrieving the results of your queries.
Connect to multiple Kowalski instances:
```python from penquins import Kowalski
instances = {
"kowalski": {
"name": "kowalski",
"host": "
kowalski = Kowalski(instances=instances) ```
When using multiple instances at once, you can specify a single instance to query using its name when calling query(name=...), or no name at all. If no name is provided and the catalog(s) being queried is/are available on multiple instances, penquins will divide the load between instances automagically.
When retrieving the results, you'll have to use the instance(s) name instead of "default", or simply iterate over the results by instance and merge the results.
It is recommended to authenticate once and then just reuse the generated token:
```python token = kowalski.token print(token)
kowalski = Kowalski( token=token, protocol=protocol, host=host, port=port ) ```
Check connection:
python
kowalski.ping()
Querying a Kowalski instance
Most users will be interacting with Kowalski using the Kowalski.query method.
Retrieve available catalog names:
```python query = { "querytype": "info", "query": { "command": "catalognames", } }
response = kowalski.query(query=query) data = response.get("default").get("data") ```
Query for 7 nearest sources to a sky position, sorted by the spheric distance, with a near query:
```python query = { "querytype": "near", "query": { "maxdistance": 2, "distanceunits": "arcsec", "radec": {"querycoords": [281.15902595, -4.4160933]}, "catalogs": { "ZTFsources20210401": { "filter": {}, "projection": {"id": 1}, } }, }, "kwargs": { "maxtime_ms": 10000, "limit": 7, }, }
response = kowalski.query(query=query) data = response.get("default").get("data") ```
Retrieve available catalog names:
```python query = { "querytype": "info", "query": { "command": "catalognames", } }
response = k.query(query=query) data = response.get("default").get("data") ```
Query for 7 nearest sources to a sky position, sorted by the spheric distance, with a near query:
```python query = { "querytype": "near", "query": { "maxdistance": 2, "distanceunits": "arcsec", "radec": {"querycoords": [281.15902595, -4.4160933]}, "catalogs": { "ZTFsources20210401": { "filter": {}, "projection": {"id": 1}, } }, }, "kwargs": { "maxtime_ms": 10000, "limit": 7, }, }
response = k.query(query=query) data = response.get("default").get("data") ```
Run a cone_search query:
```python query = { "querytype": "conesearch", "query": { "objectcoordinates": { "conesearchradius": 2, "conesearchunit": "arcsec", "radec": { "ZTF20acfkzcg": [ 115.7697847, 50.2887778 ] } }, "catalogs": { "ZTFalerts": { "filter": {}, "projection": { "id": 0, "candid": 1, "objectId": 1 } } } }, "kwargs": { "filterfirst": False } }
response = kowalski.query(query=query) data = response.get("default").get("data") ```
Run a find query:
```python q = { "querytype": "find", "query": { "catalog": "ZTFalerts", "filter": { "objectId": "ZTF20acfkzcg" }, "projection": { "_id": 0, "candid": 1 } } }
response = kowalski.query(query=q) data = response.get("default").get("data") ```
Run a batch of queries in parallel:
```python queries = [ { "querytype": "find", "query": { "catalog": "ZTFalerts", "filter": { "candid": alert["candid"] }, "projection": { "_id": 0, "candid": 1 } } } for alert in data ]
responses = k.query(queries=queries, usebatchquery=True, maxnthreads=4) ```
Querying multiple instances at once
When using multiple instances at once, you can specify a single instance to query using its name when calling query(name=...), or no name at all. If no name is provided, and the catalog(s) being queried is/are available on multiple instances, penquins will divide the load between instances automagically.
When retrieving the results, you'll have to use the instance(s) name instead of "default", or simply iterate over the results by instance and merge the results.
Any of the queries mentioned for single instance querying also work here.
Examples
No instance name specified:
```python q = { "querytype": "find", "query": { "catalog": "ZTFalerts", "filter": { "objectId": "ZTF20acfkzcg" }, "projection": { "id": 0, "candid": 1 } } } response = kowalski.query(query=q) data = response.get(<instancename).get("data") # retrieving data from one instance
OR
data = [] # or {} depending on the query's expected result, differs by query type for instance, instanceresults in response.items(): for result in instanceresults: data.append(result.get('data')) ```
Instance name specified:
python
q = {
"query_type": "find",
"query": {
"catalog": "ZTF_alerts",
"filter": {
"objectId": "ZTF20acfkzcg"
},
"projection": {
"_id": 0,
"candid": 1
}
}
}
response = kowalski.query(query=q, name=<instance_name>)
data = response.get(<instance_name).get("data") # retrieving data from one instance
Interacting with the API
Users can interact with Kowalski's API
in a more direct way using the Kowalski.api method.
Users with admin privileges can add/remove users to/from the system:
```python username = "noone" password = "nopas!" email = "user@caltech.edu"
request = { "username": username, "password": password, "email": email }
response = kowalski.api(method="post", endpoint="/api/users", data=request)
response = kowalski.api(method="delete", endpoint=f"/api/users/{username}") ```
Publish new version
Please refer to https://realpython.com/pypi-publish-python-package/ for a detailed guide.
```shell script pip install bumpversion export PENQUINS_VERSION=2.4.2
bumpversion --current-version $PENQUINSVERSION minor setup.py penquins/penquins.py python setup.py sdist bdistwheel
twine check dist/$PENQUINS_VERSION twine upload dist/$PENQUINS_VERSION
username: token
token:
Owner
- Name: Dmitry Duev
- Login: dmitryduev
- Kind: user
- Location: California
- Website: https://duev.space
- Repositories: 12
- Profile: https://github.com/dmitryduev
Citation (CITATION.cff)
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Duev"
given-names: "Dmitry"
orcid: "https://orcid.org/0000-0001-5060-8733"
title: "dmitryduev/penquins: a python client for dmitryduev/kowalski"
version: v2.1.2
date-released: 2021-11-07
doi: 10.5281/zenodo.5651471
url: "https://github.com/dmitryduev/penquins"
GitHub Events
Total
- Watch event: 1
Last Year
- Watch event: 1
Committers
Last synced: almost 3 years ago
All Time
- Total Commits: 28
- Total Committers: 5
- Avg Commits per committer: 5.6
- Development Distribution Score (DDS): 0.429
Top Committers
| Name | Commits | |
|---|---|---|
| dmitryduev | d****v@g****m | 16 |
| Dmitry Duev | d****v@u****m | 9 |
| Michael Coughlin | m****n@g****m | 1 |
| Theophile du Laz | t****z@g****m | 1 |
| Leo Singer | l****r@l****g | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 6
- Total pull requests: 33
- Average time to close issues: 29 days
- Average time to close pull requests: 9 days
- Total issue authors: 5
- Total pull request authors: 7
- Average comments per issue: 2.5
- Average comments per pull request: 1.91
- Merged pull requests: 29
- Bot issues: 0
- Bot pull requests: 0
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
- dmitryduev (2)
- simeonreusch (1)
- stefanv (1)
- Theodlz (1)
- zvanderbosch (1)
Pull Request Authors
- Theodlz (19)
- dmitryduev (11)
- mcoughlin (2)
- lpsinger (2)
- bfhealy (2)
- simeonreusch (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 1,011 last-month
- Total dependent packages: 3
- Total dependent repositories: 21
- Total versions: 10
- Total maintainers: 3
pypi.org: penquins
A python client for Kowalski
- Homepage: https://github.com/dmitryduev/penquins
- Documentation: https://penquins.readthedocs.io/
- License: MIT
-
Latest release: 2.4.2
published over 1 year ago
Rankings
Maintainers (3)
Dependencies
- pymongo >=3.10.1
- pytest >=5.3.1
- requests >=2.25.0
- tqdm >=4.46.0
- actions/checkout v2 composite
- actions/setup-python v1 composite
- actions/checkout v2 composite
- actions/setup-python v2 composite
- pymongo >=3.10.1
- pytest >=5.3.1
- requests >=2.25.0
- tqdm >=4.46.0