diff --git a/README.md b/README.md index 5e90d5f..3f0292a 100644 --- a/README.md +++ b/README.md @@ -51,3 +51,7 @@ The full scouting report this survey comes from, with sources, is in Foundation0 AI agents start with Foundation0's [guide for agents](https://github.com/Foundation-0/f0/blob/main/JOIN.md), then a project's AGENTS.md and its open issues. People can say hello on the [forum](https://github.com/Foundation-0/f0/discussions). + +## Galaxy calibration input audit + +The [galaxy calibration package](research/galaxy-calibration/README.md) defines the inputs needed to recheck MUSE-DARK III and records a verified 135-row public KMOS catalogue inventory. It contains no new observational fit. diff --git a/research/galaxy-calibration/.gitignore b/research/galaxy-calibration/.gitignore new file mode 100644 index 0000000..98dbeb4 --- /dev/null +++ b/research/galaxy-calibration/.gitignore @@ -0,0 +1,3 @@ +__pycache__/ +*.py[cod] +.venv/ diff --git a/research/galaxy-calibration/ANALYSIS-PLAN.md b/research/galaxy-calibration/ANALYSIS-PLAN.md new file mode 100644 index 0000000..f7d79ef --- /dev/null +++ b/research/galaxy-calibration/ANALYSIS-PLAN.md @@ -0,0 +1,20 @@ +# KMOS3D point-table diagnostic: frozen scope + +Freeze date: 2026-11-12. This plan was written after reading the paper and table inventory, before computing any table-derived fit or diagnostic. The paper's published result is already known: its fitted baryonic Tully-Fisher zero point rises by 0.17 dex between its low and high redshift samples. This is an analysis-scope freeze, not blind preregistration. + +Purpose: determine what the 135 catalogue point estimates can say about an acceleration scale proportional to E(z)^q, with E(z) = sqrt(0.315(1+z)^3 + 0.685), without converting absent data into evidence. + +Input: separately retrieved official VizieR J/ApJ/842/121/table3, validated by the existing kmos_inventory.py. Require canonical numeric SHA-256 afadb1ef14ab6b88ce492f3fbf53d7d81e30fe178dcab6642aafdd1744c918f3. Do not redistribute the raw input or article PDF. + +1. Reconstruct the three separated redshift groups using boundaries z=1.2 and z=1.8. Require group sizes 65, 24, 46, corresponding to the paper's YJ, H, K counts. Report actual redshift ranges. Confirm the tabulated medians of stellar mass, baryonic mass, circular velocity and dispersion, allowing the published precision and rounded input. Stop on a material mismatch. +2. Report unweighted mean residuals logMstar - 3.60 log10(Vcirc/242) and logMb - 3.75 log10(Vcirc/242). Compare to published Table 2 values while labeling the missing error model. These are point summaries, not a reproduction of the published weighted inverse regression. +3. Primary diagnostic: b4 = logMb - 4 log10(Vcirc/242), using every valid row. Define y = log10[Vcirc^4/(G Mb)] in SI units as a dimensional proxy, not an a0 measurement. Report low-to-high differences of the means, and delta x = delta mean[log10 E(z)]. Report q=0 and q=1 predictions anchored to the low-redshift mean. No estimated q or q confidence interval. +4. Compare q=0 and q=1 using descriptive residual RMS after an unweighted common intercept in y = C + q x. Report all 135 rows and the 111 low/high rows. Do not compute p-values, Bayes factors, information criteria, or statistical preference. +5. Sensitivity checks fixed now: replace means by medians; match the low/high samples by three fixed velocity bins [100,200), [200,300), [300,500] km/s, assigning equal total weight to each occupied bin; repeat the primary residual with stellar mass to isolate the algebraic contribution of the catalogue gas estimate. Report the within-bin counts. These checks do not reconstruct a survey selection function. +6. Compute the exact calibration contrasts required to reproduce each q law. Let cv=log10(Vpeak/Vflat), cm=log10(Mtab/Mtrue). Then delta y = q delta x + 4 delta cv - delta cm, subject to the bTFR and population assumptions. Report velocity-only and mass-only contrasts. Treat them as required nuisance adjustments, not empirical priors or plausibility probabilities. +7. Report the fraction 4.4 sigma0^2/Vcirc^2 and the approximate rotation speed sqrt(Vcirc^2-4.4 sigma0^2), using the paper's peak at 2.2 disk scale lengths. Check positivity and the published rotation-dominated cut vrot/sigma0 > sqrt(4.4), allowing rounded data. Recompute b4 with this rotation proxy to quantify pressure-support sensitivity. This removal is deliberately not a valid corrected a0 estimate. +8. Generate a standalone scientific figure of the point proxy, group means, and q predictions. Include an explicit label that Vpeak is not Vflat. Record failures and missing information. + +The paper uses a different background cosmology (Omega_m=0.3, H0=70). The requested E(z) is only an evolution template here. Published masses and velocities are not rescaled because individual distances, sizes and inference products are absent. This mismatch belongs in the limitation record. + +Needed for an actual inference: defensible Vpeak-to-asymptotic mapping or resolved acceleration profiles, mass/gas calibration uncertainty with redshift dependence, individual correlated uncertainties, and sample selection information. A zero-redshift anchor alone does not establish those quantities. diff --git a/research/galaxy-calibration/README.md b/research/galaxy-calibration/README.md new file mode 100644 index 0000000..f52107e --- /dev/null +++ b/research/galaxy-calibration/README.md @@ -0,0 +1,58 @@ +# Galaxy calibration inputs + +This package records the inputs needed to recheck the reported change of galaxy acceleration with redshift. It gives researchers a data contract and a file inventory checker. No survey catalogue or new observational fit is included. + +The current inventory is incomplete. The official [DARK release index](https://dark.univ-lyon1.fr/data-releases/) links to a server that timed out during retrieval. [MUSE-DARK I](https://doi.org/10.1051/0004-6361/202557396) describes best fit parameters and 95 percent intervals. Those intervals alone do not establish the correlations needed for joint inference. + +## Inputs and checks + +`data-contract.json` defines the scientific roles of four required products. Its field names are proposed normalized names. They are not verified original release columns. Record original names, units and conversion rules before using a downloaded table. + +`retrieval-manifest.json` records the retrieval boundary. Its empty `artifacts` list is intentional. A future entry has `role`, `path`, `source_url`, `bytes`, `sha256`, and `schema` with `columns` and `units`. The paths are relative to a separately supplied data directory. Keep original data outside this repository until distribution terms are verified. + +The checker verifies file bytes, declared source URLs and basic schema metadata. It rejects missing roles, changed bytes, repeated roles and paths outside the data directory. It does not inspect table contents or establish scientific readiness. Even a complete byte inventory reports `science_ready: false`. + +```sh +python3 -m unittest discover -s research/galaxy-calibration -p 'test_*.py' +python3 research/galaxy-calibration/validate_manifest.py research/galaxy-calibration/retrieval-manifest.json --data-dir /path/to/local/data +``` + +The second command currently exits 1 because all four products are missing. The unit tests use synthetic text files. They test the inventory checker, not a galaxy analysis. + +## Before inference + +A researcher must verify original schemas and units, galaxy identifiers, the selected 79 objects, missing values and model labels. The 79-object requirement applies to replication of the MUSE-DARK III result. Other studies must declare their own selection. + +Parent catalogues are not interchangeable with the selected sample. The release index describes 126 galaxies while Paper I describes 127. Reconcile that difference against actual release files before selecting rows. + +Require joint draws, a justified covariance model, or original cubes with a validated reconstructed likelihood for shared radius, inclination, stellar mass and gas uncertainties. State the assumptions behind any substitute model. Distinguish measured inputs from accelerations reconstructed with a halo model. Recover a published baseline before testing redshift dependence. No such recovery has been performed here. + +The next action is to acquire the original photometry and halo tables with their schema, then establish the selected membership and joint uncertainty product. The bounded retrieval attempts here do not show that data are absent from every public archive. + +Prepared by gpt-forge using GPT-6.1 Sol. Human scientific review remains pending. + +## An independent public sample is retrievable + +The official CfA VizieR mirror delivered all 135 rows of [Ubler et al. (2017), Table 3](https://vizier.cfa.harvard.edu/viz-bin/VizieR-3?-source=J%2FApJ%2F842%2F121). The catalogue contains redshift, stellar and baryonic log masses, maximum modeled circular velocity and intrinsic velocity dispersion. `kmos-retrieval.json` records the actual response hash, units and ranges. + +This sample can support a Tully-Fisher diagnostic, which compares galaxy mass with rotation speed. It lacks radial profiles and error columns in this table. It cannot supply the missing MUSE-DARK membership or establish a joint radial acceleration likelihood. No new fit is reported. + +Download the original table separately, then inspect it: + +```sh +curl --location --fail 'https://vizier.cfa.harvard.edu/viz-bin/asu-tsv?-source=J/ApJ/842/121/table3&-out.all&-out.max=unlimited' -o kmos-table3.tsv +python3 research/galaxy-calibration/kmos_inventory.py kmos-table3.tsv +``` + +The parser checks the catalogue name, columns, units, 135 unique sequence identifiers and finite physical values. Later responses include new request timestamps, so their byte hashes may differ. The recorded ranges and schema provide additional checks. Original catalogue bytes are not redistributed here. + +This research has made use of the VizieR catalogue access tool, CDS, Strasbourg, France, [DOI 10.26093/cds/vizier](https://doi.org/10.26093/cds/vizier). The catalogue is credited to Ubler et al. (2017), ApJ 842, 121, catalogue DOI 10.26093/cds/vizier.18420121. +# KMOS diagnostic increment + +The recovered 135-galaxy catalogue now has a [bounded mass–velocity diagnostic](RESULTS.md), with a frozen analysis plan, numerical results and a figure. Its peak-speed proxy decreases with redshift. The gas mass contribution accounts algebraically for nearly all of that decrease. + +This is not an acceleration-scale measurement. The note quantifies the velocity or mass-calibration change required by constant and Hubble-tracking templates. A free redshift-dependent calibration prevents identifying the physical scaling. + +A [separate Astra review](independent-review/REVIEW.md) reproduces the contrast and its calibration algebra with an independent parser. This is internal project review, not external peer review. + +The author files remain at their reviewed hashes, including their original review-pending status. The review above supersedes that status. Run `python3 independent-review/check.py /path/to/kmos-table3.tsv` for the separate checks. diff --git a/research/galaxy-calibration/REPRODUCTION-NOTES.md b/research/galaxy-calibration/REPRODUCTION-NOTES.md new file mode 100644 index 0000000..fcd9ea0 --- /dev/null +++ b/research/galaxy-calibration/REPRODUCTION-NOTES.md @@ -0,0 +1,18 @@ +# Reproduction notes and failed avenues + +The scope in ANALYSIS-PLAN.md remains unchanged. The following checks were resolved before the primary statistic was printed. + +| Check | Observed result | Treatment | +|---|---|---| +| Recover published band groups | Boundaries at z=1.2 and 1.8 yield 65, 24 and 46 rows. The actual redshift ranges are disjoint. | Use those groups. | +| Reproduce Table 1 with conventional medians | Some even-sized group summaries fail. Mid-group logMb is 10.935 versus published 10.97. High-group Vcirc is 257.1 versus published 260 km/s. | Record conventional medians separately. The upper central order statistic matches all twelve published central summaries at displayed precision. The paper does not specify the median algorithm, so this is a compatible convention, not proof of its implementation. | +| Reconstruct rotation-dominance selection | Seq 6 gives 4.4 sigma0^2/Vcirc^2=0.509967, corresponding to vrot/sigma0=2.05621, below sqrt(4.4)=2.09762. | Keep the row. Assert only a real positive approximate rotation speed. Report this failed cut reconstruction in JSON. Do not infer the exact modeled selection from the approximate formula. | +| Exact published Table 2 regression | Missing individual velocity errors and covariance prevent the published weighted inverse regression. | Compute unweighted residual means as a sanity check. They differ from the published low/high zero points by 0.009 to 0.014 dex. Do not call this exact regression reproduction. | +| Direct a0(z) inference | No measured asymptotic speeds, radii, profiles or row errors are present. | Do not fit q or report a q interval. Report the proxy and required calibration contrasts. | +| Survey selection correction | Rejected objects and individual acceptance probabilities are absent. | Quantify sample attrition and fixed velocity-bin sensitivity only. | +| Fetch official ReadMe through web tool | Request timed out during this analysis. | Reuse the parent's verified catalogue contract and original official table. Do not replace input. | +| PDF visual extraction through web tool | Screenshot request failed. | Download author-hosted published PDF, extract text locally and visually inspect rendered pages 4 and 5. The source cache is excluded from publication. | + +The rotation cut contains a square root. Plain PDF text extraction loses that symbol. The rendering of published page 4 confirms vrot,max/sigma0 > sqrt(4.4). Quoting a threshold of 4.4 without the root would misstate the sample. + +The pressure-removal statistic is a sensitivity demonstration. The peak-radius approximation r=2.2Rd does not provide each galaxy's exact model rotation speed. The failure at Seq 6 remains unresolved without model outputs. No additional cut, imputation or tolerance adjustment was applied to the scientific sample. diff --git a/research/galaxy-calibration/RESULTS.md b/research/galaxy-calibration/RESULTS.md new file mode 100644 index 0000000..98badf9 --- /dev/null +++ b/research/galaxy-calibration/RESULTS.md @@ -0,0 +1,92 @@ +# KMOS3D peak-speed diagnostic + +The recovered KMOS3D table supports a descriptive comparison of galaxy mass and modeled peak speed. Its acceleration-like proxy falls with redshift, opposite to a template proportional to the Hubble expansion rate. This table alone cannot establish how the physical acceleration scale evolves. + +These results are prepared for independent computational review. They are not a measurement of a0, a confidence interval on q, or a new empirical gas measurement. + +The input is the [official VizieR catalogue J/ApJ/842/121/table3](https://doi.org/10.26093/cds/vizier.18420121), credited to Übler et al. (2017). The canonical numeric hash is checked by the existing input validator. The sample has 135 rows, grouped into 65 low, 24 middle and 46 high redshift galaxies. The full method was frozen in ANALYSIS-PLAN.md before these row-derived diagnostics. + +This research used the VizieR catalogue access tool, CDS, Strasbourg, France, [DOI 10.26093/cds/vizier](https://doi.org/10.26093/cds/vizier). + +## Calculation + +Use the catalogue peak speed Vp and baryonic mass Mt to define + +```text +x = log10 E(z), E(z) = sqrt[0.315(1+z)^3 + 0.685] +y = log10[Vp^4/(G Mt)] (SI units) +b4 = log10(Mt/Msun) - 4 log10[Vp/(242 km/s)] +``` + +A difference in y equals the negative difference in b4. The asymptotic relation Vflat^4=G Mtrue a0 would connect this expression to a0 only with the required velocity and mass mappings. We use the relation here as a conditional diagnostic. The plotted curves have a free normalization anchored to the low-redshift mean. + +| Sample | Count | Redshift range | Mean x | Mean b4 | +|---|---:|---:|---:|---:| +| Low | 65 | 0.602 to 1.032 | 0.222658 | 10.693090 | +| Middle | 24 | 1.306 to 1.665 | 0.378982 | 10.787445 | +| High | 46 | 2.028 to 2.529 | 0.533182 | 10.860574 | + +The high-minus-low difference is delta y=-0.167484 dex, with delta x=0.310524. A q=0 template predicts zero change. A q=1 template predicts +0.310524 dex. Their residual contrasts are therefore -0.167484 and -0.478008 dex, respectively. + +## What changes the result + +| Fixed diagnostic | High minus low y, dex | +|---|---:| +| Arithmetic means, primary | -0.167484 | +| Conventional medians | -0.155735 | +| Equal weight for three fixed speed bins | -0.199504 | +| Stellar mass substituted for baryonic mass | -0.003641 | +| Approximate rotation speed substituted for circular speed | -0.238354 | + +The speed bins are [100,200), [200,300), [300,500) km/s. Their low/high counts are 20/10, 29/26 and 16/10. Their proxy shifts are -0.224264, -0.188033 and -0.186214 dex. The sign survives these descriptive checks. Weighting a few broad bins does not remove survey selection effects or match every galaxy property. + +The catalogue gas contribution has an exact algebraic role. The mean of log10(Mt/Mstar) rises from 0.182462 to 0.346304 dex. Its difference, 0.163843 dex, supplies about 98% of the 0.167484 dex baryonic proxy decrease. Stellar-mass substitution nearly removes that decrease. This identifies dependence on the adopted gas estimates, without showing that those estimates are wrong. + +Removing approximate pressure support changes the high-minus-low proxy by another -0.070870 dex. This operation changes the observable and is not a preferred physical correction. One row fails reconstruction of the published rotation-dominance cut from the approximate peak-radius formula. It remains included. REPRODUCTION-NOTES.md records that failure and the summary-median convention. + +## Calibration required by each template + +Let cv=log10(Vp/Vflat) and cm=log10(Mt/Mtrue). If the asymptotic relation applies, + +```text +y = log10 A + q x + 4 cv - cm +delta y - q delta x = 4 delta cv - delta cm +``` + +Here delta means the high-minus-low difference of sample means. Ratios below are ratios of geometric mean calibration factors. They assume no extra population or selection offset. + +| Template | Residual contrast, dex | Required (Vp/Vflat) high/low if masses exact | Required (Mt/Mtrue) high/low if velocity mapping exact | +|---|---:|---:|---:| +| q=0 | -0.167484 | 0.908090 | 1.470564 | +| q=1 | -0.478008 | 0.759448 | 3.006134 | + +Thus q=1 requires a 24.1% drop in the peak-to-flat speed ratio, or a factor 3.01 increase in the catalogue-to-true mass ratio, if one nuisance mapping carries the entire discrepancy. These are conditional requirements. The table provides no calibrated prior probability for either adjustment, and combinations are possible. + +Changing q by d and cv by -d x/4 leaves every predicted y unchanged. This exact degeneracy prevents identifying q when the velocity mapping may evolve freely. An external normalization at z=0 does not remove it because x(0)=0. + +For completeness, descriptive residual RMS after a fitted common intercept is 0.362879 dex for q=0 and 0.414987 dex for q=1 across all 135 rows. The low/high subset gives 0.369637 and 0.431473 dex. These distances describe point estimates under the stated proxy. They are not likelihoods or model probabilities. + +## Source definitions and sample limitations + +The [published article](https://www.mpe.mpg.de/~saglia/journals_pdf/uebler2017.pdf) supplies these definitions. Stellar masses use population synthesis and a Chabrier IMF. Gas masses use a scaling relation depending on redshift and galaxy properties (page 3, Section 2.2). Vcirc is the modeled maximum, including pressure support, and the authors discuss the absence of flat outer curves (pages 3 to 4). + +The 135 objects follow cuts from 240 modeled galaxies and 536 observations (pages 3 to 4). Only 56.25% of the modeled parent sample remains. Published comparisons demonstrate sensitivity to selection and pressure support (pages 8 and 12). The sample has different star-formation offsets across redshift (page 5). These facts prevent treating it as a random sample of all galaxies. + +The paper uses Omega_m=0.3 and H0=70. This diagnostic uses the requested Omega_m=0.315 only in E(z), without rescaling catalogue masses or speeds. Individual distance and modeling inputs are absent. Page 11 discusses missing atomic gas and mass systematics. The catalogue also lacks per-object errors, joint covariance and resolved radii. + +## Reproduce + +Place these files next to the existing kmos_inventory.py and obtain the source TSV through the published input contract. The diagnostic itself uses Python's standard library. Matplotlib is needed only for the figure. + +```sh +python3 kmos_diagnostic.py /path/to/kmos-table3.tsv --output results +python3 -m unittest discover -p 'test_kmos_diagnostic.py' -v +python3 -m pip install -r plot-requirements.txt +python3 kmos_diagnostic.py /path/to/kmos-table3.tsv --output results --plot +``` + +The script asserts the input hash, counts, compatible published summaries, positive approximate rotation speeds, complete speed-bin coverage and algebraic identities. Four unit tests check synthetic q laws, calibration signs and powers, the exact degeneracy, and bin boundaries. + +The generated JSON contains full precision, checks and limitations. The PNG and PDF show derived diagnostics without redistributing the raw catalogue or article. + +A physical inference next needs independent constraints on the velocity and gas mappings, individual correlated errors and a selection model. Resolved profiles could support a different radial-acceleration test. Until those inputs are present, the executable result is the proxy trend and the calibration change required by each template. diff --git a/research/galaxy-calibration/data-contract.json b/research/galaxy-calibration/data-contract.json new file mode 100644 index 0000000..4cd0f4d --- /dev/null +++ b/research/galaxy-calibration/data-contract.json @@ -0,0 +1,55 @@ +{ + "version": 1, + "purpose": "Reconstruct galaxy acceleration fits only after survey inputs and their joint uncertainty are verified.", + "selection_size": { + "study": "MUSE-DARK III RAR sample", + "reported_size": 79, + "requirement": "Verify membership for replication of this specific result. Other studies must declare their own selection." + }, + "products": { + "photometry": { + "filename_hint": "photometry_catalogue.txt", + "required_fields": [ + "muse_id", + "redshift", + "log_stellar_mass", + "star_formation_rate" + ] + }, + "halo_fit": { + "filename_hint": "DC14_bestfit.txt", + "required_fields": [ + "muse_id", + "halo_model", + "log_virial_mass", + "log_stellar_to_halo_mass_ratio" + ] + }, + "selection": { + "required_fields": [ + "muse_id", + "selection_reason" + ] + }, + "joint_uncertainty": { + "required_fields": [ + "muse_id", + "joint_draw_id", + "radius", + "baryonic_acceleration", + "observed_acceleration" + ], + "alternatives": [ + "Joint posterior draws with shared nuisance parameters", + "Original cubes, variance, PSF and photometry plus a validated reconstructed likelihood" + ] + } + }, + "rules": [ + "Field names above describe normalized roles, not verified release column names.", + "Declare original columns, units, transformations, missing values and model identifiers before normalization.", + "Scalar 95 percent intervals do not establish joint uncertainty.", + "A model-dependent reconstruction is not an independent measurement of the force law.", + "Never substitute all parent rows for the selected 79 galaxies." + ] +} diff --git a/research/galaxy-calibration/independent-review/REVIEW.md b/research/galaxy-calibration/independent-review/REVIEW.md new file mode 100644 index 0000000..e3b8346 --- /dev/null +++ b/research/galaxy-calibration/independent-review/REVIEW.md @@ -0,0 +1,49 @@ +# Independent review of the KMOS3D point-table diagnostic + +**Disposition: no blocking scientific or computational defect found.** The reported proxy contrast and required calibration shifts are reproducible for the selected 135-row catalogue. They do not establish a physical acceleration-scale trend, an estimate of \(q\), or a statistical preference between the two templates. + +Reviewed 12 November 2026 by gpt-forge using gpt-6-astra. Every file hash in `public-manifest.json` was verified before review. [evidence.json](evidence.json) records the exact hashes and independent aggregate checks. The source catalogue remains outside the review artifacts. + +## Independent numerical checks + +[check.py](check.py) parses the input directly and imports neither the author's diagnostic nor the inventory code. It independently confirms the canonical numeric hash, the 65/24/46 group sizes, and the contrast computed in catalogue units so that the additive SI conversion cancels. + +| Quantity | Independent value | +|---|---:| +| High-minus-low mean \(\log_{10}E\) | 0.310524417768 | +| High-minus-low mean proxy | -0.167483891033 dex | +| Conventional-median proxy contrast | -0.155734942472 dex | +| Stellar-only proxy contrast | -0.003641081668 dex | +| Gas mass-boost difference | 0.163842809365 dex | +| Required velocity-factor ratio for \(q=1\), masses exact | 0.759447790273 | +| Required mass-factor ratio for \(q=1\), velocities exact | 3.006133814591 | + +The three speed-bin counts and contrasts also match. The common-intercept RMS values reproduce to floating-point precision. The identities \(\Delta y=\Delta y_\star-\Delta\log(M_b/M_\star)\) and \(\Delta y-q\Delta x=4\Delta c_v-\Delta c_m\) have the reported signs and powers. + +The author's executable was replayed into a separate review directory. Its output agrees with the frozen JSON. This replay is separate from the independent parser and algebra checks. + +## Source interpretation + +The primary [Übler et al. article](https://arxiv.org/html/1703.04321v2), sections II.2–II.4, defines the catalogue velocity as the maximum modeled circular speed including pressure support. It also states the rotation cut as \(v_{\rm rot,max}/\sigma_0>\sqrt{4.4}\). The catalogue is selected from a larger observed and modeled parent sample. + +The report correctly treats peak speed as a different input from an independently measured asymptotic circular speed. The paper discusses approximate comparisons between velocity measures, but those comparisons do not supply a per-galaxy asymptotic-speed calibration and joint error model for this diagnostic. + +The gas contribution is based on a redshift-dependent scaling relation. The nearly complete algebraic accounting of the baryonic proxy contrast by that contribution is therefore informative about the construction of the catalogue. It is not evidence by itself that the gas estimates are biased or that the true gas evolution is absent. + +The catalogue lacks the per-row uncertainty and covariance information needed to reproduce the published error-weighted regression. The report clearly separates its unweighted summaries from that regression and does not promote residual RMS into a likelihood. The different background cosmology is also disclosed. + +## Rounding and unresolved selection reconstruction + +An additional review check allows each tabulated velocity to vary by half its 0.1 km/s reporting unit and each log baryonic mass by half its 0.01 dex reporting unit. The high-minus-low mean proxy remains in \([-0.178237,-0.156731]\) dex throughout that rounding box. + +This is only a bound on tabulation rounding. It is not a measurement-error interval and does not account for modeling, sample selection, mass calibration or correlated uncertainties. + +The reported approximate rotation-cut failure for Seq 6 persists over the rounding box: \(4.4\sigma_0^2/V_{\rm circ}^2\) lies between 0.509128 and 0.510808, above 0.5. The author correctly keeps the row and labels the peak-radius reconstruction approximate. Inferring an exact survey-selection error from this calculation would be unwarranted. + +The upper-middle order statistic is compatible with the published even-sized group summaries. The ordinary medians remain recorded. This is a plausible reproduction convention, not proof of which median implementation the original authors used. + +## What can be published and what remains open + +The publishable result is the bounded proxy contrast, its stated sensitivity checks, and the calibration change that each conditional template would require. An unconstrained redshift-dependent velocity mapping absorbs any change in \(q\), as the report shows. A local normalization alone does not remove that freedom. + +The exact contrasts do not supply the missing likelihood or external calibration bounds. Further numerical fitting of \(q\) to these same point estimates would not answer the physical question. Useful next work requires independent velocity/gas calibration, correlated measurement information and a defensible selection model, or resolved profiles for a different radial-acceleration analysis. diff --git a/research/galaxy-calibration/independent-review/check.py b/research/galaxy-calibration/independent-review/check.py new file mode 100644 index 0000000..4033a81 --- /dev/null +++ b/research/galaxy-calibration/independent-review/check.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python3 +"""Independent KMOS parsing and contrast checks, with no author imports. + +The input remains outside the review output. Only aggregate derived values and +hashes are written. Pass the separately obtained TSV as the first argument. +""" +import csv +import hashlib +import json +import math +from pathlib import Path +from statistics import mean, median +import sys + +HERE=Path(__file__).resolve().parent +AUTHOR=HERE.parent + + +def main(): + path=Path(sys.argv[1]) + manifest=json.loads((AUTHOR/'public-manifest.json').read_text()) + hashes={} + for f in manifest['files']: + actual=hashlib.sha256((AUTHOR/f['path']).read_bytes()).hexdigest() + assert actual==f['sha256'],f['path'] + hashes[f['path']]=actual + lines=[ln for ln in path.read_text().splitlines() if ln.strip() and not ln.startswith('#')] + header=next(csv.reader([lines[0]],delimiter='\t')) + rows=[dict(zip(header,map(float,cells))) for cells in csv.reader(lines[3:],delimiter='\t')] + canonical=hashlib.sha256(json.dumps(rows,sort_keys=True,separators=(',',':'),allow_nan=False).encode()).hexdigest() + assert canonical=='afadb1ef14ab6b88ce492f3fbf53d7d81e30fe178dcab6642aafdd1744c918f3' + groups=[[r for r in rows if a=.5: + frac_min=4.4*((r['sigma0']-.05)/(r['Vcirc']+.05))**2 + frac_max=4.4*((r['sigma0']+.05)/(r['Vcirc']-.05))**2 + bad.append({'Seq':int(r['Seq']),'fraction':frac,'rounding_bounds':[frac_min,frac_max]}) + assert len(bad)==1 and bad[0]['Seq']==6 and bad[0]['rounding_bounds'][0]>.5 + # Common-intercept residual RMS reproduced separately. + rms={} + for q in [0,1]: + residuals=[y(r)-q*x(r) for r in rows] + center=mean(residuals) + rms[str(q)]=math.sqrt(mean((z-center)**2 for z in residuals)) + assert abs(rms[str(q)]-saved['q_scores']['all_135'][str(q)]['descriptive_rms_dex'])<1e-13 + result={'source_hashes':hashes,'numeric_input_sha256':canonical, + 'delta_x':dx,'delta_y_dex':dy,'median_delta_y_dex':median(map(y,hi))-median(map(y,lo)), + 'stellar_delta_y_dex':stellar,'gas_algebraic_contribution_dex':gas, + 'calibration_contrasts':contrasts,'speed_bins':bins, + 'descriptive_rms':rms, + 'rounding_only_delta_y_enclosure_dex':[lower,upper], + 'rotation_cut_approximation_failures':bad, + 'disposition':'Point diagnostics reproduced. No likelihood, measurement of a0, or inference on q is established.'} + (HERE/'evidence.json').write_text(json.dumps(result,indent=2)+'\n') + print(json.dumps({k:v for k,v in result.items() if k!='source_hashes'},indent=2)) + + +if __name__=='__main__':main() diff --git a/research/galaxy-calibration/independent-review/evidence.json b/research/galaxy-calibration/independent-review/evidence.json new file mode 100644 index 0000000..fb948cc --- /dev/null +++ b/research/galaxy-calibration/independent-review/evidence.json @@ -0,0 +1,74 @@ +{ + "source_hashes": { + "ANALYSIS-PLAN.md": "39bc22224e1d729411ed3c71f3f1b65a0b4531ab83ba2b723dd22111c6953b5b", + "REPRODUCTION-NOTES.md": "23c89323bf134ef635d034c4d5c3b5fda1b3d8ade470d132168f85f66f203890", + "RESULTS.md": "ae14630267f08a8797c815d2d27977f5a13960613896afea70111c76ad478559", + "kmos_diagnostic.py": "facda3d2ac5bd68adf7f7221b88bc377550d2405861f6e245effdf58f5907203", + "test_kmos_diagnostic.py": "c1310f2b2e864e6bb042c8391d10c9b53bf447a25af72805a091b6140bed7185", + "plot-requirements.txt": "12a0a7bc6e1b1254c2f593a250e6ccff4dbd3cf0b27d6819696a9db86f4e530d", + "sources.json": "6ea8f69395419c584a315aa661ccd5ab28ff07c71877496404c9c8bdaba7abab", + "results/kmos-diagnostic.json": "d52cb2ca253b480cf65ad79918e6ae222a22c58d270c9be70c42dae5af787878", + "results/kmos-diagnostic.png": "91553d6cd43145251194e094fb5d5198662d2b3a43858cf4ebaa57ca344d1884", + "results/kmos-diagnostic.pdf": "fdf2fef192c97be29e009a5203c356fec59b10739b578ded5fc56a9e06bfa940" + }, + "numeric_input_sha256": "afadb1ef14ab6b88ce492f3fbf53d7d81e30fe178dcab6642aafdd1744c918f3", + "delta_x": 0.31052441776803963, + "delta_y_dex": -0.16748389103276362, + "median_delta_y_dex": -0.1557349424719634, + "stellar_delta_y_dex": -0.003641081668215196, + "gas_algebraic_contribution_dex": 0.16384280936454845, + "calibration_contrasts": { + "0": { + "residue_dex": -0.16748389103276362, + "velocity_factor": 0.9080902802801148, + "mass_factor": 1.4705638678440849 + }, + "1": { + "residue_dex": -0.47800830880080325, + "velocity_factor": 0.7594477902733978, + "mass_factor": 3.006133814591117 + } + }, + "speed_bins": [ + { + "counts": [ + 20, + 10 + ], + "delta_y_dex": -0.22426402102780063 + }, + { + "counts": [ + 29, + 26 + ], + "delta_y_dex": -0.18803323069313627 + }, + { + "counts": [ + 16, + 10 + ], + "delta_y_dex": -0.18621449746173857 + } + ], + "descriptive_rms": { + "0": 0.3628788107170332, + "1": 0.41498661120128355 + }, + "rounding_only_delta_y_enclosure_dex": [ + -0.1782371634118185, + -0.1567306019862822 + ], + "rotation_cut_approximation_failures": [ + { + "Seq": 6, + "fraction": 0.5099673055989798, + "rounding_bounds": [ + 0.5091280450934996, + 0.5108076087801534 + ] + } + ], + "disposition": "Point diagnostics reproduced. No likelihood, measurement of a0, or inference on q is established." +} diff --git a/research/galaxy-calibration/independent-review/review-checkpoint.json b/research/galaxy-calibration/independent-review/review-checkpoint.json new file mode 100644 index 0000000..5814cfa --- /dev/null +++ b/research/galaxy-calibration/independent-review/review-checkpoint.json @@ -0,0 +1,5 @@ +{ + "REVIEW.md": "11c53af456fb2c569b8a67f308ed851a3d079a71d5d7027cc89c1241d9f4d009", + "check.py": "3af93ab6c85c94a4af0c9a63ae548b6ad045eb47635dd6a0f6b6d3b0ba5c23b7", + "evidence.json": "dada6305752f200856acd71482ba71e1a8bf448ab3fc6e423159e96681b91cb1" +} diff --git a/research/galaxy-calibration/kmos-retrieval.json b/research/galaxy-calibration/kmos-retrieval.json new file mode 100644 index 0000000..6c6e312 --- /dev/null +++ b/research/galaxy-calibration/kmos-retrieval.json @@ -0,0 +1,47 @@ +{ + "catalogue": "J/ApJ/842/121/table3", + "rows": 135, + "bytes": 8472, + "sha256": "439100b80e7907a4e8f45b9a39e0737e9fb73597e0746d6faf8798682d186852", + "ranges": { + "z": [ + 0.602, + 2.529 + ], + "logM*": [ + 9.53, + 11.46 + ], + "logMb": [ + 9.81, + 11.63 + ], + "Vcirc": [ + 111.6, + 476.1 + ], + "sigma0": [ + 1.0, + 158.9 + ] + }, + "adequacy": { + "tully_fisher_diagnostic": true, + "radial_acceleration_relation": false, + "joint_inference": false + }, + "missing": [ + "measurement uncertainty columns", + "radius profiles", + "joint posterior or covariance" + ], + "no_new_fit": true, + "retrieved_utc": "2026-11-12T23:08:00Z", + "source_url": "https://vizier.cfa.harvard.edu/viz-bin/asu-tsv?-source=J/ApJ/842/121/table3&-out.all&-out.max=unlimited", + "source_doi": "10.26093/cds/vizier.18420121", + "paper_bibcode": "2017ApJ...842..121U", + "rights_url": "https://cds.unistra.fr/vizier-org/licences_vizier.html", + "distribution": "Original bytes kept outside repository. Hash includes request timestamp, so later retrieval hashes may differ. Compare schema, membership and ranges independently.", + "numeric_rows_sha256": "afadb1ef14ab6b88ce492f3fbf53d7d81e30fe178dcab6642aafdd1744c918f3", + "numeric_rows_serialization": "UTF-8 JSON list in received row order; parsed floats; sorted object keys; compact separators; no NaN" +} diff --git a/research/galaxy-calibration/kmos_diagnostic.py b/research/galaxy-calibration/kmos_diagnostic.py new file mode 100644 index 0000000..d535136 --- /dev/null +++ b/research/galaxy-calibration/kmos_diagnostic.py @@ -0,0 +1,184 @@ +"""Descriptive KMOS3D peak-speed diagnostic. See ANALYSIS-PLAN.md for scope. + +Requires sibling kmos_inventory.py from the published input contract. +No measurement likelihood or uncertainty interval is constructed. +""" +import argparse +import csv +import hashlib +import json +import math +from pathlib import Path +from statistics import mean, median, pstdev +import sys + +CANONICAL = 'afadb1ef14ab6b88ce492f3fbf53d7d81e30fe178dcab6642aafdd1744c918f3' +G = 6.67430e-11 # SI, CODATA 2018 +MSUN = 1.98847e30 # kg; cancels from every redshift contrast +VREF = 242.0 +BIN_EDGES = (100.0, 200.0, 300.0, 500.0) +PUBLISHED = { + 'low': {'n': 65, 'logM*': 10.49, 'logMb': 10.62, 'Vcirc': 239, 'sigma0': 30, 'b_star': 10.49, 'b_baryon': 10.68}, + 'mid': {'n': 24, 'logM*': 10.72, 'logMb': 10.97, 'Vcirc': 263, 'sigma0': 47}, + 'high': {'n': 46, 'logM*': 10.51, 'logMb': 10.89, 'Vcirc': 260, 'sigma0': 49, 'b_star': 10.51, 'b_baryon': 10.85}, +} + + +def evolution(z): + return math.sqrt(0.315 * (1 + z) ** 3 + 0.685) + + +def group_name(z): + return 'low' if z < 1.2 else 'mid' if z < 1.8 else 'high' + + +def load_rows(path): + # Validate with the original parser; extraction below does not replace its checks. + from kmos_inventory import summarize, COLUMNS + payload = path.read_bytes() + inventory = summarize(payload) + if inventory['numeric_rows_sha256'] != CANONICAL: + raise ValueError('numeric catalogue differs from the frozen input') + lines = [s for s in payload.decode('utf-8').splitlines() if s.strip() and not s.startswith('#')] + rows = [dict(zip(COLUMNS, map(float, values))) for values in csv.reader(lines[3:], delimiter='\t')] + for r in rows: + r['group'] = group_name(r['z']) + r['x'] = math.log10(evolution(r['z'])) + r['lv'] = math.log10(r['Vcirc'] / VREF) + r['b_star'] = r['logM*'] - 3.60 * r['lv'] + r['b_baryon'] = r['logMb'] - 3.75 * r['lv'] + r['b4'] = r['logMb'] - 4.0 * r['lv'] + r['y'] = 4 * math.log10(r['Vcirc'] * 1000) - math.log10(G * MSUN) - r['logMb'] + r['y_star'] = r['y'] + r['logMb'] - r['logM*'] + r['log_mass_boost'] = r['logMb'] - r['logM*'] + r['gas_fraction'] = 1.0 - 10 ** (-r['log_mass_boost']) + r['pressure_fraction'] = 4.4 * (r['sigma0'] / r['Vcirc']) ** 2 + if not (0 <= r['pressure_fraction'] < 1.0): + raise ValueError('rotation-speed reconstruction is not positive') + r['rotation_proxy'] = r['Vcirc'] * math.sqrt(1 - r['pressure_fraction']) + r['y_rotation'] = r['y'] + 2 * math.log10(1 - r['pressure_fraction']) + return inventory, rows + + +def group_summary(rs, label): + p = PUBLISHED[label] + assert len(rs) == p['n'] + medians = {k: median(r[k] for r in rs) for k in ['logM*', 'logMb', 'Vcirc', 'sigma0']} + checks = {} + upper_medians = {k: sorted(r[k] for r in rs)[len(rs)//2] for k in medians} + for k, val in upper_medians.items(): + tolerance = 0.015 if k.startswith('log') else 1.0 + checks[k] = {'calculated': val, 'published': p[k], 'tolerance': tolerance, 'passes': abs(val-p[k]) <= tolerance} + assert all(c['passes'] for c in checks.values()), (label, checks) + fields = ['x', 'y', 'y_star', 'y_rotation', 'b_star', 'b_baryon', 'b4', 'log_mass_boost', 'gas_fraction', 'pressure_fraction', 'rotation_proxy'] + return {'n': len(rs), 'redshift_range': [min(r['z'] for r in rs), max(r['z'] for r in rs)], 'redshift_mean': mean(r['z'] for r in rs), 'table1_checks_upper_central_order_statistic': checks, 'conventional_input_medians':medians, + 'mean': {k: mean(r[k] for r in rs) for k in fields}, 'median': {k: median(r[k] for r in rs) for k in fields}, + 'point_scatter_population_sd_y': pstdev(r['y'] for r in rs), + 'table2_mean_residual_minus_published': {k: mean(r[k] for r in rs)-p[k] for k in ['b_star', 'b_baryon'] if k in p}} + + +def q_scores(rs): + out = {} + for q in (0, 1): + intercept = mean(r['y'] - q*r['x'] for r in rs) + out[str(q)] = {'unweighted_intercept_log10_SI': intercept, 'descriptive_rms_dex': math.sqrt(mean((r['y']-intercept-q*r['x'])**2 for r in rs))} + return out + + +def contrast(low, high, reducer=mean): + dx = reducer(r['x'] for r in high) - reducer(r['x'] for r in low) + dy = reducer(r['y'] for r in high) - reducer(r['y'] for r in low) + return {'delta_x': dx, 'delta_y_dex': dy, 'delta_b4_dex': -dy, + 'q_comparisons': {str(q): {'predicted_delta_y_dex': q*dx, 'observed_minus_predicted_dex': dy-q*dx, + 'required_Vpeak_over_Vflat_high_to_low_ratio_if_mass_exact': 10**((dy-q*dx)/4), + 'required_Mtab_over_Mtrue_high_to_low_ratio_if_velocity_exact': 10**(-(dy-q*dx))} for q in (0,1)}} + + +def analyze(inventory, rows): + groups = {k: [r for r in rows if r['group']==k] for k in PUBLISHED} + gs = {k: group_summary(rs,k) for k,rs in groups.items()} + low, high = groups['low'], groups['high'] + bins = [] + for lo, hi in zip(BIN_EDGES[:-1], BIN_EDGES[1:]): + l = [r for r in low if lo <= r['Vcirc'] < hi] + h = [r for r in high if lo <= r['Vcirc'] < hi] + assert l and h, 'each frozen velocity bin must be populated' + bins.append({'velocity_bin_kms': [lo,hi], 'counts': {'low':len(l),'high':len(h)}, **contrast(l,h)}) + assert sum(b['counts']['low'] for b in bins)==len(low) + assert sum(b['counts']['high'] for b in bins)==len(high) + low_to_high = contrast(low,high) + pressure_delta = mean(r['y_rotation'] for r in high)-mean(r['y_rotation'] for r in low) + stellar_delta = mean(r['y_star'] for r in high)-mean(r['y_star'] for r in low) + gas_delta = mean(r['log_mass_boost'] for r in high)-mean(r['log_mass_boost'] for r in low) + assert math.isclose(low_to_high['delta_y_dex'], stellar_delta-gas_delta, abs_tol=1e-13) + # Algebraic nuisance degeneracy: changing q by dq and cv by -dq*x/4 preserves y. + for r in rows: + assert math.isclose(0.731*r['x']+4*(-0.731*r['x']/4),0,abs_tol=1e-15) + return {'analysis_type':'descriptive point-table diagnostic; no q inference', 'input':inventory, + 'constants':{'G_SI':G,'Msun_kg':MSUN,'vref_kms':VREF,'Omega_m_for_evolution':0.315}, + 'groups':gs,'primary_low_to_high':low_to_high, + 'sensitivity':{'median_low_to_high':contrast(low,high,median), 'velocity_bins': bins, + 'equal_velocity_bin_weight':{'delta_y_dex':mean(b['delta_y_dex'] for b in bins),'delta_x':mean(b['delta_x'] for b in bins)}, + 'stellar_mass_proxy_delta_y_dex':stellar_delta, 'catalogue_gas_mass_boost_delta_dex':gas_delta, + 'rotation_proxy_delta_y_dex':pressure_delta, + 'pressure_removal_changes_delta_y_by_dex':pressure_delta-low_to_high['delta_y_dex']}, + 'q_scores':{'all_135':q_scores(rows),'low_high_111':q_scores(low+high)}, + 'rotation_cut_reconstruction_failures':[{'Seq':r['Seq'],'pressure_fraction':r['pressure_fraction'],'reconstructed_vrot_over_sigma0':r['rotation_proxy']/r['sigma0']} for r in rows if r['pressure_fraction']>=0.5], + 'selection_accounting':{'observed':536,'resolved_uncontaminated':316,'modeled_parent':240,'peak_covered':149,'rotation_dominated':139,'final':135,'final_fraction_of_modeled_parent':135/240,'final_fraction_of_observed':135/536}, + 'assertions': ['canonical numeric input hash','65/24/46 groups','12 Table 1 central summaries matched by upper-middle convention; ordinary medians also recorded','positive approximate rotation speed; cut failures reported','all low/high rows in three populated fixed speed bins','stellar-minus-gas decomposition','q-velocity-calibration degeneracy'], + 'limitations':['Vcirc is modeled peak, not measured asymptotic speed','gas mass uses empirical redshift-dependent scaling','no row errors or covariance','no resolved radii or accelerations','selected sample only; no individual parent selection probabilities','published cosmology differs; no mass or speed distance rescaling attempted','no fitted q or confidence interval','descriptive RMS is not model evidence']} + + +def make_figure(rows, result, output): + import matplotlib + matplotlib.use('Agg') + import matplotlib.pyplot as plt + colors = {'low':'#1764a3','mid':'#737373','high':'#ba3c39'} + fig, axes = plt.subplots(1,2,figsize=(12.5,5.0),layout='constrained') + ax = axes[0] + for group, color in colors.items(): + rs = [r for r in rows if r['group']==group] + ax.scatter([r['x'] for r in rs],[r['y']+10 for r in rs],s=17,alpha=.55,c=color,label=f'{group}: n={len(rs)}') + m = result['groups'][group]['mean'] + ax.scatter(m['x'],m['y']+10,marker='D',s=70,c=color,edgecolor='white',zorder=4) + low = result['groups']['low']['mean'] + xs = [0.1,0.6] + for q, ls in [(0,'--'),(1,'-')]: + ax.plot(xs,[low['y']+10+q*(x-low['x']) for x in xs],color='#222222',linestyle=ls,label=f'q={q}, anchored to low mean') + ax.set(xlabel=r'$\log_{10}E(z)$',ylabel=r'$\log_{10}[(V_{\rm peak}^{4}/G M_{\rm tab})/(10^{-10}\,{\rm m\,s^{-2}})]$',title='Catalogue proxy and fixed evolution templates') + ax.legend(fontsize=8,loc='lower left') + ax.grid(alpha=.18) + ax = axes[1] + primary = result['primary_low_to_high'] + labels = ['q=0 template','q=1 template','Point mean','Point median','Fixed speed-bin weights','Stellar mass only','Rotation proxy'] + vals = [0,primary['delta_x'],primary['delta_y_dex'],result['sensitivity']['median_low_to_high']['delta_y_dex'],result['sensitivity']['equal_velocity_bin_weight']['delta_y_dex'],result['sensitivity']['stellar_mass_proxy_delta_y_dex'],result['sensitivity']['rotation_proxy_delta_y_dex']] + ax.barh(labels,vals,color=['#555555','#999999','#1764a3','#1764a3','#1764a3','#8b721f','#805299']) + ax.axvline(0,color='#333333',lw=.8) + ax.invert_yaxis() + ax.set(xlabel='High minus low proxy shift (dex)',title='Sensitivity checks; no confidence intervals') + ax.grid(axis='x',alpha=.18) + fig.suptitle('KMOS3D: peak-speed proxy is not an a₀ measurement',fontsize=15) + for ext in ['png','pdf']: + fig.savefig(output/f'kmos-diagnostic.{ext}',dpi=180) + plt.close(fig) + + +def main(): + ap=argparse.ArgumentParser(description=__doc__) + ap.add_argument('table',type=Path) + ap.add_argument('--inventory-dir',type=Path,default=Path(__file__).resolve().parent) + ap.add_argument('--output',type=Path,default=Path('.')) + ap.add_argument('--plot',action='store_true') + args=ap.parse_args() + sys.path.insert(0,str(args.inventory_dir.resolve())) + inventory,rows=load_rows(args.table) + result=analyze(inventory,rows) + result['code_sha256']=hashlib.sha256(Path(__file__).read_bytes()).hexdigest() + plan=Path(__file__).with_name('ANALYSIS-PLAN.md') + result['frozen_plan_sha256']=hashlib.sha256(plan.read_bytes()).hexdigest() + args.output.mkdir(parents=True,exist_ok=True) + (args.output/'kmos-diagnostic.json').write_text(json.dumps(result,indent=2,allow_nan=False)+'\n') + if args.plot: make_figure(rows,result,args.output) + print(json.dumps({'primary':result['primary_low_to_high'],'sensitivity':result['sensitivity'],'q_scores':result['q_scores']},indent=2)) + +if __name__=='__main__': main() diff --git a/research/galaxy-calibration/kmos_inventory.py b/research/galaxy-calibration/kmos_inventory.py new file mode 100644 index 0000000..94f1607 --- /dev/null +++ b/research/galaxy-calibration/kmos_inventory.py @@ -0,0 +1,41 @@ +"""Validate a separately downloaded CDS KMOS table and report input adequacy.""" +import argparse +import hashlib +import json +import math +from pathlib import Path + +URL = 'https://vizier.cfa.harvard.edu/viz-bin/asu-tsv?-source=J/ApJ/842/121/table3&-out.all&-out.max=unlimited' +COLUMNS = ['recno', 'Seq', 'z', 'logM*', 'logMb', 'Vcirc', 'sigma0'] + + +def summarize(payload): + lines = payload.decode('utf-8').splitlines() + if '#Name: J/ApJ/842/121/table3' not in lines: + raise ValueError('wrong catalogue') + table = [line for line in lines if line.strip() and not line.startswith('#')] + if table[0].split('\t') != COLUMNS: + raise ValueError('unexpected columns') + if [cell.strip() for cell in table[1].split('\t')] != ['', '', '', '[Msun]', '[Msun]', 'km/s', 'km/s']: + raise ValueError('unexpected units') + rows = [] + for line in table[3:]: + cells = line.split('\t') + if len(cells) != len(COLUMNS): + raise ValueError('bad row width') + row = dict(zip(COLUMNS, map(float, cells))) + if not all(math.isfinite(x) for x in row.values()): + raise ValueError('nonfinite value') + if row['z'] <= 0 or row['Vcirc'] <= 0 or row['sigma0'] < 0 or row['logMb'] < row['logM*']: + raise ValueError('invalid physical input') + rows.append(row) + if len(rows) != 135 or {r['Seq'] for r in rows} != set(range(1, 136)): + raise ValueError('unexpected sample membership') + return {'catalogue': 'J/ApJ/842/121/table3', 'rows': len(rows), 'bytes': len(payload), 'sha256': hashlib.sha256(payload).hexdigest(), 'numeric_rows_sha256': hashlib.sha256(json.dumps(rows, sort_keys=True, separators=(',', ':'), allow_nan=False).encode('utf-8')).hexdigest(), 'numeric_rows_serialization': 'UTF-8 JSON list in received row order; parsed floats; sorted object keys; compact separators; no NaN', 'ranges': {c: [min(r[c] for r in rows), max(r[c] for r in rows)] for c in COLUMNS[2:]}, 'adequacy': {'tully_fisher_diagnostic': True, 'radial_acceleration_relation': False, 'joint_inference': False}, 'missing': ['measurement uncertainty columns', 'radius profiles', 'joint posterior or covariance'], 'no_new_fit': True} + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('table', type=Path) + args = parser.parse_args() + print(json.dumps(summarize(args.table.read_bytes()), indent=2)) diff --git a/research/galaxy-calibration/plot-requirements.txt b/research/galaxy-calibration/plot-requirements.txt new file mode 100644 index 0000000..5449ae0 --- /dev/null +++ b/research/galaxy-calibration/plot-requirements.txt @@ -0,0 +1 @@ +matplotlib==3.10.8 diff --git a/research/galaxy-calibration/public-manifest.json b/research/galaxy-calibration/public-manifest.json new file mode 100644 index 0000000..094a2fd --- /dev/null +++ b/research/galaxy-calibration/public-manifest.json @@ -0,0 +1,70 @@ +{ + "status": "author checkpoint complete; independent review pending", + "created_utc": "2026-11-12T23:24:39Z", + "files": [ + { + "path": "ANALYSIS-PLAN.md", + "bytes": 4089, + "sha256": "39bc22224e1d729411ed3c71f3f1b65a0b4531ab83ba2b723dd22111c6953b5b" + }, + { + "path": "REPRODUCTION-NOTES.md", + "bytes": 2815, + "sha256": "23c89323bf134ef635d034c4d5c3b5fda1b3d8ade470d132168f85f66f203890" + }, + { + "path": "RESULTS.md", + "bytes": 7465, + "sha256": "ae14630267f08a8797c815d2d27977f5a13960613896afea70111c76ad478559" + }, + { + "path": "kmos_diagnostic.py", + "bytes": 11193, + "sha256": "facda3d2ac5bd68adf7f7221b88bc377550d2405861f6e245effdf58f5907203" + }, + { + "path": "test_kmos_diagnostic.py", + "bytes": 1977, + "sha256": "c1310f2b2e864e6bb042c8391d10c9b53bf447a25af72805a091b6140bed7185" + }, + { + "path": "plot-requirements.txt", + "bytes": 19, + "sha256": "12a0a7bc6e1b1254c2f593a250e6ccff4dbd3cf0b27d6819696a9db86f4e530d" + }, + { + "path": "sources.json", + "bytes": 2265, + "sha256": "6ea8f69395419c584a315aa661ccd5ab28ff07c71877496404c9c8bdaba7abab" + }, + { + "path": "results/kmos-diagnostic.json", + "bytes": 14443, + "sha256": "d52cb2ca253b480cf65ad79918e6ae222a22c58d270c9be70c42dae5af787878" + }, + { + "path": "results/kmos-diagnostic.png", + "bytes": 163447, + "sha256": "91553d6cd43145251194e094fb5d5198662d2b3a43858cf4ebaa57ca344d1884" + }, + { + "path": "results/kmos-diagnostic.pdf", + "bytes": 28180, + "sha256": "fdf2fef192c97be29e009a5203c356fec59b10739b578ded5fc56a9e06bfa940" + } + ], + "exclusions": [ + "source-cache/", + ".venv/", + "__pycache__/", + "raw catalogue TSV", + "run-output.json" + ], + "validation": { + "unit_tests": 4, + "prose_results_and_reproduction_notes": "pass; duplicate-link check pass", + "figure_visual_inspection": "pass: readable labels and correct signs", + "source_visual_inspection": "published pages4,5 checked", + "independent_review": "pending" + } +} diff --git a/research/galaxy-calibration/results/kmos-diagnostic.json b/research/galaxy-calibration/results/kmos-diagnostic.json new file mode 100644 index 0000000..cc446c1 --- /dev/null +++ b/research/galaxy-calibration/results/kmos-diagnostic.json @@ -0,0 +1,453 @@ +{ + "analysis_type": "descriptive point-table diagnostic; no q inference", + "input": { + "catalogue": "J/ApJ/842/121/table3", + "rows": 135, + "bytes": 8472, + "sha256": "439100b80e7907a4e8f45b9a39e0737e9fb73597e0746d6faf8798682d186852", + "numeric_rows_sha256": "afadb1ef14ab6b88ce492f3fbf53d7d81e30fe178dcab6642aafdd1744c918f3", + "numeric_rows_serialization": "UTF-8 JSON list in received row order; parsed floats; sorted object keys; compact separators; no NaN", + "ranges": { + "z": [ + 0.602, + 2.529 + ], + "logM*": [ + 9.53, + 11.46 + ], + "logMb": [ + 9.81, + 11.63 + ], + "Vcirc": [ + 111.6, + 476.1 + ], + "sigma0": [ + 1.0, + 158.9 + ] + }, + "adequacy": { + "tully_fisher_diagnostic": true, + "radial_acceleration_relation": false, + "joint_inference": false + }, + "missing": [ + "measurement uncertainty columns", + "radius profiles", + "joint posterior or covariance" + ], + "no_new_fit": true + }, + "constants": { + "G_SI": 6.6743e-11, + "Msun_kg": 1.98847e+30, + "vref_kms": 242.0, + "Omega_m_for_evolution": 0.315 + }, + "groups": { + "low": { + "n": 65, + "redshift_range": [ + 0.602, + 1.032 + ], + "redshift_mean": 0.8835846153846154, + "table1_checks_upper_central_order_statistic": { + "logM*": { + "calculated": 10.49, + "published": 10.49, + "tolerance": 0.015, + "passes": true + }, + "logMb": { + "calculated": 10.62, + "published": 10.62, + "tolerance": 0.015, + "passes": true + }, + "Vcirc": { + "calculated": 239.1, + "published": 239, + "tolerance": 1.0, + "passes": true + }, + "sigma0": { + "calculated": 30.2, + "published": 30, + "tolerance": 1.0, + "passes": true + } + }, + "conventional_input_medians": { + "logM*": 10.49, + "logMb": 10.62, + "Vcirc": 239.1, + "sigma0": 30.2 + }, + "mean": { + "x": 0.2226579557083114, + "y": -9.280753201758108, + "y_star": -9.09829166329657, + "y_rotation": -9.419206430353135, + "b_star": 10.503796293572517, + "b_baryon": 10.688819857086756, + "b4": 10.693089898841258, + "log_mass_boost": 0.18246153846153848, + "gas_fraction": 0.330789228089916, + "pressure_fraction": 0.13372770923209717, + "rotation_proxy": 226.9780242382051 + }, + "median": { + "x": 0.2270857814384546, + "y": -9.236583570346093, + "y_star": -9.114871941502404, + "y_rotation": -9.338967427161199, + "b_star": 10.523856166837046, + "b_baryon": 10.658513183866596, + "b4": 10.648920267429244, + "log_mass_boost": 0.16999999999999993, + "gas_fraction": 0.3239170246080181, + "pressure_fraction": 0.08916318339100344, + "rotation_proxy": 232.85454687422362 + }, + "point_scatter_population_sd_y": 0.3558636827743031, + "table2_mean_residual_minus_published": { + "b_star": 0.01379629357251666, + "b_baryon": 0.008819857086756144 + } + }, + "mid": { + "n": 24, + "redshift_range": [ + 1.306, + 1.665 + ], + "redshift_mean": 1.521375, + "table1_checks_upper_central_order_statistic": { + "logM*": { + "calculated": 10.72, + "published": 10.72, + "tolerance": 0.015, + "passes": true + }, + "logMb": { + "calculated": 10.97, + "published": 10.97, + "tolerance": 0.015, + "passes": true + }, + "Vcirc": { + "calculated": 263.5, + "published": 263, + "tolerance": 1.0, + "passes": true + }, + "sigma0": { + "calculated": 46.8, + "published": 47, + "tolerance": 1.0, + "passes": true + } + }, + "conventional_input_medians": { + "logM*": 10.71, + "logMb": 10.935, + "Vcirc": 262.95, + "sigma0": 45.7 + }, + "mean": { + "x": 0.37898157615890526, + "y": -9.375108763785244, + "y_star": -9.113858763785244, + "y_rotation": -9.566803864079679, + "b_star": 10.535825914781553, + "b_baryon": 10.793464494564118, + "b4": 10.787445460868392, + "log_mass_boost": 0.26125, + "gas_fraction": 0.44024023635028464, + "pressure_fraction": 0.18302925817416546, + "rotation_proxy": 245.57831090228728 + }, + "median": { + "x": 0.3811961545955956, + "y": -9.403547007914021, + "y_star": -9.146134203634222, + "y_rotation": -9.509726337397705, + "b_star": 10.546991646025543, + "b_baryon": 10.81867712681325, + "b4": 10.815883704997173, + "log_mass_boost": 0.2400000000000002, + "gas_fraction": 0.4244075097270313, + "pressure_fraction": 0.1358112647601778, + "rotation_proxy": 242.14683393410846 + }, + "point_scatter_population_sd_y": 0.32905114642327177, + "table2_mean_residual_minus_published": {} + }, + "high": { + "n": 46, + "redshift_range": [ + 2.028, + 2.529 + ], + "redshift_mean": 2.2675434782608694, + "table1_checks_upper_central_order_statistic": { + "logM*": { + "calculated": 10.51, + "published": 10.51, + "tolerance": 0.015, + "passes": true + }, + "logMb": { + "calculated": 10.89, + "published": 10.89, + "tolerance": 0.015, + "passes": true + }, + "Vcirc": { + "calculated": 259.8, + "published": 260, + "tolerance": 1.0, + "passes": true + }, + "sigma0": { + "calculated": 48.9, + "published": 49, + "tolerance": 1.0, + "passes": true + } + }, + "conventional_input_medians": { + "logM*": 10.504999999999999, + "logMb": 10.879999999999999, + "Vcirc": 257.1, + "sigma0": 48.4 + }, + "mean": { + "x": 0.5331823734763511, + "y": -9.448237092790873, + "y_star": -9.101932744964785, + "y_rotation": -9.657559930655315, + "b_star": 10.519407715234445, + "b_baryon": 10.86378521061559, + "b4": 10.860573789874021, + "log_mass_boost": 0.34630434782608693, + "gas_fraction": 0.5395965924842935, + "pressure_fraction": 0.2025020577264158, + "rotation_proxy": 231.88794011248203 + }, + "median": { + "x": 0.5260645370997044, + "y": -9.392318512818058, + "y_star": -9.050051914683786, + "y_rotation": -9.588109157216259, + "b_star": 10.497843379602845, + "b_baryon": 10.818114259282382, + "b4": 10.80465520990121, + "log_mass_boost": 0.33999999999999986, + "gas_fraction": 0.5429118103851248, + "pressure_fraction": 0.19800805354142925, + "rotation_proxy": 235.29108467296714 + }, + "point_scatter_population_sd_y": 0.3665031295485444, + "table2_mean_residual_minus_published": { + "b_star": 0.00940771523444539, + "b_baryon": 0.013785210615591126 + } + } + }, + "primary_low_to_high": { + "delta_x": 0.31052441776803974, + "delta_y_dex": -0.16748389103276473, + "delta_b4_dex": 0.16748389103276473, + "q_comparisons": { + "0": { + "predicted_delta_y_dex": 0.0, + "observed_minus_predicted_dex": -0.16748389103276473, + "required_Vpeak_over_Vflat_high_to_low_ratio_if_mass_exact": 0.9080902802801143, + "required_Mtab_over_Mtrue_high_to_low_ratio_if_velocity_exact": 1.4705638678440887 + }, + "1": { + "predicted_delta_y_dex": 0.31052441776803974, + "observed_minus_predicted_dex": -0.47800830880080447, + "required_Vpeak_over_Vflat_high_to_low_ratio_if_mass_exact": 0.7594477902733974, + "required_Mtab_over_Mtrue_high_to_low_ratio_if_velocity_exact": 3.0061338145911254 + } + } + }, + "sensitivity": { + "median_low_to_high": { + "delta_x": 0.29897875566124976, + "delta_y_dex": -0.1557349424719643, + "delta_b4_dex": 0.1557349424719643, + "q_comparisons": { + "0": { + "predicted_delta_y_dex": 0.0, + "observed_minus_predicted_dex": -0.1557349424719643, + "required_Vpeak_over_Vflat_high_to_low_ratio_if_mass_exact": 0.9142527269412801, + "required_Mtab_over_Mtrue_high_to_low_ratio_if_velocity_exact": 1.4313140765987027 + }, + "1": { + "predicted_delta_y_dex": 0.29897875566124976, + "observed_minus_predicted_dex": -0.45471369813321405, + "required_Vpeak_over_Vflat_high_to_low_ratio_if_mass_exact": 0.7697001575702539, + "required_Mtab_over_Mtrue_high_to_low_ratio_if_velocity_exact": 2.849139397532756 + } + } + }, + "velocity_bins": [ + { + "velocity_bin_kms": [ + 100.0, + 200.0 + ], + "counts": { + "low": 20, + "high": 10 + }, + "delta_x": 0.31324696257205353, + "delta_y_dex": -0.22426402102779974, + "delta_b4_dex": 0.22426402102779974, + "q_comparisons": { + "0": { + "predicted_delta_y_dex": 0.0, + "observed_minus_predicted_dex": -0.22426402102779974, + "required_Vpeak_over_Vflat_high_to_low_ratio_if_mass_exact": 0.8788889307488543, + "required_Mtab_over_Mtrue_high_to_low_ratio_if_velocity_exact": 1.6759614351031706 + }, + "1": { + "predicted_delta_y_dex": 0.31324696257205353, + "observed_minus_predicted_dex": -0.5375109835998533, + "required_Vpeak_over_Vflat_high_to_low_ratio_if_mass_exact": 0.733875271576651, + "required_Mtab_over_Mtrue_high_to_low_ratio_if_velocity_exact": 3.4475532555719792 + } + } + }, + { + "velocity_bin_kms": [ + 200.0, + 300.0 + ], + "counts": { + "low": 29, + "high": 26 + }, + "delta_x": 0.3060039343734411, + "delta_y_dex": -0.1880332306931365, + "delta_b4_dex": 0.1880332306931365, + "q_comparisons": { + "0": { + "predicted_delta_y_dex": 0.0, + "observed_minus_predicted_dex": -0.1880332306931365, + "required_Vpeak_over_Vflat_high_to_low_ratio_if_mass_exact": 0.8974116276376577, + "required_Mtab_over_Mtrue_high_to_low_ratio_if_velocity_exact": 1.5418184229834493 + }, + "1": { + "predicted_delta_y_dex": 0.3060039343734411, + "observed_minus_predicted_dex": -0.4940371650665776, + "required_Vpeak_over_Vflat_high_to_low_ratio_if_mass_exact": 0.7524726316530131, + "required_Mtab_over_Mtrue_high_to_low_ratio_if_velocity_exact": 3.119156496761986 + } + } + }, + { + "velocity_bin_kms": [ + 300.0, + 500.0 + ], + "counts": { + "low": 16, + "high": 10 + }, + "delta_x": 0.32088149619101713, + "delta_y_dex": -0.18621449746173724, + "delta_b4_dex": 0.18621449746173724, + "q_comparisons": { + "0": { + "predicted_delta_y_dex": 0.0, + "observed_minus_predicted_dex": -0.18621449746173724, + "required_Vpeak_over_Vflat_high_to_low_ratio_if_mass_exact": 0.8983516620522243, + "required_Mtab_over_Mtrue_high_to_low_ratio_if_velocity_exact": 1.5353751152723547 + }, + "1": { + "predicted_delta_y_dex": 0.32088149619101713, + "observed_minus_predicted_dex": -0.5070959936527544, + "required_Vpeak_over_Vflat_high_to_low_ratio_if_mass_exact": 0.7468373023885772, + "required_Mtab_over_Mtrue_high_to_low_ratio_if_velocity_exact": 3.214370943958868 + } + } + } + ], + "equal_velocity_bin_weight": { + "delta_y_dex": -0.1995039163942245, + "delta_x": 0.31337746437883723 + }, + "stellar_mass_proxy_delta_y_dex": -0.003641081668215307, + "catalogue_gas_mass_boost_delta_dex": 0.16384280936454845, + "rotation_proxy_delta_y_dex": -0.23835350030218017, + "pressure_removal_changes_delta_y_by_dex": -0.07086960926941543 + }, + "q_scores": { + "all_135": { + "0": { + "unweighted_intercept_log10_SI": -9.354596108988911, + "descriptive_rms_dex": 0.3628788107170334 + }, + "1": { + "unweighted_intercept_log10_SI": -9.710853250683476, + "descriptive_rms_dex": 0.41498661120128366 + } + }, + "low_high_111": { + "0": { + "unweighted_intercept_log10_SI": -9.3501609403843, + "descriptive_rms_dex": 0.36963660688825406 + }, + "1": { + "unweighted_intercept_log10_SI": -9.70150469084333, + "descriptive_rms_dex": 0.4314728262620271 + } + } + }, + "rotation_cut_reconstruction_failures": [ + { + "Seq": 6.0, + "pressure_fraction": 0.5099673055989798, + "reconstructed_vrot_over_sigma0": 2.0562111012714146 + } + ], + "selection_accounting": { + "observed": 536, + "resolved_uncontaminated": 316, + "modeled_parent": 240, + "peak_covered": 149, + "rotation_dominated": 139, + "final": 135, + "final_fraction_of_modeled_parent": 0.5625, + "final_fraction_of_observed": 0.251865671641791 + }, + "assertions": [ + "canonical numeric input hash", + "65/24/46 groups", + "12 Table 1 central summaries matched by upper-middle convention; ordinary medians also recorded", + "positive approximate rotation speed; cut failures reported", + "all low/high rows in three populated fixed speed bins", + "stellar-minus-gas decomposition", + "q-velocity-calibration degeneracy" + ], + "limitations": [ + "Vcirc is modeled peak, not measured asymptotic speed", + "gas mass uses empirical redshift-dependent scaling", + "no row errors or covariance", + "no resolved radii or accelerations", + "selected sample only; no individual parent selection probabilities", + "published cosmology differs; no mass or speed distance rescaling attempted", + "no fitted q or confidence interval", + "descriptive RMS is not model evidence" + ], + "code_sha256": "facda3d2ac5bd68adf7f7221b88bc377550d2405861f6e245effdf58f5907203", + "frozen_plan_sha256": "39bc22224e1d729411ed3c71f3f1b65a0b4531ab83ba2b723dd22111c6953b5b" +} diff --git a/research/galaxy-calibration/results/kmos-diagnostic.pdf b/research/galaxy-calibration/results/kmos-diagnostic.pdf new file mode 100644 index 0000000..82e4ce5 Binary files /dev/null and b/research/galaxy-calibration/results/kmos-diagnostic.pdf differ diff --git a/research/galaxy-calibration/results/kmos-diagnostic.png b/research/galaxy-calibration/results/kmos-diagnostic.png new file mode 100644 index 0000000..d957c72 Binary files /dev/null and b/research/galaxy-calibration/results/kmos-diagnostic.png differ diff --git a/research/galaxy-calibration/retrieval-manifest.json b/research/galaxy-calibration/retrieval-manifest.json new file mode 100644 index 0000000..2e40723 --- /dev/null +++ b/research/galaxy-calibration/retrieval-manifest.json @@ -0,0 +1,34 @@ +{ + "version": 1, + "checked_date": "2026-11-12", + "status": "missing_data", + "source_revision": { + "astr0_main": "67cafe2", + "gravity_main": "364fa3e9f740f42acaa1991428ce043f547e10dd" + }, + "sources": [ + { + "url": "https://dark.univ-lyon1.fr/data-releases/", + "result": "Reachable. Links MUSE UDF sample to https://dark-matter.osu-lyon.fr/ and describes 126 galaxies." + }, + { + "url": "https://dark-matter.osu-lyon.fr/", + "result": "Web fetch timed out. Previous HTTPS and HTTP retrieval attempts also timed out. No catalogue obtained." + }, + { + "url": "https://doi.org/10.1051/0004-6361/202557396", + "result": "Primary publisher search record confirms best fit parameters and 95 percent intervals. Direct publisher page returned 403. Article describes 127 galaxies. Exact release membership remains unverified." + }, + { + "url": "https://cdsarc.cds.unistra.fr/viz-bin/cat/J/A+A/708/A112", + "result": "Candidate catalogue URL derived from journal identifier. Not linked by paper. Web tool inaccessible; no catalogue verified. System curl timed out after 15 seconds with HTTP 000 and zero bytes." + } + ], + "artifacts": [], + "limits": [ + "No original column schema verified.", + "No selected 79 membership verified.", + "No joint uncertainty product acquired.", + "No fit or observational result computed." + ] +} diff --git a/research/galaxy-calibration/sources.json b/research/galaxy-calibration/sources.json new file mode 100644 index 0000000..850d158 --- /dev/null +++ b/research/galaxy-calibration/sources.json @@ -0,0 +1,63 @@ +{ + "catalogue": { + "identifier": "J/ApJ/842/121/table3", + "doi": "10.26093/cds/vizier.18420121", + "citation": "Übler et al. (2017), ApJ 842,121", + "raw_data_redistributed": false, + "numeric_rows_sha256": "afadb1ef14ab6b88ce492f3fbf53d7d81e30fe178dcab6642aafdd1744c918f3" + }, + "article": { + "title": "The Evolution of the Tully-Fisher Relation between z ~ 2.3 and z ~ 0.9 with KMOS3D", + "doi": "10.3847/1538-4357/aa7558", + "arxiv": "https://arxiv.org/abs/1703.04321v2", + "url": "https://www.mpe.mpg.de/~saglia/journals_pdf/uebler2017.pdf", + "published_pdf_pages": 22, + "pdf_sha256": "2f88618d9524b066d2acf0896f51f424681f22af03deeb77ca7e13f98c5bfbc6", + "cached_utc_date": "2026-11-12", + "redistributed": false, + "page_map": { + "2": "assumed cosmology", + "3": "stellar/gas mass derivation, model velocity, pressure equation1, peak choice", + "4": "sample flow, rotation cut with square root, counts", + "5": "Table1 summaries, sample star-formation offsets", + "6": "Eq2 inverse regression and errors", + "8": "Table2 regression values and selection comparisons", + "11": "mass/atomic gas systematics, velocity uncertainty discussion", + "12": "peak-radius approximation and pressure effects", + "20": "Table3 column definitions" + }, + "visually_inspected_pages": [ + 4, + 5 + ] + }, + "frozen_plan": { + "sha256": "39bc22224e1d729411ed3c71f3f1b65a0b4531ab83ba2b723dd22111c6953b5b", + "meaning": "analysis scope frozen after reading published result but before computing row diagnostics" + }, + "execution": { + "python": "3.14.6", + "matplotlib": "3.10.8", + "dependencies": "standard library for calculations; matplotlib only for plotting" + }, + "publication_allowlist": [ + "ANALYSIS-PLAN.md", + "REPRODUCTION-NOTES.md", + "RESULTS.md", + "kmos_diagnostic.py", + "test_kmos_diagnostic.py", + "plot-requirements.txt", + "sources.json", + "results/kmos-diagnostic.json", + "results/kmos-diagnostic.png", + "results/kmos-diagnostic.pdf" + ], + "publication_exclusions": [ + "source-cache/", + ".venv/", + "__pycache__/", + "raw catalogue TSV", + "run-output.json" + ], + "independent_review_status": "requested; not complete" +} diff --git a/research/galaxy-calibration/test_kmos_diagnostic.py b/research/galaxy-calibration/test_kmos_diagnostic.py new file mode 100644 index 0000000..da1f417 --- /dev/null +++ b/research/galaxy-calibration/test_kmos_diagnostic.py @@ -0,0 +1,45 @@ +"""Identity and input-boundary tests, not an uncertainty model.""" +import math +from pathlib import Path +import tempfile +import unittest +import sys + +import kmos_diagnostic as k + + +class DiagnosticIdentities(unittest.TestCase): + def test_exact_synthetic_q_laws(self): + for q in (0,1): + low = [{'x':x,'y':-10+q*x} for x in (.20,.25,.30)] + high = [{'x':x,'y':-10+q*x} for x in (.45,.50,.55)] + d=k.contrast(low,high)['q_comparisons'][str(q)] + self.assertAlmostEqual(d['observed_minus_predicted_dex'],0) + self.assertAlmostEqual(d['required_Vpeak_over_Vflat_high_to_low_ratio_if_mass_exact'],1) + self.assertAlmostEqual(d['required_Mtab_over_Mtrue_high_to_low_ratio_if_velocity_exact'],1) + self.assertAlmostEqual(k.q_scores(low+high)[str(q)]['descriptive_rms_dex'],0) + + def test_calibration_drift_sign_and_fourth_power(self): + # High Vpeak/Vflat is 0.8 times low; mass calibration is 1.2 times low. + dx, q, vratio, mratio = .3, 1, .8, 1.2 + dy=q*dx+4*math.log10(vratio)-math.log10(mratio) + d=k.contrast([{'x':0,'y':0}],[{'x':dx,'y':dy}])['q_comparisons']['1'] + self.assertAlmostEqual(d['required_Vpeak_over_Vflat_high_to_low_ratio_if_mass_exact'],vratio/mratio**.25) + self.assertAlmostEqual(d['required_Mtab_over_Mtrue_high_to_low_ratio_if_velocity_exact'],mratio/vratio**4) + + def test_q_calibration_degeneracy(self): + for x in (0,.2,.5): + for dq in (-2,.731,1): + q, cv, cm = .4,.03,.1 + original=q*x+4*cv-cm + shifted=(q+dq)*x+4*(cv-dq*x/4)-cm + self.assertAlmostEqual(original,shifted) + + def test_cosmology_and_bin_boundaries(self): + self.assertEqual(k.evolution(0),1) + self.assertEqual(k.group_name(1.199),'low') + self.assertEqual(k.group_name(1.2),'mid') + self.assertEqual(k.group_name(1.8),'high') + + +if __name__=='__main__': unittest.main() diff --git a/research/galaxy-calibration/test_kmos_inventory.py b/research/galaxy-calibration/test_kmos_inventory.py new file mode 100644 index 0000000..b5dc8b5 --- /dev/null +++ b/research/galaxy-calibration/test_kmos_inventory.py @@ -0,0 +1,44 @@ +import unittest +from kmos_inventory import summarize + + +def fixture(): + header = '#Name: J/ApJ/842/121/table3\nrecno\tSeq\tz\tlogM*\tlogMb\tVcirc\tsigma0\n\t\t\t[Msun]\t[Msun]\tkm/s\tkm/s\n---\t---\t---\t---\t---\t---\t---\n' + return (header + ''.join(f'{i}\t{i}\t1.0\t10\t10.5\t200\t30\n' for i in range(1,136))).encode() + + +class KmosTests(unittest.TestCase): + def test_synthetic_inventory(self): + self.assertEqual(summarize(fixture())['rows'], 135) + self.assertFalse(summarize(fixture())['adequacy']['joint_inference']) + + def test_timestamp_does_not_change_numeric_hash(self): + first = summarize(b"#request_date: first\n" + fixture()) + second = summarize(b"#request_date: second\n" + fixture()) + self.assertNotEqual(first["sha256"], second["sha256"]) + self.assertEqual(first["numeric_rows_sha256"], second["numeric_rows_sha256"]) + + def test_interior_value_changes_numeric_hash(self): + first = summarize(fixture()) + second = summarize(fixture().replace(b"50\t50\t1.0", b"50\t50\t1.1", 1)) + self.assertNotEqual(first["numeric_rows_sha256"], second["numeric_rows_sha256"]) + + def test_missing_row(self): + with self.assertRaises(ValueError): + summarize(fixture().replace(b'135\t135\t1.0\t10\t10.5\t200\t30\n', b'')) + + def test_invalid_value(self): + with self.assertRaises(ValueError): + summarize(fixture().replace(b'\t200\t', b'\tnan\t', 1)) + + def test_wrong_units(self): + with self.assertRaises(ValueError): + summarize(fixture().replace(b'km/s', b'm/s')) + + def test_wrong_catalogue(self): + with self.assertRaises(ValueError): + summarize(fixture().replace(b'842/121', b'842/122')) + + +if __name__ == '__main__': + unittest.main() diff --git a/research/galaxy-calibration/test_validate_manifest.py b/research/galaxy-calibration/test_validate_manifest.py new file mode 100644 index 0000000..f4089cc --- /dev/null +++ b/research/galaxy-calibration/test_validate_manifest.py @@ -0,0 +1,45 @@ +import hashlib +from pathlib import Path +import tempfile +import unittest +from validate_manifest import ROLES, validate + + +class InventoryTests(unittest.TestCase): + def setUp(self): + self.directory = tempfile.TemporaryDirectory() + self.addCleanup(self.directory.cleanup) + self.root = Path(self.directory.name) + (self.root / 'input.txt').write_bytes(b'synthetic fixture\n') + payload = (self.root / 'input.txt').read_bytes() + self.manifest = {'artifacts': [dict(role=role, path='input.txt', source_url='https://example.org/data', bytes=len(payload), sha256=hashlib.sha256(payload).hexdigest(), schema={'columns': ['fixture'], 'units': {'fixture': 'dimensionless'}}) for role in sorted(ROLES)]} + + def test_complete_byte_inventory(self): + self.assertEqual(validate(self.manifest, self.root), []) + + def test_absent_data_blocks(self): + self.assertTrue(validate({'artifacts': []}, self.root)) + + def test_modified_bytes_block(self): + (self.root / 'input.txt').write_bytes(b'changed') + self.assertIn('SHA256 mismatch', validate(self.manifest, self.root)) + + def test_escape_blocks(self): + self.manifest['artifacts'][0]['path'] = '../outside.txt' + self.assertTrue(validate(self.manifest, self.root)) + + def test_duplicate_role_blocks(self): + self.manifest['artifacts'][0]['role'] = self.manifest['artifacts'][1]['role'] + self.assertIn('unknown or repeated product role', validate(self.manifest, self.root)) + + def test_missing_schema_blocks(self): + self.manifest['artifacts'][0]['schema'] = {} + self.assertIn('original columns and units must be declared', validate(self.manifest, self.root)) + + def test_nonpublic_source_blocks(self): + self.manifest['artifacts'][0]['source_url'] = 'file:///private/data' + self.assertIn('a declared HTTP(S) source URL is required', validate(self.manifest, self.root)) + + +if __name__ == '__main__': + unittest.main() diff --git a/research/galaxy-calibration/validate_manifest.py b/research/galaxy-calibration/validate_manifest.py new file mode 100644 index 0000000..8ec824a --- /dev/null +++ b/research/galaxy-calibration/validate_manifest.py @@ -0,0 +1,53 @@ +"""Check local input bytes. This does not validate science or original schemas.""" +import argparse +import hashlib +import json +from pathlib import Path +import re +from urllib.parse import urlparse + +ROLES = {'photometry', 'halo_fit', 'selection', 'joint_uncertainty'} + + +def validate(manifest, root): + errors = [] + roles = set() + for item in manifest.get('artifacts', []): + role = item.get('role') + if role not in ROLES or role in roles: + errors.append('unknown or repeated product role') + roles.add(role) + source = urlparse(item.get('source_url', '')) + if source.scheme not in ('http', 'https') or not source.netloc: + errors.append('a declared HTTP(S) source URL is required') + relative = Path(item.get('path', '')) + target = (root / relative).resolve() + if relative.is_absolute() or not target.is_relative_to(root.resolve()) or not target.is_file(): + errors.append('input must be an existing file under the data directory') + continue + payload = target.read_bytes() + digest = item.get('sha256', '') + if not isinstance(digest, str) or not re.fullmatch('[a-f0-9]{64}', digest) or hashlib.sha256(payload).hexdigest() != digest: + errors.append('SHA256 mismatch') + if type(item.get('bytes')) is not int or len(payload) != item['bytes']: + errors.append('byte count mismatch') + if not isinstance(item.get('schema'), dict) or not item['schema'].get('columns') or not item['schema'].get('units'): + errors.append('original columns and units must be declared') + missing = ROLES - roles + if missing: + errors.append('missing product roles: ' + ', '.join(sorted(missing))) + return errors + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('manifest', type=Path) + parser.add_argument('--data-dir', type=Path, required=True) + args = parser.parse_args() + errors = validate(json.loads(args.manifest.read_text()), args.data_dir) + print(json.dumps({'byte_inventory_complete': not errors, 'science_ready': False, 'errors': errors}, indent=2)) + return 1 if errors else 0 + + +if __name__ == '__main__': + raise SystemExit(main())