Example DRS Imager Processing

Installation

[ ]:
%pip install --upgrade pip setuptools wheel
!git clone https://github.com/oirlab/liger_iris_pipeline.git
%pip install ./liger_iris_pipeline
Requirement already satisfied: pip in /Users/cale/anaconda3/envs/liger_iris/lib/python3.12/site-packages (25.0)
Collecting pip
  Downloading pip-25.1.1-py3-none-any.whl.metadata (3.6 kB)
Requirement already satisfied: setuptools in /Users/cale/anaconda3/envs/liger_iris/lib/python3.12/site-packages (59.6.0)
Collecting setuptools
  Using cached setuptools-80.9.0-py3-none-any.whl.metadata (6.6 kB)
Requirement already satisfied: wheel in /Users/cale/anaconda3/envs/liger_iris/lib/python3.12/site-packages (0.37.1)
Collecting wheel
  Using cached wheel-0.45.1-py3-none-any.whl.metadata (2.3 kB)
Downloading pip-25.1.1-py3-none-any.whl (1.8 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.8/1.8 MB 5.3 MB/s eta 0:00:00a 0:00:01
Using cached setuptools-80.9.0-py3-none-any.whl (1.2 MB)
Using cached wheel-0.45.1-py3-none-any.whl (72 kB)
Installing collected packages: wheel, setuptools, pip
  Attempting uninstall: wheel
    Found existing installation: wheel 0.37.1
    Uninstalling wheel-0.37.1:
      Successfully uninstalled wheel-0.37.1
  Attempting uninstall: setuptools
    Found existing installation: setuptools 59.6.0
    Uninstalling setuptools-59.6.0:
      Successfully uninstalled setuptools-59.6.0
  Attempting uninstall: pip
    Found existing installation: pip 25.0
    Uninstalling pip-25.0:
      Successfully uninstalled pip-25.0
Successfully installed pip-25.1.1 setuptools-80.9.0 wheel-0.45.1
Note: you may need to restart the kernel to use updated packages.
Cloning into 'liger_iris_pipeline'...
remote: Enumerating objects: 4495, done.
remote: Counting objects: 100% (910/910), done.
remote: Compressing objects: 100% (377/377), done.
remote: Total 4495 (delta 605), reused 744 (delta 527), pack-reused 3585 (from 1)
Receiving objects: 100% (4495/4495), 3.21 MiB | 1.29 MiB/s, done.
Resolving deltas: 100% (2804/2804), done.
zsh:1: no matches found: ./liger_iris_pipeline[test]
Note: you may need to restart the kernel to use updated packages.

Imports

[ ]:
import liger_iris_pipeline
from liger_iris_pipeline.utils.gdrive import download_gdrive_file
import numpy as np
from astropy import units
import matplotlib.pyplot as plt
2025-07-15 08:15:12,062 - stpipe - WARNING - /Users/cale/anaconda3/envs/liger_iris/lib/python3.12/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm

Level 0 → Level 1 (Ramp level corrections and fitting)

[ ]:
# Imager data of M13 stars
sci_L0_filepath = download_gdrive_file('Liger/L0/2024B-P001-001_Liger_IMG_SCI_LVL0_0001_M13-J-10mas-skyscale1.0.fits', use_cached=True)
pipeline = liger_iris_pipeline.Stage1Pipeline()
pipeline.ramp_fit.method = 'ols'
nonlin_path = download_gdrive_file('Liger/Cals/Liger_IMG_NONLIN_20240924000000_0.0.1.fits', use_cached=True)
pipeline.nonlin_corr.nonlin = nonlin_path
model_result = pipeline.run([sci_L0_filepath])[0]
2025-07-15 08:17:36,981 - stpipe.Stage1Pipeline - INFO - Stage1Pipeline instance created.
2025-07-15 08:17:36,984 - stpipe.NonlinearCorrectionStep - INFO - NonlinearCorrectionStep instance created.
2025-07-15 08:17:36,985 - stpipe.FitRampStep - INFO - FitRampStep instance created.
2025-07-15 08:17:37,058 - stpipe.Stage1Pipeline - INFO - Running step <liger_iris_pipeline.pipeline.stage1.Stage1Pipeline object at 0x171889910> with parameters:
output_file=None
output_dir=None
save_results=False
skip=False
suffix=None
2025-07-15 08:17:37,108 - stpipe.NonlinearCorrectionStep - INFO - Running step <liger_iris_pipeline.readout.nonlincorr_step.NonlinearCorrectionStep object at 0x1718c9040> with parameters:
output_file=None
output_dir=None
save_results=False
skip=False
suffix=None
nonlin='/Users/cale/.astropy/cache/download/url/Liger/Cals/Liger_IMG_NONLIN_20240924000000_0.0.1.fits'
2025-07-15 08:17:37,212 - stpipe.NonlinearCorrectionStep - INFO - Using nonlin reference file /Users/cale/.astropy/cache/download/url/Liger/Cals/Liger_IMG_NONLIN_20240924000000_0.0.1.fits
2025-07-15 08:17:37,970 - stpipe.NonlinearCorrectionStep - WARNING - Could not update status for <stdatamodels.properties.ObjectNode object at 0x171556ea0>.nonlin_corr in datamodel.
2025-07-15 08:17:37,971 - stpipe.NonlinearCorrectionStep - INFO - Step NonlinearCorrectionStep done
2025-07-15 08:17:38,025 - stpipe.FitRampStep - INFO - Running step <liger_iris_pipeline.readout.fit_ramp_step.FitRampStep object at 0x1718c8890> with parameters:
output_file=None
output_dir=None
save_results=False
skip=False
suffix=None
method='ols'
num_coadd=3
2025-07-15 08:17:38,963 - stpipe.FitRampStep - WARNING - Could not update status for <stdatamodels.properties.ObjectNode object at 0x1715582c0>.ramp_fit in datamodel.
2025-07-15 08:17:38,963 - stpipe.FitRampStep - INFO - Step FitRampStep done
2025-07-15 08:17:38,965 - stpipe.Stage1Pipeline - INFO - Step Stage1Pipeline done

Examine result

[5]:
plt.imshow(model_result.data, vmin=0, vmax=np.quantile(model_result.data, .999))
[5]:
<matplotlib.image.AxesImage at 0x1718bba70>
../_images/examples_liger_imager_m13_8_1.png

Level 1 → Level 2 (Standard calibrations, WCS assignment)

[7]:
sci_L1_filepath = download_gdrive_file('Liger/L1/2024B-P001-001_Liger_IMG_SCI_LVL1_0001_M13-J-10mas-skyscale1.0.fits', use_cached=True)
dark_filepath = download_gdrive_file('Liger/Cals/Liger_IMG_DARK_20240924000000_0.0.1.fits', use_cached=True)
flat_filepath = download_gdrive_file('Liger/Cals/Liger_IMG_FLAT_20240924000000_0.0.1.fits', use_cached=True)
pipeline = liger_iris_pipeline.ImagerStage2Pipeline()
pipeline.dark_sub.dark = dark_filepath
pipeline.flat_field.flat = flat_filepath
input_dict = {
    'SCI' : [sci_L1_filepath],
}
model_result = pipeline.run(input_dict)[0]
2025-07-15 08:20:46,833 - stpipe.ImagerStage2Pipeline - INFO - ImagerStage2Pipeline instance created.
2025-07-15 08:20:46,840 - stpipe.ParseSubarrayMapStep - INFO - ParseSubarrayMapStep instance created.
2025-07-15 08:20:46,841 - stpipe.DarkSubtractionStep - INFO - DarkSubtractionStep instance created.
2025-07-15 08:20:46,843 - stpipe.FlatFieldStep - INFO - FlatFieldStep instance created.
2025-07-15 08:20:46,846 - stpipe.CalculateBackgroundImagerStep - INFO - CalculateBackgroundImagerStep instance created.
2025-07-15 08:20:46,850 - stpipe.SubtractBackgroundImagerStep - INFO - SubtractBackgroundImagerStep instance created.
2025-07-15 08:20:46,853 - stpipe.AssignWCSStep - INFO - AssignWCSStep instance created.
2025-07-15 08:20:46,929 - stpipe.ImagerStage2Pipeline - INFO - Running step <liger_iris_pipeline.pipeline.imager_stage2.ImagerStage2Pipeline object at 0x379cec4a0> with parameters:
output_file=None
output_dir=None
save_results=False
skip=False
suffix=None
2025-07-15 08:20:46,930 - stpipe.ImagerStage2Pipeline - INFO - First argument {'SCI': ['/Users/cale/.astropy/cache/download/url/Liger/L1/2024B-P001-001_Liger_IMG_SCI_LVL1_0001_M13-J-10mas-skyscale1.0.fits']} does not appear to be a model
2025-07-15 08:20:46,984 - stpipe.ParseSubarrayMapStep - INFO - Running step <liger_iris_pipeline.parse_subarray_map.parse_subarray_map_step.ParseSubarrayMapStep object at 0x379c11550> with parameters:
output_file=None
output_dir=None
save_results=False
skip=False
suffix=None
2025-07-15 08:20:47,001 - stpipe.ParseSubarrayMapStep - INFO - No SUBARR_MAP extension found
2025-07-15 08:20:47,002 - stpipe.ParseSubarrayMapStep - INFO - Step ParseSubarrayMapStep done
2025-07-15 08:20:47,059 - stpipe.DarkSubtractionStep - INFO - Running step <liger_iris_pipeline.dark_subtraction.dark_step.DarkSubtractionStep object at 0x379c10dd0> with parameters:
output_file=None
output_dir=None
save_results=False
skip=False
suffix=None
dark_output_dir=None
dark='/Users/cale/.astropy/cache/download/url/Liger/Cals/Liger_IMG_DARK_20240924000000_0.0.1.fits'
2025-07-15 08:20:47,076 - stpipe.DarkSubtractionStep - INFO - Using dark reference <DarkModel(2048, 2048) from Liger_IMG_DARK_20240924000000_0.0.1.fits>
2025-07-15 08:20:47,090 - stpipe.DarkSubtractionStep - INFO - Step DarkSubtractionStep done
2025-07-15 08:20:47,149 - stpipe.FlatFieldStep - INFO - Running step <liger_iris_pipeline.flat_field.flat_field_step.FlatFieldStep object at 0x379c01370> with parameters:
output_file=None
output_dir=None
save_results=False
skip=False
suffix=None
flat_output_dir=None
flat='/Users/cale/.astropy/cache/download/url/Liger/Cals/Liger_IMG_FLAT_20240924000000_0.0.1.fits'
2025-07-15 08:20:47,167 - stpipe.FlatFieldStep - INFO - Using flat reference file /Users/cale/.astropy/cache/download/url/Liger/Cals/Liger_IMG_FLAT_20240924000000_0.0.1.fits
2025-07-15 08:20:47,195 - stpipe.FlatFieldStep - INFO - Step FlatFieldStep done
2025-07-15 08:20:47,250 - stpipe.CalculateBackgroundImagerStep - INFO - Running step <liger_iris_pipeline.background.calc_background_imager_step.CalculateBackgroundImagerStep object at 0x379c02c90> with parameters:
output_file=None
output_dir=None
save_results=False
skip=False
suffix=None
sigma_low=6.0
sigma_high=2.0
maxiters=100
box_size=101
filter_size=None
2025-07-15 08:20:47,259 - stpipe.CalculateBackgroundImagerStep - INFO - Calculcating sky background from [<ImagerModel(2048, 2048) from 2024B-P001-001_Liger_IMG_SCI_LVL1_0001_M13-J-10mas-skyscale1.0.fits>].
2025-07-15 08:20:49,784 - stpipe.CalculateBackgroundImagerStep - WARNING - Could not update status for <stdatamodels.properties.ObjectNode object at 0x379c28260>.calc_bkg_imager in datamodel.
2025-07-15 08:20:49,784 - stpipe.CalculateBackgroundImagerStep - INFO - Step CalculateBackgroundImagerStep done
2025-07-15 08:20:49,841 - stpipe.SubtractBackgroundImagerStep - INFO - Running step <liger_iris_pipeline.background.subtract_background_imager_step.SubtractBackgroundImagerStep object at 0x379c03fb0> with parameters:
output_file=None
output_dir=None
save_results=False
skip=False
suffix=None
background=<ImagerModel(2048, 2048) from 2024B-P001-001_Liger_IMG_SCI_LVL1_0001_M13-J-10mas-skyscale1.0.fits>
scale=1.0
2025-07-15 08:20:49,856 - stpipe.SubtractBackgroundImagerStep - WARNING - Could not update status for <stdatamodels.properties.ObjectNode object at 0x3799f55b0>.subtract_bkg in datamodel.
2025-07-15 08:20:49,856 - stpipe.SubtractBackgroundImagerStep - INFO - Step SubtractBackgroundImagerStep done
2025-07-15 08:20:49,914 - stpipe.AssignWCSStep - INFO - Running step <liger_iris_pipeline.assign_wcs.assign_wcs_step.AssignWCSStep object at 0x379ced430> with parameters:
output_file=None
output_dir=None
save_results=False
skip=False
suffix=None
2025-07-15 08:20:49,927 - stpipe.AssignWCSStep - INFO - Step AssignWCSStep done
2025-07-15 08:20:49,929 - stpipe.ImagerStage2Pipeline - INFO - Step ImagerStage2Pipeline done

Examine Results

[8]:
# Compute wcs corners
height, width = model_result.data.shape
print(f"Image shape: {height} x {width}")
corners = np.array([[0, 0], [width-1, 0], [width-1, height-1], [0, height-1]]) * units.pixel
world_corners = [model_result.meta.wcs(*corner) for corner in corners]
print("World corners (RA, Dec):")
for corner in world_corners:
    print(f"  {corner[0].value:.6f}, {corner[1].value:.6f}")
extent = [world_corners[0][0].value, world_corners[1][0].value, world_corners[2][1].value, world_corners[0][1].value]
dx = extent[1] - extent[0]
dy = extent[2] - extent[3]
extent = np.array([-dx / 2, dx / 2, dy / 2, -dy / 2]) * 3600

plt.imshow(model_result.data, extent=extent, vmin=0, vmax=np.quantile(model_result.data, .999))
#plt.xlim(-0.15, 0.15); plt.ylim(0.15, -0.15)
plt.xlabel("Relative RA [arcsec]"); plt.ylabel("Relative Dec [arcsec]")
plt.show()
Image shape: 2048 x 2048
World corners (RA, Dec):
  250.418990, 36.457018
  250.426060, 36.457018
  250.426060, 36.462704
  250.418990, 36.462704
../_images/examples_liger_imager_m13_12_1.png