Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions tutorials/euclid/euclid_clusters_tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ To explore a different control field, change the seed value or remove the seed e
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def check_mer_tile_requirement(coord, search_radius=2.0):
"""Check whether a sky coordinate is covered by exactly 4 Euclid MER science images.
Expand Down Expand Up @@ -230,6 +231,7 @@ def check_mer_tile_requirement(coord, search_radius=2.0):
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def find_control_field(cluster_df, cluster_ra, cluster_dec, min_distance_arcmin=15, max_attempts=100):
"""Find a random control field offset from the known cluster catalog.
Expand Down Expand Up @@ -342,6 +344,7 @@ Because the four photometric bands are independent of each other, `download_and_
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def _download_band(band, mer_images, field_coord, field_id, cache_dir, s3):
"""Download one photometric band from S3 and write a cutout FITS to the local cache.
Expand Down Expand Up @@ -401,6 +404,7 @@ def _download_band(band, mer_images, field_coord, field_id, cache_dir, s3):
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def download_and_cache_field(mer_images, field_name, field_coord, field_id):
"""Stream cutout FITS images from S3 and cache them locally.
Expand Down Expand Up @@ -482,6 +486,7 @@ Displaying the cluster and control fields side by side at the same stretch gives
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def normalize_with_consistent_stretch(cluster_cutouts, control_cutouts, lower_percentile=1, upper_percentile=99):
"""Normalize cluster and control cutouts using a shared percentile stretch.
Expand Down Expand Up @@ -538,6 +543,7 @@ def normalize_with_consistent_stretch(cluster_cutouts, control_cutouts, lower_pe
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def downsample(arr, factor=4):
"""Block-average a 2-D or 3-D image array by an integer factor for faster display.
Expand Down Expand Up @@ -646,6 +652,7 @@ Then we show part of the cluster dataframe to see what information we have avail
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def query_galaxies_for_field(ra, dec, field_name, redshift_center, redshift_width=0.1):
"""Query galaxies within a redshift slice around a sky position.
Expand Down Expand Up @@ -781,6 +788,7 @@ The function prints the number of galaxies within bounds as a diagnostic, if a l
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def apply_dbscan_clustering(galaxy_df, wcs, rgb_image, field_name, eps=500, min_samples=18):
"""Apply DBSCAN to detect galaxy overdensities in a redshift-selected sample. DBSCAN operates on the 2-D projected
Expand Down Expand Up @@ -938,6 +946,7 @@ Combining field galaxies from both the cluster and control fields gives us a lar
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def identify_cluster_members(galaxy_df, labels, galaxy_coords, field_name):
"""Separate a galaxy sample into cluster members and field galaxies.
Expand Down Expand Up @@ -1058,6 +1067,7 @@ We convert the uniform-aperture fluxes in the photo-z catalog to AB magnitudes a
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def calculate_color_magnitude(df):
"""Convert uniform-aperture fluxes to AB magnitudes and compute Y-H color.
Expand Down Expand Up @@ -1102,6 +1112,7 @@ field_cmd = calculate_color_magnitude(all_field_galaxies[['flux_y_unif', 'flux_h
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def remove_outliers_bounds(df, h_min=17, h_max=25, yh_min=-0.5, yh_max=1.5):
"""Filter a colour-magnitude table to a physically motivated range.
Expand Down Expand Up @@ -1242,6 +1253,7 @@ Ten spectra per group is sufficient to show whether the cluster and field popula
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def get_n_spectra(obj_ids, n=10):
"""
Expand Down Expand Up @@ -1434,6 +1446,7 @@ The three helper functions below handle this: `preprocess_spectrum` continuum-su
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def preprocess_spectrum(spec):
"""Continuum-remove + robust-normalize a spectrum for visualization."""
Expand Down Expand Up @@ -1487,6 +1500,7 @@ def preprocess_spectrum(spec):
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def build_stack(spectra_dict, w_grid):
"""Interpolate processed spectra onto a common grid and return matrix [nobj, ngrid]."""
Expand Down Expand Up @@ -1514,6 +1528,7 @@ def build_stack(spectra_dict, w_grid):
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def lines_in_window(wmin, wmax, z):
"""Return dict of lines whose observed wavelength falls in [wmin, wmax]."""
Expand Down Expand Up @@ -1553,6 +1568,7 @@ field_stack = build_stack(field_spectra, w_grid)
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def label_emission_line(ax, x, label, y=0.92, rotation=90, color='k'):
"""Place a vertical emission-line label at wavelength x."""
Expand Down Expand Up @@ -1639,6 +1655,7 @@ This provides an independent check of cluster membership using spectroscopic red
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def search_ned_field(ra, dec, z_min, z_max, label, radius_arcmin=3, max_retries=3):
"""Search NED within radius_arcmin of (ra, dec), filter to z_min–z_max, and print a summary.
Expand Down Expand Up @@ -1731,6 +1748,7 @@ We now overlay the NED-catalogued objects on the cluster and control field image
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def overlay_ned_sources(
cluster_objects, control_objects,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ Since the template-fit photometry is recommended for extended objects, we'll sep
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
# Galaxy + any. Star + galaxy. QSO + galaxy.
classes = {"Galaxy": (2, 3, 6, 7), "Star": (1, 3), "QSO": (4, 6)}
Expand Down Expand Up @@ -304,6 +305,7 @@ This figure is inspired by Romelli Fig. 6 (top panel).
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
# Only consider objects within these mag and mag difference limits.
mag_limits, mag_diff_limits = (16, 24), (-1, 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ list out some basic information including column names
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def inspect_parquet_columns(s3_path, *, region='us-east-1', max_rows=0):
"""
Expand Down Expand Up @@ -176,6 +177,7 @@ Next we merge the SN sample with the host galaxy fluxes and physical properties.
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def assemble_SN_data(sn_flux_file, galaxy_flux_file, galaxy_info_file, *, region='us-east-1'):
"""
Expand Down Expand Up @@ -251,6 +253,7 @@ A tight correlation along the 1:1 line indicates successful matching.
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def plot_redshift_comparison(df):
"""
Expand Down Expand Up @@ -349,6 +352,7 @@ roman_bands = {
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def scale_rubin_to_roman(df, rubin_bands, roman_bands, match_wave=0.87, verbose=False):
"""
Expand Down Expand Up @@ -445,6 +449,7 @@ def scale_rubin_to_roman(df, rubin_bands, roman_bands, match_wave=0.87, verbose=
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def photons_to_maggies_with_filter(photon_flux, filt):
"""
Expand Down Expand Up @@ -493,6 +498,7 @@ def photons_to_maggies_with_filter(photon_flux, filt):
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def add_maggie_columns(df):
"""
Expand Down Expand Up @@ -545,6 +551,7 @@ def add_maggie_columns(df):
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def plot_single_sed(df, rubin_bands, roman_bands, galaxy_index=0, loglog=False):
"""
Expand Down Expand Up @@ -636,6 +643,7 @@ plot_single_sed(df_scaled, rubin_bands, roman_bands, 1, loglog=True)
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def plot_many_seds(df, rubin_bands, roman_bands, n_galaxies=10, loglog=False):
"""
Expand Down Expand Up @@ -744,6 +752,7 @@ Prospector has its own built in functions to do writing and reading, but
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def df_to_all_obs(df, flux_err_frac=0.1):
"""
Expand Down Expand Up @@ -801,6 +810,7 @@ def df_to_all_obs(df, flux_err_frac=0.1):
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def process_output(output, model, obs, sps):
"""
Expand Down Expand Up @@ -903,6 +913,7 @@ def process_output(output, model, obs, sps):
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def run_fit(obs, model_params, sps, lnprobfn, noise_model, fitting_kwargs):
"""
Expand Down Expand Up @@ -965,6 +976,7 @@ def run_fit(obs, model_params, sps, lnprobfn, noise_model, fitting_kwargs):
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def run_fit_star(args):
"""
Expand Down Expand Up @@ -1007,6 +1019,7 @@ def run_fit_star(args):
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def fit_sample_parallel(obs_list, model_params, sps, lnprobfn, noise_model=(None,None),
fitting_kwargs=None, nproc=None):
Expand Down Expand Up @@ -1057,6 +1070,7 @@ def fit_sample_parallel(obs_list, model_params, sps, lnprobfn, noise_model=(None
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def save_outputs_hdf5(outputs, obs_list, filename="all_galaxies.h5"):
"""
Expand Down Expand Up @@ -1240,6 +1254,7 @@ use this section to quickly load the fitted results instead of re-running Prospe
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def download_results_hdf5_from_gdrive(file_id, dest_path="./sn_fits.h5"):
"""
Expand Down Expand Up @@ -1272,6 +1287,7 @@ def download_results_hdf5_from_gdrive(file_id, dest_path="./sn_fits.h5"):
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def load_outputs_hdf5(filename="sn_fits.h5",
file_id="1BuymtEXJsxbd8PqwkIEmff-76JGGa650"):
Expand Down Expand Up @@ -1353,6 +1369,7 @@ After fitting, we can visualize the results by comparing observed and modeled SE
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def plot_SED_fit(outputs, obs_list, galaxy_id):
"""
Expand Down Expand Up @@ -1464,6 +1481,7 @@ for gid in galaxy_ids[:5]:
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def plot_corner(outputs, obs_list, galaxy_id):
"""
Expand Down Expand Up @@ -1556,6 +1574,7 @@ Agreement along the 1:1 line indicates successful recovery of physical parameter
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def plot_stellar_mass_verification(df, outputs):
"""
Expand Down Expand Up @@ -1642,6 +1661,7 @@ We compare the distribution of Prospector-derived stellar masses for the two SN
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def plot_1a_vs_cc_mass(df_sn, outputs):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ Let's take a look at a few images to see what we are dealing with.
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def show_gallery(files, max_images=9):
"""
Expand Down Expand Up @@ -292,6 +293,7 @@ OU_RUBIN_SIA_COLLECTION = 'simulated_rubin_openuniverse2024'
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def get_s3_fpath(cloud_access):
cloud_info = json.loads(cloud_access) # converts str to dict
Expand All @@ -307,6 +309,7 @@ First, we find the filenames of the images in the Roman TDS survey which include
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def Roman_TDS_image_search(host_galaxy, radius, bandname):
"""
Expand Down Expand Up @@ -360,6 +363,7 @@ Since there are > 100 TDS images per band, we will:
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def select_images_by_mjd_quantiles(images, n_select=9):
"""
Expand Down Expand Up @@ -426,6 +430,7 @@ The two plotting functions then compile these measurements into time-ordered plo
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def run_aperture_photometry(host_galaxy, bandname, image_column="image_filenames", aperture_radius=1.0):
"""
Expand Down Expand Up @@ -525,6 +530,7 @@ host_galaxy
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def plot_single_band_light_curve(df, bandname, start_mjd):
"""
Expand Down Expand Up @@ -595,6 +601,7 @@ def plot_single_band_light_curve(df, bandname, start_mjd):
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def plot_multiband_light_curve(df, bands, start_mjd):
"""
Expand Down Expand Up @@ -685,6 +692,7 @@ We follow the example in this [tutorial](https://caltech-ipac.github.io/irsa-tut
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def make_cutout(fname, ra, dec, size=100):
"""
Expand Down Expand Up @@ -739,6 +747,7 @@ def make_cutout(fname, ra, dec, size=100):
---
jupyter:
source_hidden: true
tags: [hide-cell]
---
def cutout_gallery(image_filenames, mjd_list, ra, dec, aperture_radius_pix_list, size=100, ncols=4,
galaxy_id=None):
Expand Down
Loading
Loading