mirar.processors.skyportal package
Central module for the skyportal integration
Submodules
mirar.processors.skyportal.client module
Client for interacting with Skyportal API
- class mirar.processors.skyportal.client.SkyportalClient(base_url: str = 'https://fritz.science/api/')[source]
Bases:
objectBasic Skyportal client class for executing functions
- api(method: str, endpoint: str, data: Mapping | None = None) Response[source]
Make an API call to a SkyPortal instance
headers = {‘Authorization’: f’token {self.token}’} response = requests.request(method, endpoint, json_dict=data, headers=headers)
- Parameters:
method – HTTP method
endpoint – API endpoint
data – JSON data to send
- Returns:
response from API call
mirar.processors.skyportal.skyportal_candidate module
Module for sending candidates to Fritz.
- class mirar.processors.skyportal.skyportal_candidate.SkyportalCandidateUploader(*args, stream_id: int, fritz_filter_id: int, annotation_keys: list[str] | None = None, **kwargs)[source]
Bases:
SkyportalSourceUploaderProcessor for sending candidates to Fritz.
- description() str[source]
Return a description of the processor
- Returns:
A description of the processor
- export_to_skyportal(alert)[source]
Posts a candidate to SkyPortal.
- Parameters:
alert (_type_) – _description_
- get_annotations(alert) dict[source]
Retrieve annotations from alert data.
- Parameters:
alert – Alert data
- Returns:
Annotations
- skyportal_post_annotation(alert)[source]
Post an annotation. Works for both candidates and sources.
- Parameters:
alert – alert data
- Returns:
None
mirar.processors.skyportal.skyportal_source module
Module for sending sources to Fritz.
- class mirar.processors.skyportal.skyportal_source.SkyportalSourceUploader(origin: str, group_ids: list[int], instrument_id: int, update_thumbnails: bool = False, skyportal_client: ~mirar.processors.skyportal.client.SkyportalClient | None = <mirar.processors.skyportal.client.SkyportalClient object>)[source]
Bases:
BaseSourceProcessorProcessor for sending source photometry to Skyportal.
- api(method: str, endpoint: str, data: Mapping | None = None) Response[source]
Make an API call to a SkyPortal instance
headers = {‘Authorization’: f’token {self.token}’} response = requests.request(method, endpoint, json_dict=data, headers=headers)
- Parameters:
method – HTTP method
endpoint – API endpoint e.g sources
data – JSON data to send
- Returns:
response from API call
- base_key = 'skyportalsender'
- description() str[source]
Return a description of the processor
- Returns:
A description of the processor
- export_to_skyportal(alert)[source]
Posts a source to SkyPortal.
- Parameters:
alert (_type_) – _description_
- make_photometry(source: Series) DataFrame[source]
Make a de-duplicated pandas.DataFrame with photometry of alert[CAND_NAME_KEY] Modified from Kowalksi (https://github.com/dmitryduev/kowalski)
- Parameters:
source – source row
- Returns:
pandas.DataFrame with photometry
- make_thumbnail(source: Series, skyportal_type: str, alert_packet_type: str)[source]
Convert lossless FITS cutouts from ZTF-like alerts into PNGs. Make thumbnail for pushing to SkyPortal.
- Parameters:
source – ZTF-like alert packet/dict
skyportal_type – <new|ref|sub> thumbnail type expected by SkyPortal
alert_packet_type – <Science|Template|Difference> survey naming
- Returns:
- skyportal_post_source(alert: dict, group_ids: list[int] | None = None)[source]
Add a new source to SkyPortal
- Parameters:
alert – dict of source info
group_ids – list of group_ids to post source to, defaults to None
- Returns:
None
mirar.processors.skyportal.thumbnail module
Function for converting a FITS image to a skyportal “thumbnail”.
- mirar.processors.skyportal.thumbnail.make_thumbnail(image_data: ndarray, linear_stretch: bool = False) str[source]
Util function to convert a FITS image to a PNG image
Skyportal requires, to quote the API:
base64-encoded PNG image file contents. Image size must be between 16px and 500px on a side.
- Parameters:
image_data – Image data
linear_stretch – boolean whether to use a linear stretch (default is log)
- Returns:
Skyportal-compliant PNG image string