Skip to main content

Python SDK for the MMDC astrophysics platform (mmdc.am)

Project description

astro-mmdc

Python SDK for the MMDC astrophysics platform — access SED data preparation and blazar broadband emission modeling APIs.

Installation

pip install astro-mmdc
# or
uv pip install astro-mmdc

Quick Start

SED Data Preparation

from astro_mmdc import MMDC

client = MMDC()

# Submit SED preparation job and wait for completion
job = client.sed.prepare_and_wait(
    ra=187.28, dec=2.05, database_name="3C273", source_name="3C 273"
)
print(f"Job {job.uuid} finished with status: {job.status}")

# Retrieve frequency/flux data
data = client.sed.get_data(job.uuid)

# Get source metadata
info = client.sed.get_info(job.uuid)
print(f"Redshift: {info.redshift}")

# Download as CSV
client.sed.download_csv(job.uuid, "sed_data.csv")

Batch Modeling

from astro_mmdc import MMDC

client = MMDC()

# Submit and wait for SSC model fit
result = client.modeling.batch_infer(
    "observations.csv",
    z=0.158,
    ebl=True,
    model_type="SSC",
)
print(f"PDF report: {result.pdf_link}")
print(f"Best parameters: {result.best_parameters}")

# Or submit without waiting
submission = client.modeling.submit_batch(
    "observations.csv", z=0.158, ebl=True, model_type="SSC"
)
# ... do other work ...
result = client.modeling.wait_for_batch(submission.batch_result_id)

HADRONIC Model with Neutrino Parameters

result = client.modeling.batch_infer(
    "observations.csv",
    z=1.0,
    ebl=True,
    model_type="HADRONIC",
    likelihood_type="poisson",
    n_icecube=3,
    dt=12.0,  # months
)

CSV Validation

validation = client.modeling.validate_csv("observations.csv")
if validation.success:
    print(f"{validation.data_points} data points, ready for modeling")

Configuration

# Custom base URL (e.g., local development)
client = MMDC(base_url="http://localhost:8000")

# Custom timeout
client = MMDC(timeout=60.0)

# Context manager (auto-closes connection)
with MMDC() as client:
    data = client.sed.get_data("some-uuid")

Error Handling

from astro_mmdc import MMDC, APIError, ValidationError, PollingTimeoutError, NotFoundError

client = MMDC()

try:
    result = client.modeling.batch_infer("data.csv", z=0.5, ebl=True, model_type="SSC")
except ValidationError as e:
    print(f"CSV validation failed: {e} (type: {e.validation_type})")
except PollingTimeoutError:
    print("Job took too long")
except NotFoundError:
    print("Resource not found")
except APIError as e:
    print(f"API error {e.status_code}: {e.detail}")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

astro_mmdc-0.1.0.tar.gz (29.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

astro_mmdc-0.1.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file astro_mmdc-0.1.0.tar.gz.

File metadata

  • Download URL: astro_mmdc-0.1.0.tar.gz
  • Upload date:
  • Size: 29.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for astro_mmdc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2302d584ad109255b9ac65bf4cbb812b535597d3ea92c01e8caa4cd1ae6a5879
MD5 b2be8c7d8d90c6ea16a6d2f26a85a82f
BLAKE2b-256 5aae6b89910db2fb6827a575641877a11930e957297890384540f37447cfa8b5

See more details on using hashes here.

File details

Details for the file astro_mmdc-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: astro_mmdc-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for astro_mmdc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d6a54ba23820f38e3a3bff1abe580facbd6515ed612e455613ff99450b6f9051
MD5 e0d0716774ebaede7fe0722a5f4fc49d
BLAKE2b-256 a80f567c6e8170e706dbe49b076b7eacc4cb43725c4101e0c47bf0684fbc38bf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page