Observation
- class jwst.wfss_contam.observations.Observation(direct_image, segmentation_map, grism_wcs, direct_image_wcs, boundaries=None, max_cpu=1, max_pixels_per_chunk=50000.0, oversample_factor=2, band_wavelengths=None)[source]
Bases:
objectDefine an observation leading to a single grism image.
The Observation class is responsible for calling the various WCS transforms that convert a direct image and a segmentation image into a simulation of the grism image, making assumptions about the spectral properties of the direct image sources. When the
disperse_ordermethod is called one or more times, two products are created: the simulated dispersed image (simulated_imageattribute) and the simulated source cutouts (simulated_cutoutsattribute).Initialize all data and metadata for a given observation.
- Parameters:
- direct_imagenp.ndarray
Direct imaging data. May be 2-D
(ny, nx)for a single-band direct image, or 3-D(N, ny, nx)for a multi-band cube.- segmentation_mapnp.ndarray
Segmentation map data.
- grism_wcs
WCS WCS object from grism image
- direct_image_wcs
WCS WCS object from direct image
- boundarieslist, optional
Start/Stop coordinates of the FOV within the larger seed image.
- max_cpuint, optional
Max number of cpu’s to use when multiprocessing
- max_pixels_per_chunkint, optional
Maximum number of pixels per chunk when dispersing sources
- oversample_factorint, optional
Factor by which to oversample the wavelength grid
- band_wavelengthsarray-like of shape (N,), optional
Central wavelengths (in microns) for each plane of a 3-D
direct_image. Required whendirect_imageis 3-D; ignored whendirect_imageis 2-D.
Methods Summary
chunk_sources(order, lambdas, sens_waves, ...)Chunk the sources into groups of max_pixels.
disperse_order(order, wmin, wmax, ...[, ...])Disperse the sources for a given spectral order, with multiprocessing.
Methods Documentation
- chunk_sources(order, lambdas, sens_waves, sens_response, selected_ids=None, max_pixels=100000.0, basis_models=None, trace_pdt=None)[source]
Chunk the sources into groups of max_pixels.
- Parameters:
- orderint
Spectral order to process
- lambdasndarray
Wavelengths at which to compute dispersed pixel values for this order, precomputed once per order.
- sens_wavesndarray
Wavelength array from photom reference file
- sens_responsendarray
Response (flux calibration) array from photom reference file
- selected_idslist, optional
List of source IDs to process. If None, all sources are processed.
- max_pixelsint, optional
Maximum number of pixels per chunk.
- basis_modelslist of callables, optional
Flux distributions to evaluate at each wavelength. Typically these will be Legendre polynomials from 1st order up to a given max order, e.g. [P1(x), P2(x), …], the coefficients of which are linearly fit later. If None, no models are included in the output.
- trace_pdt
TracePDT, optional Precomputed pixel dispersion table for this spectral order. If None, no lookup table is used.
- Returns:
- disperse_argslist[list]
Outer list has length number of groups, and each inner list contains the arguments to disperse() for that group in the format that multiprocessing starmap expects.
- disperse_order(order, wmin, wmax, sens_waves, sens_response, selected_ids=None, basis_models=None, pdt_spacing=None, pdt_wl_oversample=1)[source]
Disperse the sources for a given spectral order, with multiprocessing.
The
simulated_cutoutsandsimulated_imageattributes are updated in place.- Parameters:
- orderint
Spectral order to process
- wminfloat
Minimum wavelength for dispersed spectra
- wmaxfloat
Maximum wavelength for dispersed spectra
- sens_wavesndarray
Wavelength array from photom reference file
- sens_responsendarray
Response (flux calibration) array from photom reference file
- selected_idslist, optional
List of source IDs to process. If None, all sources are processed.
- basis_modelslist of callables, optional
Flux distributions to evaluate at each wavelength. Typically these will be single polynomial orders, e.g. [lambda x: x, lambda x: x^2], …] the coefficients of which are linearly fit later. If None, no models are included in the output.
- pdt_spacingint, optional
Spacing of grid points to sample along the x and y axes when building a cached lookup table for the trace-shape transform. If None (the default), no lookup table is used and the exact transform is evaluated directly for every pixel.
- pdt_wl_oversamplefloat, optional
Oversampling factor for the lookup table’s wavelength grid, relative to the native dispersion scale. If None, the lookup table’s wavelength grid instead exactly matches the dispersal wavelength grid, allowing
evaluate_gridto skip wavelength-axis interpolation entirely. Only used ifpdt_spacingis not None.