code: def spec_iterative_pca(outfile, n_ev=10, n_iter=20, norm="L2"):
      """
      This function takes the file outputted above, performs an iterative
      PCA to fill in the gaps, and appends the results to the same file.
      """
      data_in = np.load(outfile)
      spectra = data_in["spectra"]
      mask = data_in["mask"]
  
      res = iterative_pca(
          spectra,
          mask,
          n_ev=n_ev,
          n_iter=n_iter,
          norm=norm,
          full_output=True,
      )
  
      input_dict = {key: data_in[key] for key in data_in.files}
  
      # don't save the reconstructed spectrum: this can easily
      # be recomputed from the other parameters.
      input_dict["mu"] = res[1]
      input_dict["evecs"] = res[2]
      input_dict["evals"] = res[3]
      input_dict["norms"] = res[4]
      input_dict["coeffs"] = res[5]
  
      np.savez(outfile, **input_dict)
  
file_path: astroML/examples/datasets/compute_sdss_pca.py
imports: import sys
  from urllib.error import HTTPError
  import numpy
  from astroML.datasets import fetch_sdss_spectrum
  from astroML.datasets.tools import query_plate_mjd_fiber, TARGET_GALAXY
  from astroML.dimensionality import iterative_pca
label_desc: Use image node_id 2 for calling a global function with example usage: spec_iterative_pca(outfile, n_ev, n_iter, norm) without return types