import numpy as np import matplotlib.pyplot as plt from matplotlib.collections import PolyCollection from astropy.time import Time from spherical_geometry.polygon import SphericalPolygon, great_circle_arc, vector from catch import Catch, Config, model from sbsearch.core import line_to_segment_query_terms from sbsearch.spatial import term_to_cell_vertices target = '65P' dates = ('2017-07-15', '2017-08-15') #dates = ('2017-01-01', '2017-12-31') #dates = ('2014-03-15', '2018-03-15') view = (10, -110) # elevation, azimuth for 3D plot config = Config(database='postgresql://@/catch_dev', log='/dev/null', debug=True) file_suffix = (f'{target.lower().replace(" ", "").replace("/", "")}' f'-{dates[0].replace("-", "")}' f'-{dates[1].replace("-", "")}') with Catch.with_config(config) as catch: # get 65P query terms for Jul/Aug 2017 comet = catch.get_designation(target) eph = comet.ephemeris(model.SkyMapper, start=Time(dates[0]), stop=Time(dates[1])) ra = np.array([e.ra for e in eph]) dec = np.array([e.dec for e in eph])
from catch import Catch, Config from env import ENV # Build URI and instantiate data-provider service db_engine_URI: str = ( f"{ENV.DB_DIALECT}://{ENV.DB_USERNAME}:{ENV.DB_PASSWORD}@{ENV.DB_HOST}" f"/{ENV.DB_DATABASE}") db_engine: Engine = sqlalchemy.create_engine(db_engine_URI, poolclass=NullPool, pool_recycle=3600, pool_pre_ping=True) db_session: scoped_session = scoped_session(sessionmaker(bind=db_engine)) # catch library configuration catch_config: Config = Config(log=ENV.CATCH_LOG) @contextmanager def data_provider_session() -> Iterator[Session]: """Provide a transactional scope around a series of operations.""" session: Session = db_session() try: yield session session.commit() except (SQLAlchemyError, DBAPIError): session.rollback() raise finally: db_session.remove()