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
- type Client
- func (c *Client) Get(ctx context.Context, rawURL string) ([]byte, error)
- func (c *Client) NearestObjects(ctx context.Context, ra, dec, radius float64, limit int) ([]*PhotoObject, error)
- func (c *Client) QuerySQL(ctx context.Context, sql string) ([]map[string]json.RawMessage, error)
- func (c *Client) SearchPhotometry(ctx context.Context, minMag, maxMag float64, limit int) ([]*PhotoObject, error)
- func (c *Client) SearchSpectra(ctx context.Context, class string, minZ, maxZ float64, limit int) ([]*Spectrum, error)
- type Domain
- type PhotoObject
- type Spectrum
Constants ¶
const DefaultUserAgent = "sdss-cli/dev (+https://github.com/tamnd/sdss-cli)"
DefaultUserAgent identifies the client to SDSS.
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 ¶
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 ¶
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.
type Domain ¶
type Domain struct{}
Domain is the SDSS driver. It carries no state.
func (Domain) Classify ¶
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.
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.