Skip to main content

APhoS Python library for data representation

Project description

APhoS client for retrieving data in Python

This is Amateur Photometric Survey (APhoS) client for web application.
Contains documentation about modules, models and functions for working with astronomical data from APhoS database.
Server is accessible from: https://aphos.cerit-sc.cz/
Swagger UI (Interface for api of the server): https://aphos.cerit-sc.cz/swagger-ui/index.html
Openapi json or yaml file (documentation of api): https://aphos.cerit-sc.cz/openapi

Installation

Package: aphos-openapi

Install: pip install aphos-openapi
Upgrade: pip install aphos-openapi --upgrade

(If you have pip3 instead of pip, just use pip3)

Contents

References work only in github: https://github.com/pavel-kinc/aphos-client/blob/main/README.md

Requirements

  • Python >=3.8,
  • 'urllib3'>=1.25.3,
  • 'python-dateutil',
  • 'matplotlib',
  • 'astropy'

Usage Api models

from aphos_openapi import aphos
import datetime  # for setting apertures
from pprint import pprint  # pretty print for objects

def my_function():

    """
    Basic usage, info, get_objects_by_params, get_object
    """
    aphos.info()  # prints basic info about aphos_openapi package
    objects = aphos.get_objects_by_params(name="GK Cep") # gets objects which match the name
    if objects:
        print(objects[0].magnitude) # prints magnitude of first found object
    # pprint(objects[0])
    list_of_stars = aphos.get_objects_by_params()  # gets 100 space objects from database
    star = aphos.get_object("605-025126", "UCAC4")  # gets space object with fluxes

    """
    get_var_cmp_by_ids, set_var_cmp_apertures, resolve_name_aphos
    """
    if star is not None:
        comparison = aphos.get_var_cmp_by_ids(star.id, "604-024943", star.catalog, "UCAC4")
        pprint(comparison.variable)
        # pprint(comparison.data[0])
        if comparison is not None:
            date = datetime.date(2022,1, 6)  # first day of night we want to change apertures
            aphos.set_var_cmp_apertures(comparison, date, 3, 3)
            # pprint(comparison.data[0])
            aphos.set_var_cmp_apertures(comparison)  # back to auto apertures
            # pprint(comparison)
            
    potential_stars = aphos.resolve_name_aphos("V* FU Aur")
    if potential_stars:
        star = potential_stars[0]
        print(f"{star.id} {star.catalog} {str(star.magnitude)}")


if __name__ == '__main__':
    my_function()

Usage Coordinates

More info about object in package.

from aphos_openapi import aphos
from aphos_openapi.models.coordinates import Coordinates
from astropy.coordinates import SkyCoord
from pprint import pprint  # pretty print for objects

"""
Coordinates can take astropy.coordinates SkyCoord or other strings format listed below.
If units are present in string, unit will be ignored.
Radius is float, and you can choose unit by 'm' or 's', otherwise it will be degrees.

Coordinates below are more or less equal, more in class documentation.
"""
coords1 = Coordinates("21h41m55.291s +71d18m41.12s", 8, radius_unit='m')
coords2 = Coordinates("21 41 55.291 +71 18 41.12", 0.1333333)  # default unit for RA is hour
coords3 = Coordinates(SkyCoord("21h41m55.291s +71d18m41.12s"), 0.1333333)
coords4 = Coordinates("21.698691944444448h +71.31142223d", 0.1333333)
coords5 = Coordinates("21:41:55.291 +71:18:41.12", 0.1333333)
coords6 = Coordinates("325.48037916666664d +71.31142223d", 0.1333333)
coords7 = Coordinates("325 28 49.365 +71 18 41.12", 8, 'd', 'm')

space_objects = aphos.get_objects_by_params(coordinates=coords7)
pprint(space_objects)

Usage GraphData

Main methods:

  • constructor
  • to_file()
  • graph()
  • composite_graph()
  • phase_graph()

More info about methods in package.

from aphos_openapi import aphos
from aphos_openapi.models.graph_data import GraphData
from pprint import pprint  # pretty print for objects

var_cmp = aphos.get_var_cmp_by_ids("605-025126", "604-024943")
if var_cmp is not None:
    data = GraphData(var_cmp)  # create GraphData object from Comparison
    # pprint(data)
    data.graph()  # matplotlib graph
    data.to_file("path/to/file.csv")  # saves data to file
data_from_file = GraphData("path/to/file.csv")  # create GraphData from file
pprint(f"{data_from_file.variable} {data_from_file.comparison}")
pprint(data_from_file.data_list[0])  # print how 1 row of data looks like
data_from_file.composite_graph()
data_from_file.phase_graph(2455957.5, 1.209373)  # start of epoch and period

Support

pavelkinc230@gmail.com

Additional information for functions and models of this package

Documentation For Functions

get_catalogs() -> Optional[List[str]]

Get all available catalogs from APhoS.
Returns: List of available catalogs (strings).

get_object(
object_id: str,
catalog: str = DEFAULT_CATALOG)
-> Optional[SpaceObjectWithFluxes]

Get object from APhoS based on parameters.
Returns: SpaceObjectWithFluxes or None if there is no such object.
Params:
 object_id - object id of the space object
 catalog - catalog of the space object

get_objects_by_params(
object_id: Optional[str] = None,
catalog: Optional[str] = None,
name: Optional[str] = None,
coordinates: Optional[Coordinates] = None,
min_mag: Union[str, float, None] = None,
max_mag: Union[str, float, None] = None)
-> Optional[list[SpaceObject]]

