{"spec_id":"lightcurve-transit","library":"makie","language":"julia","code":"# anyplot.ai\n# lightcurve-transit: Astronomical Light Curve\n# Library: makie 0.22.10 | Julia 1.11.9\n# Quality: 89/100 | Created: 2026-06-20\n\nusing CairoMakie\nusing Colors\nusing Random\n\nRandom.seed!(42)\n\n# Theme tokens — Imprint palette (see prompts/default-style-guide.md)\nconst THEME       = get(ENV, \"ANYPLOT_THEME\", \"light\")\nconst PAGE_BG     = THEME == \"light\" ? colorant\"#FAF8F1\" : colorant\"#1A1A17\"\nconst ELEVATED_BG = THEME == \"light\" ? colorant\"#FFFDF6\" : colorant\"#242420\"\nconst INK         = THEME == \"light\" ? colorant\"#1A1A17\" : colorant\"#F0EFE8\"\nconst INK_SOFT    = THEME == \"light\" ? colorant\"#4A4A44\" : colorant\"#B8B7B0\"\n\nconst IMPRINT_PALETTE = [\n    colorant\"#009E73\",  # 1 — brand green (always first series)\n    colorant\"#C475FD\",  # 2 — lavender\n    colorant\"#4467A3\",  # 3 — blue\n    colorant\"#BD8233\",  # 4 — ochre\n    colorant\"#AE3030\",  # 5 — matte red\n    colorant\"#2ABCCD\",  # 6 — cyan\n    colorant\"#954477\",  # 7 — rose\n    colorant\"#99B314\",  # 8 — lime\n]\n\n# Transit model: smooth trapezoid with quadratic ingress/egress ramps\n# Parameters: center=0.0, depth=1.2%, t14=0.072 (total), t23=0.044 (flat bottom)\nfunction transit_model(phase)\n    r = abs(phase)\n    r >= 0.036 && return 1.0\n    r <= 0.022 && return 0.988\n    frac = (r - 0.022) / 0.014   # 0 at 2nd contact, 1 at 1st contact\n    return 1.0 - 0.012 * (1.0 - frac)^2\nend\n\n# Simulated phase-folded exoplanet photometry — 400 observations over phase -0.25 to 0.25\nn_obs        = 400\nphases_raw   = (rand(n_obs) .- 0.5) .* 0.5\nnoise_sigma  = 0.0018\nflux_raw     = transit_model.(phases_raw) .+ randn(n_obs) .* noise_sigma\nflux_err_raw = fill(noise_sigma, n_obs) .* (0.75 .+ 0.5 .* rand(n_obs))\n\nsort_idx   = sortperm(phases_raw)\nphases_obs = phases_raw[sort_idx]\nflux_obs   = flux_raw[sort_idx]\nflux_err   = flux_err_raw[sort_idx]\n\n# Dense model curve for smooth overlay\nphases_curve = collect(range(-0.25, 0.25, length=500))\nmodel_curve  = transit_model.(phases_curve)\n\n# Semi-transparent colors for observations\nc1 = IMPRINT_PALETTE[1]\nobs_color     = RGBA(c1.r, c1.g, c1.b, 0.60)\nobs_err_color = RGBA(c1.r, c1.g, c1.b, 0.28)\n\n# Figure — landscape 3200×1800 px (size × px_per_unit = 1600×2 = 3200)\nfig = Figure(\n    size            = (1600, 900),\n    fontsize        = 14,\n    backgroundcolor = PAGE_BG,\n)\n\nax = Axis(\n    fig[1, 1];\n    title              = \"Exoplanet Transit · lightcurve-transit · julia · makie · anyplot.ai\",\n    titlesize          = 20,\n    titlecolor         = INK,\n    xlabel             = \"Orbital Phase\",\n    ylabel             = \"Relative Flux\",\n    xlabelsize         = 14,\n    ylabelsize         = 14,\n    xlabelcolor        = INK,\n    ylabelcolor        = INK,\n    xticklabelsize     = 12,\n    yticklabelsize     = 12,\n    xticklabelcolor    = INK_SOFT,\n    yticklabelcolor    = INK_SOFT,\n    xtickcolor         = INK_SOFT,\n    ytickcolor         = INK_SOFT,\n    backgroundcolor    = PAGE_BG,\n    topspinevisible    = false,\n    rightspinevisible  = false,\n    leftspinecolor     = INK_SOFT,\n    bottomspinecolor   = INK_SOFT,\n    xgridvisible       = false,\n    ygridcolor         = RGBAf(INK.r, INK.g, INK.b, 0.12),\n    xminorgridvisible  = false,\n    yminorgridvisible  = false,\n)\n\n# Baseline flux=1.0 reference — marks the out-of-transit level\nhlines!(ax, [1.0];\n    color     = RGBAf(INK.r, INK.g, INK.b, 0.35),\n    linewidth = 1.0,\n    linestyle = :dash,\n)\n\n# Transit contact-point markers: 1st/4th contact (ingress/egress boundaries)\n# and 2nd/3rd contact (flat-bottom edges)\nvlines!(ax, [-0.036, 0.036];\n    color     = RGBAf(INK.r, INK.g, INK.b, 0.25),\n    linewidth = 1.0,\n    linestyle = :dash,\n)\nvlines!(ax, [-0.022, 0.022];\n    color     = RGBAf(INK.r, INK.g, INK.b, 0.18),\n    linewidth = 1.0,\n    linestyle = :dot,\n)\n\n# Error bars rendered first so scatter points sit on top\nerrorbars!(ax, phases_obs, flux_obs, flux_err;\n    color        = obs_err_color,\n    whiskerwidth = 5,\n)\n\n# Scattered photometric measurements — Imprint position 1 (brand green)\nscatter!(ax, phases_obs, flux_obs;\n    color       = obs_color,\n    markersize  = 9,\n    strokewidth = 0,\n    label       = \"Photometry\",\n)\n\n# Best-fit transit model overlay — Imprint position 2 (lavender)\nlines!(ax, phases_curve, model_curve;\n    color     = IMPRINT_PALETTE[2],\n    linewidth = 4.0,\n    label     = \"Transit Model\",\n)\n\naxislegend(ax;\n    position        = :rb,\n    backgroundcolor = ELEVATED_BG,\n    framecolor      = INK_SOFT,\n    labelcolor      = INK,\n    labelsize       = 12,\n)\n\nsave(\"plot-$(THEME).png\", fig; px_per_unit = 2)\n"}