code: def fetch_sdss_specgals(data_home=None, download_if_missing=True):
      """Loader for SDSS Galaxies with spectral information
  
      Parameters
      ----------
      data_home : optional, default=None
          Specify another download and cache folder for the datasets. By default
          all astroML data is stored in '~/astroML_data'.
  
      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 = (661598,)
          record array containing pipeline parameters
  
      Notes
      -----
      These were compiled from the SDSS database using the following SQL query::
  
          SELECT
            G.ra, G.dec, S.mjd, S.plate, S.fiberID, --- basic identifiers
            --- basic spectral data
            S.z, S.zErr, S.rChi2, S.velDisp, S.velDispErr,
            --- some useful imaging parameters
            G.extinction_r, G.petroMag_r, G.psfMag_r, G.psfMagErr_r,
            G.modelMag_u, modelMagErr_u, G.modelMag_g, modelMagErr_g,
            G.modelMag_r, modelMagErr_r, G.modelMag_i, modelMagErr_i,
            G.modelMag_z, modelMagErr_z, G.petroR50_r, G.petroR90_r,
            --- line fluxes for BPT diagram and other derived spec. parameters
            GSL.nii_6584_flux, GSL.nii_6584_flux_err, GSL.h_alpha_flux,
            GSL.h_alpha_flux_err, GSL.oiii_5007_flux, GSL.oiii_5007_flux_err,
            GSL.h_beta_flux, GSL.h_beta_flux_err, GSL.h_delta_flux,
            GSL.h_delta_flux_err, GSX.d4000, GSX.d4000_err, GSE.bptclass,
            GSE.lgm_tot_p50, GSE.sfr_tot_p50, G.objID, GSI.specObjID
          INTO mydb.SDSSspecgalsDR8 FROM SpecObj S CROSS APPLY
            dbo.fGetNearestObjEQ(S.ra, S.dec, 0.06) N, Galaxy G,
            GalSpecInfo GSI, GalSpecLine GSL, GalSpecIndx GSX, GalSpecExtra GSE
          WHERE N.objID = G.objID
            AND GSI.specObjID = S.specObjID
            AND GSL.specObjID = S.specObjID
            AND GSX.specObjID = S.specObjID
            AND GSE.specObjID = S.specObjID
            --- add some quality cuts to get rid of obviously bad measurements
            AND (G.petroMag_r > 10 AND G.petroMag_r < 18)
            AND (G.modelMag_u-G.modelMag_r) > 0
            AND (G.modelMag_u-G.modelMag_r) < 6
            AND (modelMag_u > 10 AND modelMag_u < 25)
            AND (modelMag_g > 10 AND modelMag_g < 25)
            AND (modelMag_r > 10 AND modelMag_r < 25)
            AND (modelMag_i > 10 AND modelMag_i < 25)
            AND (modelMag_z > 10 AND modelMag_z < 25)
            AND S.rChi2 < 2
            AND (S.zErr > 0 AND S.zErr < 0.01)
            AND S.z > 0.02
            --- end of query ---
  
      Examples
      --------
      >>> from astroML.datasets import fetch_sdss_specgals
      >>> data = fetch_sdss_specgals()  # doctest: +IGNORE_OUTPUT +REMOTE_DATA
      >>> # number of objects in dataset
      >>> data.shape  # doctest: +REMOTE_DATA
      (661598,)
      >>> # first five column names
      >>> data.dtype.names[:5]  # doctest: +REMOTE_DATA
      ('ra', 'dec', 'mjd', 'plate', 'fiberID')
      >>> # first three RA values
      >>> print(data['ra'][:3])  # doctest: +REMOTE_DATA
      [ 146.71419105  146.74414186  146.62857334]
      >>> # first three declination values
      >>> print(data['dec'][:3])  # doctest: +REMOTE_DATA
      [-1.04127639 -0.6522198  -0.7651468 ]
      """
  
      data_home = get_data_home(data_home)
  
      archive_file1 = os.path.join(
          data_home, os.path.basename(DATA_URL1)
      )
      archive_file2 = os.path.join(
          data_home, os.path.basename(DATA_URL2)
      )
  
      if not (
          os.path.exists(archive_file1)
          and os.path.exists(archive_file2)
      ):
          if not download_if_missing:
              raise IOError(
                  "data not present on disk. "
                  "set download_if_missing=True to download"
              )
  
          for url, name in zip(
              [DATA_URL1, DATA_URL2], [archive_file1, archive_file2]
          ):
              data = Table.read(url)
              data.write(name)
  
      data1 = Table.read(archive_file1)
      data2 = Table.read(archive_file2)
  
      data = vstack([data1, data2])
      return np.asarray(data)
  
imports: import os
  import numpy
  from astropy.cosmology import FlatLambdaCDM
  from astropy.table import Table, vstack
  from .None import get_data_home
label_desc: Use image node_id 1 for calling a global function with example usage: fetch_sdss_specgals(data_home, download_if_missing) and returns: np