This documentation is for astroML version 0.2

This page


astroML Mailing List

GitHub Issue Tracker


Scipy 2012 (15 minute talk)

Scipy 2013 (20 minute talk)


If you use the software, please consider citing astroML.

11.4.12. astroML.datasets.fetch_imaging_sample

astroML.datasets.fetch_imaging_sample(data_home=None, download_if_missing=True)

Loader for SDSS Imaging sample data

Parameters :

data_home : optional, default=None

Specify another download and cache folder for the datasets. By default all scikit learn data is stored in ‘~/astroML_data’ subfolders.

download_if_missing : optional, default=True

If False, raise a IOError if the data is not locally available instead of trying to download the data from the source site.

Returns :

data : recarray, shape = (330753,)

record array containing imaging data


This data was selected from the SDSS database using the following SQL query:

  round(p.ra,6) as ra, round(p.dec,6) as dec,,                              --- comments are preceded by ---
  round(p.extinction_r,3) as rExtSFD, --- r band extinction from SFD
  round(p.modelMag_u,3) as uRaw,      --- ISM-uncorrected model mags
  round(p.modelMag_g,3) as gRaw,      --- rounding up model magnitudes
  round(p.modelMag_r,3) as rRaw,
  round(p.modelMag_i,3) as iRaw,
  round(p.modelMag_z,3) as zRaw,
  round(p.modelMagErr_u,3) as uErr,   --- errors are important!
  round(p.modelMagErr_g,3) as gErr,
  round(p.modelMagErr_r,3) as rErr,
  round(p.modelMagErr_i,3) as iErr,
  round(p.modelMagErr_z,3) as zErr,
  round(p.psfMag_u,3) as psfRaw,      --- psf magnitudes
  round(p.psfMag_g,3) as psfRaw,
  round(p.psfMag_r,3) as psfRaw,
  round(p.psfMag_i,3) as psfRaw,
  round(p.psfMag_z,3) as psfRaw,
  round(p.psfMagErr_u,3) as psfuErr,
  round(p.psfMagErr_g,3) as psfgErr,
  round(p.psfMagErr_r,3) as psfrErr,
  round(p.psfMagErr_i,3) as psfiErr,
  round(p.psfMagErr_z,3) as psfzErr,
  p.type,                   --- tells if a source is resolved or not
  (case when (p.flags & '16') = 0 then 1 else 0 end) as ISOLATED
INTO mydb.SDSSimagingSample
FROM PhotoTag p
    --- 10x2 sq.deg.
  p.ra > 0.0 and p.ra < 10.0 and p.dec > -1 and p.dec < 1
    --- resolved and unresolved sources
  and (p.type = 3 OR p.type = 6) and
    --- '4295229440' is magic code for no
  (p.flags & '4295229440') = 0 and
    --- PRIMARY objects only, which implies
    --- !BRIGHT && (!BLENDED || NODEBLEND || nchild == 0)]
  p.mode = 1 and
    --- adopted faint limit (same as about SDSS limit)
  p.modelMag_r < 22.5
--- the end of query


>>> from astroML.datasets import fetch_imaging_sample
>>> data = fetch_imaging_sample()
>>> data.shape  # number of objects in dataset
>>> print data.names[:5]  # names of the first five columns
['ra', 'dec', 'run', 'rExtSFD', 'uRaw']
>>> print data['ra'][:2]
[ 0.265165  0.265413]
>>> print data['dec'][:2]
[-0.444861 -0.62201 ]