Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'https://si.src.skach.org/argus/' is available in Karabo. #515

Open
kenfus opened this issue Sep 15, 2023 · 0 comments
Open

'https://si.src.skach.org/argus/' is available in Karabo. #515

kenfus opened this issue Sep 15, 2023 · 0 comments
Assignees
Labels
cscs Things concerning CSCS Swiss National Supercomputing Centre enhancement New feature or request prio-high High priority

Comments

@kenfus
Copy link
Member

kenfus commented Sep 15, 2023

Currently, code to access the data looks like this:

import os
import re
import requests
import pyvo as vo

# Initialize the TAP service
tap_service_url = 'https://si.src.skach.org/argus/'  # Replace with your TAP service URL


def get_filename(response):
    """
    Get filename from the HTTP response headers.
    """
    return re.findall("filename=\"(.+)\"", response.headers['content-disposition'])[0]

tap_service = vo.dal.TAPService(tap_service_url)

query = """
SELECT TOP 1 obs_publisher_did FROM ivoa.ObsCore
"""
resultset = tap_service.search(query)
for row in resultset:
    for record in row.getdatalink():
        print('Object: ', record.id, ' URL: ', record.getdataurl(), ' Size: ', record.content_length)
        response = requests.get(record.getdataurl())
        if response.status_code == 200:
            #print('Dataset headers: ', record.getdataset().headers)
            filename = get_filename(response)
            print('Downloaded file: ', filename)
            open(filename, 'wb').write(response.content)
        else:
            print(f"Failed to download data: {response.status_code}\nHeaders: {response.headers}")
    print()

It should be easy to wrap those function into karabo.

@kenfus kenfus added enhancement New feature or request prio-high High priority cscs Things concerning CSCS Swiss National Supercomputing Centre labels Sep 15, 2023
@kenfus kenfus self-assigned this Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cscs Things concerning CSCS Swiss National Supercomputing Centre enhancement New feature or request prio-high High priority
Projects
None yet
Development

No branches or pull requests

1 participant