Example #1
0
from penquins import Kowalski
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm

import astropy.stats
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
import io

import optparse
__version__ = 0.1

user, password = '******', 'PrettyStr0ngPa$$w0rd'

k = Kowalski(username=user, password=password)

connection_ok = k.check_connection()
if not connection_ok:
    raise KowalskiError('not connected to Kowalski DB')
print(f'Connection OK: {connection_ok}')

collection_ZTF_alerts = 'ZTF_alerts'
collection_ZTF_alerts_aux = 'ZTF_alerts_aux'


def get_radec(n):
    q = {
        "query_type": "find",
        "query": {
            "catalog": collection_ZTF_alerts,
            "filter": {
                "objectId": n
Example #2
0
    else:
        list_fields = np.arange(156,1900)

    # Send a warning if you need to have admin permissions
    if args.doWriteDb:
        print("WARNING! You activated a flag to write information \
into the database. If you are admin, this means that the database \
will be updated with the results of your queries.") 

    # Read the secrets
    secrets = ascii.read('./secrets.csv', format = 'csv')
    username = secrets['kowalski_user'][0]
    password = secrets['kowalski_pwd'][0]

    kow = Kowalski(username=username, password=password)
    connection_ok = kow.check_connection()
    if not connection_ok:
        raise KowalskiError('not connected to Kowalski DB')
    print(f'Connection to Kowalski OK: {connection_ok}')

    # Iterate over a certain date range
    if args.date_start is None:
        date_start = Time.now() - datetime.timedelta(days=1)
    else:
        try:
            date_start = Time(args.date_start, format='iso')
        except ValueError:
            print("Invalid start date. It must be a string in ISO format.")
            print("Example: '2017-08-17 12:41:04.4'")
            exit()