Skip to content

add command line interface for AstroPhot for simple setups#310

Open
ConnorStoneAstro wants to merge 19 commits into
devfrom
cli_scripts
Open

add command line interface for AstroPhot for simple setups#310
ConnorStoneAstro wants to merge 19 commits into
devfrom
cli_scripts

Conversation

@ConnorStoneAstro

@ConnorStoneAstro ConnorStoneAstro commented Jun 13, 2026

Copy link
Copy Markdown
Member

while AstroPhot allowsfor arbitrary complexity in the models it creates, there are a lot of standard setups that can be handled by a simple command line interface. This will hopefully make for quick one line solutions to typical workflows.

The CLI output has also been simplified: fitted results are now written to a YAML file that collects parameters from both the main model and sky model, and includes total flux and total magnitude summaries (with uncertainties when available).

Copilot AI review requested due to automatic review settings June 13, 2026 18:09
@ConnorStoneAstro

Copy link
Copy Markdown
Member Author

@copilot the output for the CLI script is currently an hdf5 file generated by the caskade interface. I think a simple yaml file that collects the parameters from the main model and the sky model would be better. It should also include the total flux/magnitude

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a lightweight command-line script to run a “single object + sky” AstroPhot fit from FITS inputs, aimed at simplifying common workflows without requiring a full custom model configuration.

Changes:

  • Introduces single_model_cli.py to fit a selected AstroPhot model type (plus sky) to a target FITS image via argparse.
  • Supports optional PSF/variance/mask FITS inputs and forwards additional unknown --key value args into ap.Model(...) as initial parameters.
  • Writes fitted parameter state plus optional model/residual images and covariance matrix outputs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread astrophot/cli/cli_single.py
Comment thread astrophot/cli/cli_single.py
Comment thread docs/source/prebuilt/single_model_cli.py

Copilot AI commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

@copilot the output for the CLI script is currently an hdf5 file generated by the caskade interface. I think a simple yaml file that collects the parameters from the main model and the sky model would...

Implemented in 9ddd313. The CLI now writes <name>_parameters.yaml with separate main_model and sky_model parameter blocks (values + uncertainties), and a photometry block containing total flux/uncertainty plus total magnitude/uncertainty when a zeropoint is provided.

Copilot AI changed the title add command line interface for AstroPhot for simple setups add command line interface for AstroPhot for simple setups Jun 13, 2026
@ConnorStoneAstro

Copy link
Copy Markdown
Member Author

@copilot can you please make sure an Astropy WCS object is passed to the the target image creation so that the relevant coordinates are all correct?

@ConnorStoneAstro

Copy link
Copy Markdown
Member Author

@copilot can you add unit tests that grab the CLI script and run it on the target data fits file stored in the docs source?

@codecov

codecov Bot commented Jun 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.53%. Comparing base (3af6466) to head (0898181).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev     #310   +/-   ##
=======================================
  Coverage   91.53%   91.53%           
=======================================
  Files         113      113           
  Lines        6072     6072           
=======================================
  Hits         5558     5558           
  Misses        514      514           
Flag Coverage Δ
unittests 91.53% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

ConnorStoneAstro and others added 4 commits June 13, 2026 21:19
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@ConnorStoneAstro

Copy link
Copy Markdown
Member Author

@copilot Could you please create a unit test for the cli script. Like with the notebooks, you'll need to copy it into the unit testing directory and copy the target image then run the command.

@ConnorStoneAstro

Copy link
Copy Markdown
Member Author

@copilot Could you please create a unit test for the cli script. Like with the notebooks, you'll need to copy it into the unit testing directory and copy the target image then run the command.

@ConnorStoneAstro

Copy link
Copy Markdown
Member Author

@copilot can you move the CLI script into the main AstroPhot directory and make it so that users can call the CLI script with an "astrophot" command rather than calling python and the path to the script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants