# coding: utf-8

"""
    OurSky SDA

    The basic flow for a new organization is as follows: 1. View the available satellite targets with the [satellite targets](#tag/satellite-targets/GET/v1/satellite-targets) endpoint. Copy the id of the target you want to observe. 2. Create an organization target with the [organization target](#tag/organization-targets/GET/v1/organization-targets) endpoint. Use the id copied from above. 3. Create a webhook with the [webhook](#tag/webhooks/POST/v1/communications/webhook) endpoint to receive OSRs automatically (preferred) or use the [OSRs](#tag/observation-sequence-results/GET/v1/observation-sequence-results) endpoint to poll for OSRs.  Check out our [examples](https://github.com/ourskyai/oursky-examples) repository to see usage in each language.

    The version of the OpenAPI document: 1.3.9821
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from datetime import datetime
from typing import List, Optional, Union
from pydantic import BaseModel, Field, StrictBool, StrictFloat, StrictInt, conlist
from ourskyai_sda_api.models.observation_bounding_box import ObservationBoundingBox
from ourskyai_sda_api.models.v1_target_correlation import V1TargetCorrelation

class V1ObservationFeature(BaseModel):
    """
    Observation Feature  # noqa: E501
    """
    corrected_ra: Optional[Union[StrictFloat, StrictInt]] = Field(None, alias="correctedRa", description="EME2000 right ascension, corrected for stellar aberration [degrees]")
    corrected_dec: Optional[Union[StrictFloat, StrictInt]] = Field(None, alias="correctedDec", description="EME2000 declination, corrected for stellar aberration [degrees]")
    ra: Union[StrictFloat, StrictInt] = Field(..., description="the right ascension in degrees in EME2000 frame, not corrected for stellar aberration")
    dec: Union[StrictFloat, StrictInt] = Field(..., description="the declination in degrees in EME2000 frame, not corrected for stellar aberration")
    timestamp: datetime = Field(...)
    bounding_box: Optional[ObservationBoundingBox] = Field(None, alias="boundingBox")
    apparent_magnitude: Optional[Union[StrictFloat, StrictInt]] = Field(None, alias="apparentMagnitude", description="BETA: the apparent magnitude of the target at the time of the observation")
    apparent_magnitude_is_calibrated: Optional[StrictBool] = Field(None, alias="apparentMagnitudeIsCalibrated", description="indicates if the apparentMagnitude is calibrated against stars in the image, if enough were identified. If false, the apparentMagnitude is simply a flux conversion, still useful for light curves")
    distance_from_prediction: Optional[Union[StrictFloat, StrictInt]] = Field(None, alias="distanceFromPrediction", description="The distance from the predicted location in arcseconds (using SGP4 propagation)")
    target_correlations: Optional[conlist(V1TargetCorrelation)] = Field(None, alias="targetCorrelations")
    __properties = ["correctedRa", "correctedDec", "ra", "dec", "timestamp", "boundingBox", "apparentMagnitude", "apparentMagnitudeIsCalibrated", "distanceFromPrediction", "targetCorrelations"]

    class Config:
        """Pydantic configuration"""
        allow_population_by_field_name = True
        validate_assignment = True

    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.dict(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> V1ObservationFeature:
        """Create an instance of V1ObservationFeature from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True,
                          exclude={
                          },
                          exclude_none=True)
        # override the default output from pydantic by calling `to_dict()` of bounding_box
        if self.bounding_box:
            _dict['boundingBox'] = self.bounding_box.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in target_correlations (list)
        _items = []
        if self.target_correlations:
            for _item in self.target_correlations:
                if _item:
                    _items.append(_item.to_dict())
            _dict['targetCorrelations'] = _items
        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> V1ObservationFeature:
        """Create an instance of V1ObservationFeature from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return V1ObservationFeature.parse_obj(obj)

        _obj = V1ObservationFeature.parse_obj({
            "corrected_ra": obj.get("correctedRa"),
            "corrected_dec": obj.get("correctedDec"),
            "ra": obj.get("ra"),
            "dec": obj.get("dec"),
            "timestamp": obj.get("timestamp"),
            "bounding_box": ObservationBoundingBox.from_dict(obj.get("boundingBox")) if obj.get("boundingBox") is not None else None,
            "apparent_magnitude": obj.get("apparentMagnitude"),
            "apparent_magnitude_is_calibrated": obj.get("apparentMagnitudeIsCalibrated"),
            "distance_from_prediction": obj.get("distanceFromPrediction"),
            "target_correlations": [V1TargetCorrelation.from_dict(_item) for _item in obj.get("targetCorrelations")] if obj.get("targetCorrelations") is not None else None
        })
        return _obj


