Spectrum Analysis

grizli.utils Module

Dumping ground for general utilities

Functions

RGBtoHex(vals[, rgbtype]) Converts RGB values in a variety of formats to Hex values.
apply_flt_dq(filename[, replace, verbose, …]) Read and apply the compact exposure information file
argv_to_dict(argv[, defaults, dot_dict]) Convert a list of (simple) command-line arguments to a dictionary.
array_templates(templates[, wave, max_R, z, …]) Return an array version of the templates that have all been interpolated to the same grid.
blot_nearest_exact(in_data, in_wcs, out_wcs) Own blot function for blotting exact pixels without rescaling for input and output pixel size
bspline_templates(wave[, degree, df, …]) B-spline basis functions, modeled after splines
calc_header_zeropoint(im[, ext]) Determine AB zeropoint from image header
catalog_area([ra, dec, make_plot, NMAX, …]) Compute the surface area of a list of RA/DEC coordinates
catalog_mask(cat[, ecol, …]) Compute a catalog mask for
cheb_templates(wave[, order, get_matrix, …]) Chebyshev polynomial basis functions
column_string_operation(col, test[, method, …]) Analogous to str.contains but for table column.
column_values_in_list(col, test_list) Test if column elements “in” an iterable (e.g., a list of strings)
combine_phot_dict(phots[, templates, MW_EBV]) Combine photmetry dictionaries
compute_equivalent_widths(templates, coeffs, …) Compute template-fit emission line equivalent widths
compute_output_wcs(wcs_list[, pixel_scale, …]) Compute output WCS that contains the full list of input WCS
convex_hull_wrapper(x, y) Generate a convex hull from a list of points
ctime_to_iso(mtime[, format, strip_decimal, …]) Convert time.ctime strings to ISO dates
detect_with_photutils(sci[, err, dq, seg, …]) Use photutils to detect objects and make segmentation map
dot_templates(coeffs, templates[, z, max_R, …]) Compute template sum analogous to np.dot(coeffs, templates).
drizzle_array_groups(sci_list, wht_list, …) Drizzle array data with associated wcs
drizzle_from_visit(visit, output[, pixfrac, …]) Make drizzle mosaic from exposures in a visit dictionary
dump_flt_dq(filename[, replace, verbose]) Dump FLT/FLC header & DQ extensions to a compact file
emission_line_templates() Testing FSPS line templates
eval_bspline_templates(wave, bspl, coefs)
fetch_acs_wcs_files(beams_file[, bucket_name]) Fetch wcs files for a given beams.fits files
fetch_config_files([ACS, get_sky, …]) Config files needed for Grizli
fetch_default_calibs([ACS]) Fetch a set of default HST calibration files
fetch_hst_calib([file, ftpdir, verbose, …]) TBD
fetch_hst_calibs(flt_file[, ftpdir, …]) TBD Fetch necessary calibration files needed for running calwf3 from STScI FTP
fetch_s3_url([url, file_func, …]) Fetch file from an S3 bucket
fetch_wfpc2_calib([file, path, use_mast, …]) Fetch static WFPC2 calibration file and run stsci.tools.convertwaiveredfits on it.
fill_between_steps(x, y0, y1[, ax]) Make fill_between work like linestyle=’steps-mid’.
fill_masked_covar(covar, mask) Fill a covariance matrix in a larger array that had masked values
fix_flt_nan(flt_file[, bad_bit, verbose]) Fix NaN values in FLT files
flt_to_dict(fobj[, primary_keys, …]) Parse basic elements from a FLT/FLC header to a dictionary
full_spectrum_wcsheader([center_wave, dlam, …]) Make a WCS header for a 2D spectrum
generate_tempfilt(templates, filters[, …])
get_Vizier_photometry(ra, dec[, templates, …]) Fetch photometry from a Vizier catalog
get_common_slices(a_origin, a_shape, …) Get slices of overlaps between two rectangular grids
get_filter_obsmode([filter, acs_chip, …]) Derive pysynphot obsmode keyword from a filter name, where UVIS filters end in ‘u’
get_flt_footprint(flt_file[, extensions, …]) Compute footprint of all SCI extensions of an HST exposure
get_flt_info([files, columns]) Extract header information from a list of FLT files
get_hst_filter(header) Get simple filter name out of an HST image header.
get_line_wavelengths() Get a dictionary of common emission line wavelengths and line ratios
get_set_bits(value) Compute which binary bits are set for an integer
get_spectrum_AB_mags(spectrum[, bandpasses]) Integrate a pysynphot spectrum through filter bandpasses
get_visit_footprints(visits) Add Polygon ‘footprint’ attributes to visit dict.
get_wcs_pscale(wcs[, set_attribute]) Get correct pscale from a WCS object
get_wcs_slice_header(wcs, slx, sly) TBD
header_keys_from_filelist(fits_files[, …]) Dump header keywords to a Table
hull_area(x, y) Return the area of a convex hull of a list of points
hull_edge_mask(x, y[, pad, pad_is_absolute, …]) Compute geometrical edge mask for points within a convex hull
load_beta_templates([wave, betas]) Step-function templates with f_lambda ~ (wave/1216.)**beta
load_phoenix_stars([logg_list, teff_list, …]) Load Phoenix stellar templates
load_quasar_templates([broad_fwhm, …]) Make templates suitable for fitting broad-line quasars
load_sdss_pca_templates([file, smooth]) Load SDSS eigen templates
load_templates([fwhm, line_complexes, …]) Generate a list of templates for fitting to the grism spectra
log_comment(LOGFILE, comment[, verbose, …]) Log a message to a file, optionally including a date tag
log_exception(LOGFILE, traceback[, verbose, …]) Log exception information to a file, or print to screen
log_function_arguments(LOGFILE, frame[, …]) Log local variables, e.g., parameter arguements to a file
log_scale_ds9(im[, lexp, cmap, scale]) Scale an array like ds9 log scaling
log_zgrid([zr, dz]) Make a logarithmically spaced redshift grid
make_alf_template() Make Alf + FSPS template
make_maximal_wcs(files[, pixel_scale, …]) Compute an ImageHDU with a footprint that contains all of files
make_spectrum_wcsheader([center_wave, dlam, …]) Make a WCS header for a 2D spectrum
make_wcsheader([ra, dec, size, pixscale, …]) Make a celestial WCS header
mast_query_from_file_list([files, os_open]) Generate a MAST query on datasets in a list.
mode_statistic(data[, percentiles]) Get modal value of a distribution of data following Connor et al.
multiprocessing_ndfilter(data, filter_func) Cut up a large array and send slices to scipy.ndimage filters
nmad(data) Normalized NMAD=1.4826022 * median_absolute_deviation
nowtime([iso]) Wrapper for astropy.time.now
parse_flt_files([files, info, uniquename, …]) Read header information from a list of exposures and parse out groups based on filter/target/orientation.
parse_grism_associations(exposure_groups[, …]) Get associated lists of grism and direct exposures
parse_s3_url([url]) Parse s3 path string
parse_visit_overlaps(visits[, buffer]) Find overlapping visits/filters to make combined mosaics
polynomial_templates(wave[, ref_wave, …])
radec_to_targname([ra, dec, round_arcsec, …]) Turn decimal degree coordinates into a string with rounding.
read_catalog(file[, sextractor, format]) Wrapper around gread.
read_gzipped_header([file, BLOCK, NMAX, …]) Read primary header from a (potentially large) zipped FITS file
remove_text_labels(fig) Remove all Text annotations from fig.axes.
reproject_faster(input_hdu, output[, pad]) Speed up reproject module with array slices of the input image
safe_invert(arr) version-safe matrix inversion using np.linalg or np.matrix.I
set_warnings([numpy_level, astropy_level]) Set global numpy and astropy warnings
simple_LCDM([Om0, Ode0, H0, Ob0, Tcmb0, name]) Simple LambdaCDM cosmology
split_poly_template(templ[, ref_wave, order]) Multiply a single template by polynomial bases to effectively generate a polynomial multiplicative correction that can be fit with linear least squares.
split_spline_template(templ[, …]) Multiply a single template by spline bases to effectively generate a spline multiplicative correction that can be fit with linear least squares.
split_visit(visit[, visit_split_shift, …]) Check if files in a visit have large shifts and split them otherwise
step_templates([wlim, bin_steps, R, round, …]) Step-function templates for easy binning
strip_header_keys(header[, comment, …]) Strip header keywords
symlink_templates([force]) Symlink templates from module to $GRIZLI/templates as part of the initial setup
synphot_encircled_energy([obsmode, sp, …]) Compute encircled energy curves with pysynphot
synphot_zeropoint([obsmode, radius]) Compute synphot for a specific aperture
tabulate_encircled_energy([aper_radii, …])
to_header(wcs[, add_naxis, relax, key]) Modify astropy.wcs.WCS.to_header to produce more keywords
transform_wcs(in_wcs[, translation, …]) Update WCS with shift, rotation, & scale
trapz_dx(x) Return trapezoid rule coefficients, useful for numerical integration using a dot product
unset_dq_bits(value[, okbits, verbose]) Unset bit flags from a DQ array

Classes

EffectivePSF() Tools for handling WFC3/IR Effective PSF
GTable([data, masked, names, dtype, meta, …]) Extend Table class with more automatic IO and other helper methods.
HubbleXYZ([spt_file, param_dict]) Helper to compute HST geocentric coordinates from orbital parameters
MW_F99(a_v[, r_v]) Wrapper around the specutils.extinction / extinction modules, which are called differently
SRegion(inp[, label]) Helper class for parsing an S_REGION string
SpectrumTemplate([wave, flux, central_wave, …]) Container for template spectra.
Unique(array[, verbose]) Helper for unique items in an array
WCSFootprint(wcs[, ext, label]) Helper functions for dealing with WCS footprints
WCSMapAll(input, output[, origin]) Sample class to demonstrate how to define a coordinate transformation

grizli.grismconf Module

Demonstrate aXe trace polynomials.

Initial code taken from (Brammer, Pirzkal, & Ryan 2014), which contains a detailed explanation how the grism configuration parameters and coefficients are defined and evaluated.

Functions

get_config_filename([instrume, filter, …]) Generate a config filename based on the instrument, filter & grism combination.
load_grism_config(conf_file) Load parameters from an aXe configuration file

Classes

aXeConf([conf_file]) Read an aXe-compatible configuration file

grizli.model Module

Model grism spectra in individual FLTs

Classes

BeamCutout([flt, beam, conf, …]) Cutout spectral object from the full frame.
GrismDisperser([id, direct, segmentation, …]) Object for computing dispersed model spectra
GrismFLT([grism_file, sci_extn, …]) Scripts for modeling of individual grism FLT images
ImageData([sci, err, dq, header, wcs, …]) Container for image data with WCS, etc.

grizli.multifit Module

Functionality for manipulating multiple grism exposures simultaneously

Functions

drizzle_2d_spectrum(beams[, data, wlimit, …]) Drizzle 2D spectrum from a list of beams
drizzle_2d_spectrum_wcs(beams[, data, …]) Drizzle 2D spectrum from a list of beams
drizzle_to_wavelength(beams[, wcs, ra, dec, …]) Drizzle a cutout at a specific wavelength from a list of BeamCutout objects
get_redshift_fit_defaults() TBD
show_drizzle_HDU(hdu[, diff, …]) Make a figure from the multiple extensions in the drizzled grism file.

Classes

GroupFLT([grism_files, sci_extn, …]) Main container for handling multiple grism exposures together
MultiBeam(beams[, group_name, fcontam, psf, …]) Tools for dealing with multiple BeamCutout instances

grizli.fitting Module

Tools for fitting spectra with templates.

Functions

compute_cdf_percentiles(fit[, cdf_sigmas]) Compute tabulated percentiles of the CDF for a (lossy) compressed version of the redshift PDF.
compute_sps_params([full, cosmology, H0, …])
full_sed_plot(mb, tfit[, zfit, bin, minor, …]) Make a separate plot showing photometry and the spectrum
make_summary_catalog([target, sextractor, …])
refit_beams([root, append, id, keep_dict, …]) Regenerate a MultiBeam object selecting only certiain PAs
run_all(id[, t0, t1, fwhm, zr, dz, fitter, …]) Run the full template-fitting procedure
run_all_parallel(id[, get_output_data, …]) Wrapper function for grizli.fitting.run_all that preloads all keyword options from a stored file.
show_drizzled_lines(line_hdu[, …]) Make a figure with the drizzled line maps

Classes

GroupFitter Base class for StackFitter and MultiBeam spectrum fitting objects

Catalog tools

grizli.catalog Module

Catalog table tools

Functions

table_to_radec(table[, output]) Make a “radec” ascii file with ra, dec columns from a table object
table_to_regions(table[, output, comment, …]) Make a DS9 region file from a table object
randomize_segmentation_labels(seg[, …]) Randomize labels on a segmentation image for easier visualization
get_ukidss_catalog([ra, dec, radius, …]) Query for objects in the UKIDSS catalogs
get_sdss_catalog([ra, dec, radius]) Query for objects in the SDSS photometric catalog
get_twomass_catalog([ra, dec, radius, catalog])
get_irsa_catalog([ra, dec, tab, radius, …]) Query for objects in the AllWISE source catalog
get_gaia_radec_at_time(gaia_tbl[, date, format]) Use apply_space_motion to compute GAIA positions at a specific observation date
get_gaia_DR2_vizier_columns() Get translation of Vizier GAIA DR2 columns.
get_gaia_DR2_vizier([ra, dec, radius, max, …]) Query GAIA catalog from Vizier
gaia_dr2_conesearch_query([ra, dec, radius, max]) Generate a query string for the TAP servers TBD
get_gaia_DR2_catalog([ra, dec, radius, …]) Query GAIA DR2 astrometric catalog
gen_tap_box_query([ra, dec, radius, …]) Generate a query string for the NOAO Legacy Survey TAP server
query_tap_catalog([ra, dec, radius, …]) Query NOAO Catalog holdings
get_hubble_source_catalog([ra, dec, radius, …]) Query NOAO Source Catalog, which is aligned to GAIA DR1.
get_nsc_catalog([ra, dec, radius, corners, …]) Query NOAO Source Catalog, which is aligned to GAIA DR1.
get_desdr1_catalog([ra, dec, radius, …]) Query DES DR1 Catalog.
get_skymapper_catalog([ra, dec, radius, …]) Get Skymapper DR1 from Vizier
get_panstarrs_catalog([ra, dec, radius, …]) Get PS1 from Vizier
get_radec_catalog([ra, dec, radius, …]) Decide what reference astrometric catalog to use

Pipeline tools

grizli.pipeline.default_params Module

Parameter handling with YAML

Functions

compare_args()
get_yml_parameters([local_file, …]) Read default parameters from the YAML file in grizli/data
safe_yaml_loader(yamlfile[, loaders]) Try different YAML loaders
test_aws_availability() Test if aws s3 is available
write_params_to_yml(kwargs[, output_file, …]) Write grizli parameters to a file

grizli.pipeline.auto_script Module

Automatic processing scripts for grizli

Functions

clean_prep([field_root]) Clean unneeded files after the field preparation
count_grism_exposures(phot, groups[, …]) Count number of grism exposures that contain objects in a catalog
create_path_dict([root, home, raw, prep, …]) Generate path dict.
drizzle_overlaps(field_root[, filters, …])
exposure_report(root[, log]) Save exposure info to webpage & json file
extract([field_root, maglim, prior, MW_EBV, …])
fetch_files([field_root, HOME_PATH, paths, …]) Fully automatic script
field_psf([root, PREP_PATH, RAW_PATH, …]) Generate PSFs for the available filters in a given field
field_rgb([root, xsize, output_dpi, …]) RGB image of the field mosaics
fill_filter_mosaics(field_root) Fill field mosaics with the average value taken from other filters so that all images have the same coverage
fine_alignment([field_root, HOME_PATH, …]) Try fine alignment from visit-based SExtractor catalogs
generate_fit_params([field_root, fitter, …]) Generate a parameter dictionary for passing to the fitting script
get_extra_data([root, HOME_PATH, …])
get_rgb_filters(filter_list[, force_ir, …]) Compute which filters to use to make an RGB cutout
get_visit_exposure_footprints([visit_file, …]) Add exposure-level footprints to the visit dictionary
go([root, HOME_PATH, RAW_PATH, PREP_PATH, …]) Run the full pipeline for a given target
grism_prep([field_root, PREP_PATH, …]) Contamination model for grism exposures
load_GroupFLT([field_root, PREP_PATH, …]) Initialize a GroupFLT object
make_combined_mosaics(root[, fix_stars, …]) Drizzle combined mosaics
make_directories([root, HOME_PATH, paths]) Make RAW, Prep, Persistence, Extractions directories
make_filter_combinations(root[, weight_fnu, …]) Combine ir/opt mosaics manually scaling a specific zeropoint
make_mosaic_footprints(field_root) Make region files where wht images nonzero
make_reference_wcs(info[, files, output, …]) Make a reference image WCS based on the grism exposures
make_report(root[, gzipped_links, xsize, …]) Make HTML report of the imaging and grism data products
make_rgb_thumbnails([root, ids, maglim, …]) Make RGB thumbnails in working directory
manual_alignment([field_root, HOME_PATH, …])
mask_IR_psf_spikes([visit, mag_lim, cat, …]) Mask 45-degree diffraction spikes around bright stars
multiband_catalog([field_root, threshold, …]) Make a detection catalog and run aperture photometry with the SExtractor clone sep.
parse_visits([field_root, RAW_PATH, …]) Organize exposures into “visits” by filter / position / PA / epoch
photutils_catalog([field_root, threshold, …]) Make a detection catalog with SExtractor and then measure photometry with photutils.
preprocess([field_root, HOME_PATH, …]) master_radec: force use this radec file
refine_model_with_fits([field_root, grp, …]) Refine the full-field grism models with the best fit spectra from individual extractions.
remove_bad_expflag([field_root, HOME_PATH, …]) Remove FLT files in RAW directory with bad EXPFLAG values, which usually corresponds to failed guide stars.
summary_catalog(**kwargs)
update_wcs_headers_with_fine(field_root[, …]) Update grism headers with the fine shifts

grizli.pipeline.photoz Module

Helpers for working with eazy-py.

Functions

apply_catalog_corrections(root[, …]) Aperture and background corrections to photometric catalog
eazy_photoz(root[, force, object_only, …])
fix_aperture_corrections(tab[, verbose, …]) June 2020: Reapply total corrections using fixed bug for the kron total corrections where the necessary pixel scale wasn’t used.
get_external_catalog(phot[, filter_file, …]) Fetch photometry from vizier
show_all_thumbnails([label, filters, …]) Show individual filter and RGB thumbnails
show_from_ds9(ds9, self, zout[, use_sky])

Classes

EazyPhot(photoz[, grizli_templates, zgrid, …])
Parameters:

Simulations

Some basic tools for simulating HST/JWST/Roman grism data. See multimission_simulaation.ipynb for some examples.

grizli.fake_image Module

Tools for generating very basic fake images for HST/JWST/Roman simulations

Functions

make_fake_image(header[, output, …]) Use the header from NIRISS, WFC3/IR or WFIRST/Roman and make an FLT-like image that grizli can read as a reference.
make_roman_config([save_to_conf]) Use pandeia to calculate a Roman/G150 configuration file and sensitivity curve for grizli
nircam_header([ra, dec, pa_aper, filter, …]) Make JWST/NIRCAM image header
niriss_header([ra, dec, pa_aper, filter, grism]) Make JWST/NIRISS image header
roman_header([ra, dec, pa_aper, naxis]) Make WFIRST/Roman WFI header
roman_hls_image([exptime, nexp, background, …]) Make a simple FITS file for a Roman High Latitude Survey Image
rotate_CD_matrix(cd, pa_aper) Rotate CD matrix
wfc3ir_header([ra, dec, pa_aper, flt, filter]) Make HST/WFC3-IR image header
wfirst_header(**kwargs) Alias to roman_header