Get space objects based on multiple parameters, where every can be None.
Returns: List of space objects.
Params:
 object_id - object id of the space object
 catalog - catalog of space objects
 name - name of space objects
 coordinates - coordinates
 min_mag - minimum magnitude (0 and more)
 max_mag - maximum magnitude (20 and less)

get_var_cmp_by_ids(
variable_id: str,
comparison_id: str,
var_catalog: str = DEFAULT_CATALOG,
cmp_catalog: str = DEFAULT_CATALOG)
-> Optional[ComparisonObject]

Get Comparison object of variable star (space object) and comparison star based on IDs.
Returns: Data about objects and fluxes.
Params:
 variable_id - id of variable star
 comparison_id - id of comparison star
 var_catalog - catalog of variable star
 cmp_catalog - catalog of comparison star

get_user(
username: str)
-> Optional[User]

Get user by username.
Returns: User (username and description).
Params:
 username - username of a user

set_var_cmp_apertures(
comparison: ComparisonObject,
night: Optional[date] = None,
var: Optional[int] = None,
cmp: Optional[int] = None)
-> None

Sets apertures based on night and desired indexes in comparison object and recalculates magnitude and deviation.
Params:
 comparison - ComparisonObject - object to which the apertures are set
 night - night to which the apertures are changing (None is all nights)
 var - target index of aperture to set (from variable star)
 cmp - target index of aperture to set (from comparison star)

resolve_name_aphos(
name: str)
-> Optional[list[SpaceObject]]

Resolve name based on astropy name resolver and tries to find equal potential objects in APhoS database (Cross-identification).
Returns: List of space objects which are potentially equal to given name, from all catalogs.
Params:
 name - any name by which a space object can be resolved

upload_files(
path: str)
-> list[tuple[str, bool, str]]

!!! HIDDEN FOR NOW !!!

Upload files as Anonymous user. Files are in format csv, with delimiter ';', generated from SIPS software. For authenticated upload use website -> info().
Returns: List of tuple (file, success of upload of the given file, info about upload).
Params:
 path - path to file or directory with files

info() -> None

Prints useful documentation and info about this package.

Object's methods are documented in package and in usage.

Documentation For Models

(Api models only, mostly genereated) References work only in github: https://github.com/pavel-kinc/aphos-client/blob/main/README.md

ComparisonObject

Properties

Name Type Description Notes
variable SpaceObject
comparison SpaceObject
data [FluxData]

[Back to Model list]

ErrorMessage

Properties

Name Type Description Notes
id str [optional]
message str [optional]

[Back to Model list]

Flux

Properties

Name Type Description Notes
right_asc str
declination str
added_by str
ap_auto float
apertures [float]
photo PhotoProperties
ap_auto_dev float
aperture_devs [float]

[Back to Model list]

FluxData

Properties

Name Type Description Notes
right_asc str
dec str
ap_auto str
ap_auto_dev float
apertures [str]
aperture_devs [float]
magnitude float
deviation float
username str
night Night
exp_middle str
cmp_ap_auto str
cmp_ap_auto_dev float
cmp_apertures [str]
cmp_aperture_devs [float]

[Back to Model list]

Night

Properties

Name Type Description Notes
first_date_of_the_night str
second_date_of_the_night str
ap_to_be_used str
cmp_ap_to_be_used str

[Back to Model list]

PhotoProperties

Properties

Name Type Description Notes
exposure_begin datetime
exposure_end datetime

[Back to Model list]

SpaceObject

Properties

Name Type Description Notes
id str
catalog str
name str
right_asc str
declination str
magnitude float
fluxes_count int

[Back to Model list]

SpaceObjectWithFluxes

Extends SpaceObject by fluxes.

Properties

Name Type Description Notes
fluxes [Flux] Additional field compared to SpaceObject
id str
catalog str
name str
right_asc str
declination str
magnitude float
fluxes_count int

[Back to Model list]

User

Properties

Name Type Description Notes
username str Unique
description str

[Back to Model list]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aphos_openapi-2.5.3.tar.gz (61.6 kB view details)

Uploaded Source

Built Distribution

aphos_openapi-2.5.3-py3-none-any.whl (88.5 kB view details)

Uploaded Python 3

File details

Details for the file aphos_openapi-2.5.3.tar.gz.

File metadata

  • Download URL: aphos_openapi-2.5.3.tar.gz
  • Upload date:
  • Size: 61.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for aphos_openapi-2.5.3.tar.gz
Algorithm Hash digest
SHA256 f2a14a54b8079a3371b1654e4c9ecf6be18106bcf8887d2612aec2df4e1b1cbe
MD5 96fade9d6dbd7483a7ec06d913f8276a
BLAKE2b-256 af0c27619a681892cf4cdd3e11a0545ce2629be125f1628496af7d058b985f7b

See more details on using hashes here.

File details

Details for the file aphos_openapi-2.5.3-py3-none-any.whl.

File metadata

File hashes

Hashes for aphos_openapi-2.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1d0b5198a1b426238c4178eb629d50a5a65cc5049ce866e479d0a51452ff9a40
MD5 685110e9c43a9b86c8326cf294c2f4f4
BLAKE2b-256 2716f7b7d3132a24a59204a6a550a359a01a20d8c9a5bc4df9fb11540c498d86

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page