Package: aphos-openapi
APhoS client for retrieving data in PythonThis 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.htmlOpenapi json or yaml file (documentation of api):https://aphos.cerit-sc.cz/openapiInstallationPackage:aphos-openapiInstall:pip install aphos-openapiUpgrade:pip install aphos-openapi --upgrade(If you have pip3 instead of pip, just use pip3)ContentsReferences work only in github:https://github.com/pavel-kinc/aphos-client/blob/main/README.mdBasic infoInstallationRequirementsBasic usageCoordinates usageGraphData usageSupportFunctionsApi modelsRequirementsPython >=3.8,'urllib3'>=1.25.3,'python-dateutil','matplotlib','astropy'Usage Api modelsfrom 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 CoordinatesMore 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 GraphDataMain methods:constructorto_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 periodSupportpavelkinc230@gmail.comAdditional information for functions and models of this packageDocumentation For Functionsget_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 objectcatalog - catalog of the space objectget_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 objectcatalog - catalog of space objectsname - name of space objectscoordinates - coordinatesmin_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 starcomparison_id - id of comparison starvar_catalog - catalog of variable starcmp_catalog - catalog of comparison starget_user(username: str)-> Optional[User]Get user by username.Returns: User (username and description).Params:username - username of a userset_var_cmp_apertures(comparison: ComparisonObject,night: Optional[date] = None,var: Optional[int] = None,cmp: Optional[int] = None)-> NoneSets apertures based on night and desired indexes in comparison object and recalculates magnitude and deviation.Params:comparison - ComparisonObject - object to which the apertures are setnight - 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 resolvedupload_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 filesinfo() -> NonePrints 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.mdComparisonObjectErrorMessageFluxFluxDataNightPhotoPropertiesSpaceObjectSpaceObjectWithFluxesUserComparisonObjectPropertiesNameTypeDescriptionNotesvariableSpaceObjectcomparisonSpaceObjectdata[FluxData][Back to Model list]ErrorMessagePropertiesNameTypeDescriptionNotesidstr[optional]messagestr[optional][Back to Model list]FluxPropertiesNameTypeDescriptionNotesright_ascstrdeclinationstradded_bystrap_autofloatapertures[float]photoPhotoPropertiesap_auto_devfloataperture_devs[float][Back to Model list]FluxDataPropertiesNameTypeDescriptionNotesright_ascstrdecstrap_autostrap_auto_devfloatapertures[str]aperture_devs[float]magnitudefloatdeviationfloatusernamestrnightNightexp_middlestrcmp_ap_autostrcmp_ap_auto_devfloatcmp_apertures[str]cmp_aperture_devs[float][Back to Model list]NightPropertiesNameTypeDescriptionNotesfirst_date_of_the_nightstrsecond_date_of_the_nightstrap_to_be_usedstrcmp_ap_to_be_usedstr[Back to Model list]PhotoPropertiesPropertiesNameTypeDescriptionNotesexposure_begindatetimeexposure_enddatetime[Back to Model list]SpaceObjectPropertiesNameTypeDescriptionNotesidstrcatalogstrnamestrright_ascstrdeclinationstrmagnitudefloatfluxes_countint[Back to Model list]SpaceObjectWithFluxesExtends SpaceObject by fluxes.PropertiesNameTypeDescriptionNotesfluxes[Flux]Additional field compared to SpaceObjectidstrcatalogstrnamestrright_ascstrdeclinationstrmagnitudefloatfluxes_countint[Back to Model list]UserPropertiesNameTypeDescriptionNotesusernamestrUniquedescriptionstr[Back to Model list]