-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from LCOGT/feature/implement_median
Feature/implement median
- Loading branch information
Showing
4 changed files
with
122 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import requests | ||
import logging | ||
|
||
import boto3 | ||
|
||
from django.conf import settings | ||
|
||
log = logging.getLogger() | ||
log.setLevel(logging.INFO) | ||
|
||
def store_fits_output(item_key: str, fits_buffer: object) -> object: | ||
""" | ||
Stores a fits into the operation bucket in S3 | ||
Keyword Arguements: | ||
item_key -- name under which to store the fits file | ||
fits_buffer -- the fits file to add to the bucket | ||
""" | ||
log.info(f'Adding {item_key} to {settings.DATALAB_OPERATION_BUCKET}') | ||
|
||
s3 = boto3.resource('s3') | ||
response = s3.Bucket(settings.DATALAB_OPERATION_BUCKET).put_object(Key = item_key, Body = fits_buffer.getvalue()) | ||
return response | ||
|
||
def get_archive_from_basename(basename: str) -> dict: | ||
""" | ||
Queries and returns an archive file from the Archive | ||
Keyword Arguements: | ||
basename -- name to query | ||
""" | ||
query_params = {'basename_exact': basename } | ||
|
||
response = requests.get(settings.ARCHIVE_API + '/frames/', params=query_params) | ||
|
||
try: | ||
image_data = response.json() | ||
results = image_data.get('results', None) | ||
except IndexError: | ||
log.error(f"No image found with specified basename: {basename}") | ||
raise FileNotFoundError | ||
|
||
return results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters