<jupyter_start><jupyter_text>A brief introduction to `KlipRetrieve`.<jupyter_code>from subtract_psf import KlipRetrieve<jupyter_output><empty_output><jupyter_text>Retrieve the two sets of data cubes (reference + target), then align them to enable PSF subtraction.*(Two possible alignment strategies -- `'theoretical'` and `'empirical2'`. See **[`compare_aligns.ipynb`](compare_aligns.ipynb)** to compare their performance.)*<jupyter_code>kr = KlipRetrieve('../example_images/', align_style='empirical2')<jupyter_output>in ../example_images/...
********
aligning all data cubes' images by their bright pixels...
********
********
removing padding from alignment process...
********
********
generating KLIP projections of target images in `self.klip_proj`...
********
********
generating pre-/post-subtraction contrast curves...
********
********
completed `self.pre_prof_hdu`, `self.post_prof_hdu`, `self.photon_prof_hdu`, and `self.pre_avg_hdu`.
********
********
injecting companion with (location-specific) 5-sigma intensity, after alignment.
********<jupyter_text>View plots of the alignment process to visualize each step.<jupyter_code>kr.plot_original_pointings()<jupyter_output><empty_output><jupyter_text>If you use the `'theoretical'` alignment style, you can also visualize what the star locations look like after being shifted from the above plot:<jupyter_code>kr_theo = KlipRetrieve('../example_images/', align_style='theoretical', verbose=False)
kr_theo.plot_shifted_pointings()<jupyter_output><empty_output><jupyter_text>Peform the PSF subtraction and see the results, slice-by-slice.*(Toggle the `companion` argument in `plot_subtraction()` to view the scene with and without a companion.)*Uncomment the first line of the following cell to randomize the companion's position. `inject_companion()` can also take an argument to set the factor by which to multiply the companion's brightness relative to the standard deviation of intensity for all pixels at its radial distance from the star.To see an example of how to inject a companion *pre-alignment*, using real stellar and companion flux spectra, see __[`inject_kappa_and.ipynb`](inject_kappa_and.ipynb)__.<jupyter_code>#kr.inject_companion(times_sigma=5)
kr.plot_subtraction(target_image=3, wv_slice=-2, companion=False)<jupyter_output>********
total intensity pre-subtract:  9.2950e-01
total intensity post-subtract: 9.5990e-03
********<jupyter_text>Compare contrast and separation curves for multiple wavelengths.<jupyter_code>kr.plot_contrasts(target_image=3, times_sigma=5, companion=False)<jupyter_output>********
1 arcsecond contrast @2.87 microns
pre-sub:  1.2400e-03 | post-sub: 6.3126e-05
********

********
1 arcsecond contrast @4.11 microns
pre-sub:  2.2670e-03 | post-sub: 1.5240e-04
********

********
1 arcsecond contrast @4.94 microns
pre-sub:  3.3383e-03 | post-sub: 2.9314e-04
********<jupyter_text>Key attributes: Image cubes:- *`data_cubes`*, an HDUList containing the original data cubes used to initiate your `KlipRetrieve` instance. The first half is made up of the reference "observations", and the target/science observations are in the second half.- *`stackable_cubes`*, an HDUList of data cubes where all slices are aligned and ready for PSF subtraction.- *`injected_cubes`*, an HDUList of *target* data cubes from `stackable_cubes` that have been injected with a companion. (Created automatically through `inject_companion()`.)- *`klip_proj`*, an HDUList of KLIP projections of the *target* data cubes in `stackable_cubes`. (Created automatically through `_generate_klip_proj()`.)- *`subtracted_cubes`*, an HDUList of reference cubes from `stackable_cubes` and target cubes made from the difference between `injected_cubes` and the latter half of `stackable_cubes`. Profile cubes:- *`pre_prof_hdu`*, an HDUList containing radial profile information for the standard deviation of flux in the target images in `stackable_cubes` ("**pre**-subtraction").- *`post_prof_hdu`*, an HDUList containing radial profile information for the standard deviation of flux when you subtract `injected_cubes`'s target images by their counterparts in `klip_proj` ("**post**-subtraction").- *`pre_avg_hdu`*, an HDUList containing radial profile information for the *mean* of flux in the target images in `stackable_cubes`.<jupyter_code>kr.data_cubes.info()
kr.stackable_cubes.info()
kr.klip_proj.info()
kr.injected_cubes.info()
kr.subtracted_cubes.info()<jupyter_output>Filename: (No file associated with this HDUList)
No.    Name      Ver    Type      Cards   Dimensions   Format
  0  REFERENCE0    1 ImageHDU       118   (26, 22, 6)   float64   
  1  REFERENCE1    1 ImageHDU       118   (26, 22, 6)   float64   
  2  REFERENCE2    1 ImageHDU       118   (26, 22, 6)   float64   
  3  REFERENCE3    1 ImageHDU       118   (26, 22, 6)   float64   
  4  REFERENCE4    1 ImageHDU       118   (26, 22, 6)   float64   
  5  REFERENCE5    1 ImageHDU       118   (26, 22, 6)   float64   
  6  REFERENCE6    1 ImageHDU       118   (26, 22, 6)   float64   
  7  REFERENCE7    1 ImageHDU       118   (26, 22, 6)   float64   
  8  REFERENCE8    1 ImageHDU       118   (26, 22, 6)   float64   
  9  REFERENCE9    1 ImageHDU       118   (26, 22, 6)   float64   
 10  TARGET0       1 ImageHDU       123   (26, 22, 6)   float64   
 11  TARGET1       1 ImageHDU       123   (26, 22, 6)   float64   
 12  TARGET2       1 ImageHDU       123   (26, 22, 6)   float64   
 13  TARGET3      [...]<jupyter_text>Observational attributes:More information about the observations is avilable through `positions` (the dither cycle used in this set of observations), `draws_ref` and `draws_sci` (the true stellar position in each data cube due to pointing and dither errors -- `point_err_ax` & `dith_err_ax`), `lo_wv` and `hi_wv` (the wavelength range of the spectrograph, in meters), and `wvlnths` (all the wavelengths observed, also in meters. its length is equal to the number of slices in each data cube).All non-List/HDUList attributes are listed below:<jupyter_code>{k:v for k,v in vars(kr).items()
 if not isinstance(v, list)
 and not k.startswith('_')}<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup