) citation = "Crain et al. (2015) (EAGLE NoAGN 25 Mpc)" bibcode = "2015MNRAS.450.1937C" name = "Galaxy Stellar Mass-Galaxy Size EAGLE NoAGN (25 Mpc)" plot_as = "points" redshift = 0.100_639 h_obs = 0.7 h = cosmology.h M = raw.T[0] * unyt.Solar_Mass R = raw.T[1] * unyt.kpc bins = unyt.unyt_array(np.logspace(8.5, 12, 20), units=unyt.Solar_Mass) # Now bin the line centers, median, deviation = binned_median_line(x=M, y=R, x_bins=bins) processed.associate_x( centers, scatter=None, comoving=False, description="Galaxy Stellar Mass (30kpc, 3D)" ) processed.associate_y( median, scatter=deviation, comoving=False, description="Galaxy Half-Mass Radius (whole subhalo, 3D)", ) processed.associate_citation(citation, bibcode) processed.associate_name(name) processed.associate_comment(comment) processed.associate_redshift(redshift) processed.associate_plot_as(plot_as)
if os.path.exists(output_path): os.remove(output_path) outobj.write(filename=output_path) # Also output median and scatter points for composite sample x_all = np.hstack(x_all) * unyt.dimensionless y_all = np.hstack(y_all) * unyt.dimensionless plussig = lambda a: np.percentile(a, 84) subsig = lambda a: np.percentile(a, 16) x_bins = np.percentile(x_all, np.linspace(1, 99, 10)) * unyt.dimensionless x_mids = x_bins[:-1] + np.diff(x_bins) * 0.5 _, y_med, y_sigs = binned_median_line(x_all, y_all, x_bins=x_bins) y_scatter = unyt.unyt_array((y_sigs[0], y_sigs[1])) x_scatter = unyt.unyt_array([np.diff(x_bins) * 0.5] * 2) output_filename = "DeLooze20_composite_median.hdf5" # Meta-data comment = f"Median and scatter compiled from multiple surveys" citation = f"Compiled by De Looze et al. (2020)" bibcode = "2020MNRAS.496.3668D" name = "MHI/Mstar as a function of 12 + log10(O/H)" plot_as = "points" redshift = 0.0 redshift_lower = 0.0 redshift_upper = 3.0
def create_line( self, x: unyt_array, y: unyt_array, box_volume: Union[None, unyt_quantity] = None, reverse_cumsum: bool = False, minimum_additional_points: int = 0, ): """ Creates the line! Parameters ---------- x: unyt_array Horizontal axis data y: unyt_array Vertical axis data box_volume: Union[None, unyt_quantity] Box volume for the simulation, required for mass functions. Should have associated volume units. Generally this is given as a comoving quantity. reverse_cumsum: bool A boolean deciding whether to reverse the cumulative sum. If false, the sum is computed from low to high values (along the X-axis). Relevant only for cumulative histogram lines. Default is false. minimum_additional_points: int, optional Minimum number of additional data points with the highest values of x to show in the median-line or mean-line plots. Returns ------- output: Tuple[unyt_array] A five-length (mean, median lines) or three-length (mass_function, histogram, cumulative_histogram) tuple of unyt arrays that takes the following form: (bin centers, vertical values, vertical scatter, additional_x [optional], additional_y [optional]). """ if self.bins is None: self.generate_bins(values=x) else: self.bins.convert_to_units(x.units) self.output = None masked_x = x masked_y = y if self.lower is not None: self.lower.convert_to_units(y.units) mask = masked_y > self.lower masked_x = masked_x[mask] masked_y = masked_y[mask] if self.upper is not None: self.upper.convert_to_units(y.units) mask = masked_y < self.upper masked_x = masked_x[mask] masked_y = masked_y[mask] if self.median: self.output = lines.binned_median_line( x=masked_x, y=masked_y, x_bins=self.bins, return_additional=True, minimum_additional_points=minimum_additional_points, ) elif self.mean: self.output = lines.binned_mean_line( x=masked_x, y=masked_y, x_bins=self.bins, return_additional=True, minimum_additional_points=minimum_additional_points, ) elif self.mass_function: mass_function_output = create_mass_function_given_bins( masked_x, self.bins, box_volume=box_volume) self.output = ( *mass_function_output, unyt_array([], units=mass_function_output[0].units), unyt_array([], units=mass_function_output[1].units), ) elif self.luminosity_function: luminosity_function_output = create_luminosity_function_given_bins( masked_x, self.bins, box_volume=box_volume) self.output = ( *luminosity_function_output, unyt_array([], units=luminosity_function_output[0].units), unyt_array([], units=luminosity_function_output[1].units), ) elif self.histogram: histogram_output = create_histogram_given_bins( masked_x, self.bins, box_volume=box_volume) self.output = ( *histogram_output, unyt_array([], units=histogram_output[0].units), unyt_array([], units=histogram_output[1].units), ) elif self.cumulative_histogram: histogram_output = create_histogram_given_bins( masked_x, self.bins, box_volume=box_volume, cumulative=True, reverse=reverse_cumsum, ) self.output = ( *histogram_output, unyt_array([], units=histogram_output[0].units), unyt_array([], units=histogram_output[1].units), ) elif self.adaptive_mass_function: *mass_function_output, self.bins = create_adaptive_mass_function( masked_x, lowest_mass=self.start, highest_mass=self.end, box_volume=box_volume, return_bin_edges=True, ) self.output = ( *mass_function_output, unyt_array([], units=mass_function_output[0].units), unyt_array([], units=mass_function_output[1].units), ) else: self.output = None return self.output
"H=70 km/s/Mpc and O_lambda=0.7. Provided h-free so no h-correction made. " f"This data is for the {band}-band only.") citation = f"Lange et al. (2015, {band}-band)" bibcode = "2015MNRAS.447.2603L" name = "Galaxy Stellar Mass-Galaxy Size" plot_as = "points" redshift = 0.05 h_obs = 0.7 h = cosmology.h half_mass = 10**(raw.T[1]) * unyt.kpc M = 10**(raw.T[0]) * unyt.Solar_Mass # We now need to bin this data mass_bins = unyt.Solar_Mass * np.logspace(7, 12, 26) mass_bin_centers, galaxy_sizes, galaxy_size_scatter = binned_median_line( x=M, y=half_mass, x_bins=mass_bins) processed.associate_x( mass_bin_centers, scatter=None, comoving=False, description="Galaxy Stellar Mass", ) processed.associate_y( galaxy_sizes, scatter=galaxy_size_scatter, comoving=False, description="Galaxy Half-Mass Radius", ) processed.associate_citation(citation, bibcode) processed.associate_name(name)
base_n_bins=number_of_bins, logarithmic=True, stretch_final_bin=True, ) _, bins_nsf = create_adaptive_bins( stellar_mass_nsf, lowest_value=stellar_mass_bin_range[0], highest_value=stellar_mass_bin_range[1], base_n_bins=number_of_bins, logarithmic=True, stretch_final_bin=True, ) centers_sf, medians_sf, deviations_sf = binned_median_line( x=stellar_mass_sf, y=R[mask_sf], x_bins=bins_sf, return_additional=False) centers_nsf, medians_nsf, deviations_nsf = binned_median_line( x=stellar_mass_nsf, y=R[mask_nsf], x_bins=bins_nsf, return_additional=False) processed_sf.associate_x(centers_sf, scatter=None, comoving=False, description="Galaxy Stellar Mass") processed_sf.associate_y( medians_sf,