Loading Images

The ScienceImage class is the core object in ezphot for representing a single science FITS exposure. It manages metadata, processing status, associated products, and provides tools for background estimation, masking, and photometry preparation.

Creating a ScienceImage instance

You can create a ScienceImage by passing the path to a FITS file:

from ezphot.imageobjects import ScienceImage

sci = ScienceImage("/path/to/science.fits")

print(sci)

>>> ScienceImage(
  is_exists   = True,
  is_saved    = False,
  data_load   = True,
  header_load = True,
  imgtype     = Light,
  exptime     = 300.0,
  filter      = m625,
  path        = /path/to/science.fits,
  savedir     = /.../scidata/OBSERVATORY/TELKEY/OBJNAME/TELNAME/FILTER
)

Accessing Data and Header

The loaded FITS data and header can be accessed directly:

# Pixel data as a NumPy array
data = sci.data

# FITS header as an astropy.io.fits.Header
header = sci.header

Inspecting Properties

ScienceImage exposes important metadata through convenient properties.

print(sci.obsdate)     # Observation date
print(sci.filter)      # Filter name
print(sci.exptime)     # Exposure time
print(sci.seeing)      # Measured seeing
print(sci.objname)     # Object name

This information is collected from both FITS headers and telescope configuration.

Working with Save Paths

Important

ScienceImage automatically generates a structured save path for all connected products (status files, masks, catalogs, background maps, etc.).

# Access save paths
print(sci.path)                # Path to the science image
print(sci.savedir)             # Path to the save directory
print(sci.savepath.savepath)   # Path to the savepath of the image
print(sci.savepath.statuspath) # Path to status JSON
print(sci.savepath.infopath)   # Path to info JSON
print(sci.savepath.catalogpath)# Path to source catalog

You can override the default location by setting a custom savedir:

sci.savedir = "/custom/output/directory"

Saving and Removing Files

Save the current image to disk (including status and info):

sci.write()

Note

This will save the current data and header of the instance to savepath.savepath, not to the current path.

Remove the main FITS file and/or all associated products:

sci.remove(remove_main=True, remove_connected_files=True)

Visualization

ScienceImage provides built-in methods to quickly inspect images.

Show the full image

sci.show()

This opens a matplotlib window with the science image displayed.

Show a zoomed region around a position

# Display a region around pixel coordinates (x=1024, y=1024)
sci.show_position(x=1024, y=1024, zoom_radius_arcsec=50)

# Or around sky coordinates (RA, Dec in degrees)
sci.show_position(x=150.114, y=2.205,
                  coord_type="coord", zoom_radius_arcsec=30)

The show_position method is useful for checking sources, transients, or calibration stars in either pixel or sky coordinates.

Open with DS9

sci.run_ds9()

This will launch SAOImage DS9 with the image loaded.

ScienceImage forms the basis of the ezphot workflow and connects seamlessly with other objects such as ReferenceImage, Mask, and Background.