SWXSOCClient

class swxsoc.net.client.SWXSOCClient[source]

Bases: BaseClient

Client for searching for SWXSOC data on AWS. This client provides search and fetch functionality for SWXSOC data and is based on the sunpy BaseClient for FIDO.

For more information on the sunpy BaseClient, see: https://docs.sunpy.org/en/stable/generated/api/sunpy.net.base_client.BaseClient.html

Note that AWS buckets may require access keys.

Examples

>>> from swxsoc.net.attr import AttrAnd, SearchTime, Level, Descriptor, Instrument
>>> from swxsoc.net.client import SWXSOCClient
>>> from astropy.time import Time
>>> client = SWXSOCClient()
>>> query = AttrAnd([SearchTime(start=Time("2025-07-10T00:00:00"), end=Time("2025-07-11T00:00:00")),
...    Instrument("meddea"),
...    Level("l0"),
...    Descriptor("housekeeping")])
>>> results = client.search(query)  

Attributes Summary

size_column

Methods Summary

fetch(query_results, *, path, downloader, ...)

Fetches the files based on query results and queues them up to be downloaded to the specified path by your downloader.

generate_prefixes(levels, start_time, ...)

Generates a list of prefixes based on the level and time range.

generate_presigned_url(bucket_name, object_key)

Generates a presigned URL for accessing an object in S3.

list_files_in_s3(bucket_names)

Lists all files in the specified S3 buckets.

search([query])

Searches for data based on the given query.

Attributes Documentation

size_column = 'size'

Methods Documentation

fetch(query_results, *, path, downloader, **kwargs)[source]

Fetches the files based on query results and queues them up to be downloaded to the specified path by your downloader.

Note: The downloader must be an instance of parfive.Downloader

Parameters:
  • query_results (list) – The results of the search query.

  • path (str) – The directory path where files should be saved.

  • downloader (Downloader) – The parfive downloader instance used for fetching files.

static generate_prefixes(levels: list, start_time: str, end_time: str, descriptor: str) list[source]

Generates a list of prefixes based on the level and time range.

Parameters:
  • levels (list) – A list of data levels.

  • start_time (str) – The start time in ISO format.

  • end_time (str) – The end time in ISO format.

  • descriptor (str) – The file descriptor

Returns:

list – A list of prefixes.

static generate_presigned_url(bucket_name, object_key, expiration=3600)[source]

Generates a presigned URL for accessing an object in S3. If credentials are not available or access is denied, attempts an unsigned request for public access.

Parameters:
  • bucket_name (str) – The name of the S3 bucket.

  • object_key (str) – The key of the S3 object.

  • expiration (int, optional) – The expiration time in seconds for the presigned URL. Default is 3600 seconds.

Returns:

str or None – The presigned URL if successful, or a direct unsigned URL if public access is allowed. Otherwise, returns None.

static list_files_in_s3(bucket_names: list) list[source]

Lists all files in the specified S3 buckets. If access is denied, it retries with an unsigned request.

Parameters:

bucket_names (list) – A list of S3 bucket names.

Returns:

list – A list of dictionaries containing metadata about each S3 object.

search(query=None)[source]

Searches for data based on the given query.

Parameters:

query (AttrAnd) – The query object specifying search criteria.

Returns:

QueryResponseTable – A table containing the search results.