sdss

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package sdss is the library behind the sdss command line: the HTTP client, request shaping, and the typed data models for the Sloan Digital Sky Survey (SDSS DR18).

The Client sets a real User-Agent, paces requests so a busy session stays polite, and retries transient failures (429 and 5xx). Build your SQL and catalog searches on top of it.

Index

Constants

View Source
const DefaultUserAgent = "sdss-cli/dev (+https://github.com/tamnd/sdss-cli)"

DefaultUserAgent identifies the client to SDSS.

View Source
const Host = "skyserver.sdss.org"

Host is the site this client talks to.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	HTTP      *http.Client
	UserAgent string
	// Rate is the minimum gap between requests. Zero means no pacing.
	Rate    time.Duration
	Retries int
	// contains filtered or unexported fields
}

Client talks to the SDSS SkyServer over HTTP.

func NewClient

func NewClient() *Client

NewClient returns a Client with sensible defaults: a 30s timeout, a 500ms minimum gap between requests (SDSS can be slow), and 3 retries.

func (*Client) Get

func (c *Client) Get(ctx context.Context, rawURL string) ([]byte, error)

Get fetches the given URL and returns the response body. It paces and retries according to the client's settings.

func (*Client) NearestObjects

func (c *Client) NearestObjects(ctx context.Context, ra, dec, radius float64, limit int) ([]*PhotoObject, error)

NearestObjects returns photometric objects within radius arcminutes of the given (ra, dec) sky coordinates using the SDSS cone-search table function.

func (*Client) QuerySQL

func (c *Client) QuerySQL(ctx context.Context, sql string) ([]map[string]json.RawMessage, error)

QuerySQL runs an arbitrary SQL query against the SDSS SkyServer and returns the rows from the first table (Table1) as raw JSON maps. The caller is responsible for unmarshalling each row into its own type.

func (*Client) SearchPhotometry

func (c *Client) SearchPhotometry(ctx context.Context, minMag, maxMag float64, limit int) ([]*PhotoObject, error)

SearchPhotometry queries the PhotoObj table for sources with R-band magnitude between minMag and maxMag, returning at most limit records.

func (*Client) SearchSpectra

func (c *Client) SearchSpectra(ctx context.Context, class string, minZ, maxZ float64, limit int) ([]*Spectrum, error)

SearchSpectra queries the SpecObj table for spectra of the given class (GALAXY, QSO, or STAR) with redshift between minZ and maxZ.

type Domain

type Domain struct{}

Domain is the SDSS driver. It carries no state.

func (Domain) Classify

func (Domain) Classify(input string) (uriType, id string, err error)

Classify turns any non-empty input into ("object", input), since SDSS does not have a canonical URI scheme beyond object IDs.

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate returns the SDSS SkyServer detail URL for a given object ID.

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

type PhotoObject

type PhotoObject struct {
	ID   string  `json:"id"           kit:"id"`
	RA   float64 `json:"ra"`
	Dec  float64 `json:"dec"`
	Type string  `json:"type"`
	MagR float64 `json:"mag_r,omitempty"`
	MagG float64 `json:"mag_g,omitempty"`
	MagU float64 `json:"mag_u,omitempty"`
	MagI float64 `json:"mag_i,omitempty"`
	MagZ float64 `json:"mag_z,omitempty"`
}

PhotoObject is a photometrically detected object in the SDSS catalog.

type Spectrum

type Spectrum struct {
	ID       string  `json:"id"               kit:"id"`
	RA       float64 `json:"ra"`
	Dec      float64 `json:"dec"`
	Redshift float64 `json:"redshift,omitempty"`
	Class    string  `json:"class,omitempty"`
	SubClass string  `json:"subclass,omitempty"`
}

Spectrum is a spectroscopically observed object in the SDSS catalog.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL