UP | HOME

FITSPipeline

I got an itch to process some of the raw 3I/ATLAS FITS images from Hubble. I had no idea where to begin, so I asked an AI (Claude via Jetbrains).

Since you have a Linux Ubuntu setup with astronomy packages (likely including astropy, which is great for handling FITS files), here's a step-by-step guide to get started with downloading and processing the raw FITS images. I'll focus on raw data processing, as that's what you mentioned—Hubble data requires calibration for science use, but you can start with basic inspection.

Step 1: Download the Raw FITS Files from MAST

The raw data (e.g., *raw.fits files) is hosted in the Mikulski Archive for Space Telescopes (MAST), operated by STScI. No account is needed for public data like this.

  • Go to the MAST HST search interface: https://mast.stsci.edu/search/ui/#/hst
  • In the search form:
    • Enter “17830” in the “Proposal ID” field.
    • Optionally, filter by “Target Name” as “3I/ATLAS” or “C/2025 N1” to narrow it down.
    • Click “Search”.
  • The results will show datasets from the proposal, including:
    • July 21, 2025 observations: Two orbits with short exposures (25-40 seconds) in WFC3/UVIS filters (likely F606W or similar broadbands for comet imaging).
    • November 30, 2025 observations: Similar WFC3 setup, tracking the comet (background stars appear streaked due to motion).
    • Dataset IDs typically start with “J” or “I” (e.g., jfxx01010asn.fits for associations, or individual *raw.fits files).
  • Select the datasets you want (check boxes), then click “Download” or “Add to Basket”.
  • Choose file types: Select “Uncalibrated” or “Raw” to get the original FITS files (avoid “Calibrated” if you want to process from scratch).
  • Download the ZIP or individual files. Each observation might include multiple exposures and an association table (*asn.fits) for grouping them.

Alternatively, for programmatic download (since you have Python): - Install astroquery if not already: pip install astroquery - Use this example script:

from astroquery.mast import Observations

​# Query by proposal and target obs_table =
Observations.query_criteria(proposal_id=“17830”,
target_name=[“3I/ATLAS”, “C/2025 N1”])

​# List available products data_products =
Observations.get_product_list(obs_table)

​# Filter for raw FITS (adjust filters as needed) raw_products =
Observations.filter_products(data_products, productType=“SCIENCE”,
extension=“fits”, mrp_only=False, calib_level=1) # calib_level=1 for raw
# Download to current directory
Observations.download_products(raw_products, download_dir=“.”)

This will fetch the files directly.

Step 2: Basic Inspection of FITS Files with Astropy

Once downloaded, start with simple viewing/analysis using astropy (assuming it's installed; if not, pip install astropy).

  • Open and inspect a file:

    from astropy.io import fits
    import matplotlib.pyplot as plt
    
    # Open the FITS file
    with fits.open('example_raw.fits') as hdul:  # Replace with your file name
        hdul.info()  # Shows structure (primary header, science data, etc.)
        header = hdul[0].header  # Or hdul[1].header for science extension
        print(header)  # View keywords like EXPTIME, FILTER, DATE-OBS
    
        # Plot the raw science data (usually in extension 1 'SCI')
        data = hdul[1].data  # Adjust extension if needed
        plt.imshow(data, cmap='gray', origin='lower')
        plt.colorbar()
        plt.show()
    
  • This gives you the uncalibrated image. For comets, you'll see the raw counts; background stars may streak in tracking mode.

Step 3: Calibrate the Data Using the calwf3 Pipeline

Hubble raw data needs calibration (bias subtraction, flat-fielding, CTE correction, etc.) for accurate analysis. Use the official calwf3 pipeline, part of HSTCAL.

Installation on Ubuntu

  1. Install Miniconda (if no Conda):

    wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
    bash Miniconda3-latest-Linux-x86_64.sh
    

    Restart your terminal.

  2. Install HSTCAL via conda-forge:

    conda install -c conda-forge hstcal
    

    This includes calwf3 and Python wrappers (wfc3tools).

  3. Install CRDS for reference files:

    pip install crds
    

    Initialize:

    crds bestrefs --context hst --all
    

Running the Pipeline

  • Update headers with best reference files (CRDS will suggest them):

    crds bestrefs --files *.fits --update-bestrefs
    
  • Run via Python (preferred):

    from wfc3tools import calwf3
    
    # For a single raw file
    calwf3('example_raw.fits')  # Outputs calibrated files like *_flt.fits
    
    # Or for an association (multiple exposures)
    calwf3('example_asn.fits')
    
  • Via command line:

    calwf3.e example_raw.fits -v  # Verbose mode
    

    Output: Calibrated science files (*flt.fits for singles, *crj.fits for combined if CR-SPLIT).

Step 4: Further Processing and Analysis

  • If dithered (multiple positions), use DrizzlePac (install: conda install -c conda-forge drizzlepac) to align and combine:

    from drizzlepac import astrodrizzle
    astrodrizzle.AstroDrizzle('*_flt.fits', output='combined_drz')
    
  • For comet-specific analysis (e.g., coma measurement, photometry): Use astropy's photutils or custom scripts.
  • Documentation: Check the WFC3 Data Handbook (https://hst-docs.stsci.edu/wfc3dhb) for details on keywords and steps. If you run into issues, the STScI Help Desk (help@stsci.edu) is responsive.

Once you've calibrated your Hubble WFC3 FITS files (e.g., producing ​*flt.fits or a drizzled *drz.fits file), exporting to a viewable format like JPG, PNG, or TIFF is straightforward using Python with astropy and matplotlib. Astronomical images have high dynamic range, so proper scaling/stretching is key to revealing details (e.g., the comet's coma and tail) without the image appearing blank or washed out.

Alternative: Manual or Logarithmic Stretch

If ZScale doesn't suit your taste:

from astropy.visualization import LogStretch

norm = ImageNormalize(data, interval=ZScaleInterval(), stretch=LogStretch())
# Then same plt.imshow(...) as above

Tips for Best Results

  • Use the drizzled (*drz.fits or *drc.fits) file if available—it's combined, distortion-corrected, and higher resolution.
  • For comets like 3I/ATLAS (non-sidereal tracking), stars will streak, but the comet should be sharp. Zoom in on the central region if needed: plt.xlim(xmin, xmax); plt.ylim(ymin, ymax)
  • Higher DPI (e.g., 300+) gives sharper exports for sharing/printing.
  • If the image looks too dark/bright, tweak with vmin=/=vmax manually: plt.imshow(data, cmap'gray', vmin=0.1, vmax=99.9)= (percentiles work well).

This will produce professional-looking outputs similar to official Hubble releases. Here's what processed Hubble images of comets typically look like (for reference; your raw processing should yield comparable results with the right stretch):

Run the script on your files and adjust as needed—share your exported image if you want feedback on the stretch!