Skip to content

Show the pyse inputs, similar to -h#192

Merged
HannoSpreeuw merged 2 commits intomasterfrom
print_inputs
Jan 13, 2026
Merged

Show the pyse inputs, similar to -h#192
HannoSpreeuw merged 2 commits intomasterfrom
print_inputs

Conversation

@tmillenaar
Copy link
Copy Markdown
Contributor

The idea of this MR is to make it clear to the user what arguments are being used.
We add a new cli argument called --show-input that will print the configuration contents after it has been updated with the contents of the config file and the command line arguments.

For me this now looks like so:

$ pyse --show-input 

 === image ===
   interpolate_order: 1
   median_filter: 0
   mf_threshold: 0
   rms_filter: 0.001
   deblend_mincont: 0.005
   structuring_element: [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
   vectorized: False
   nr_threads: None
   margin: 0
   radius: 0.0
   back_size_x: 32
   back_size_y: 32
   eps_ra: 0.0
   eps_dec: 0.0
   clean_bias: 0.0
   clean_bias_error: 0.0
   frac_flux_cal_error: 0.0
   alpha_maj1: 2.5
   alpha_maj2: 0.5
   alpha_min1: 0.5
   alpha_min2: 2.5
   alpha_brightness1: 1.5
   alpha_brightness2: 1.5
   detection_thr: 10.0
   analysis_thr: 3.0
   fdr: False
   alpha: 0.01
   deblend_nthresh: 0
   grid: None
   bmaj: None
   bmin: None
   bpa: None
   force_beam: False
   detection_image: None
   fixed_posns: None
   fixed_posns_file: None
   ffbox: 3.0
   ew_sys_err: 0.0
   ns_sys_err: 0.0
   remove_edge_sources: True
 === export ===
   output_dir: .
   file_type: csv
   skymodel: False
   csv: False
   regions: False
   rmsmap: False
   sigmap: False
   residuals: False
   islands: False
   pandas_df: False
   source_params: ['peak', 'peak_err', 'flux', 'flux_err', 'x', 'x_err', 'y', 'y_err', 'smaj', 'smaj_err', 'smin', 'smin_err', 'theta', 'theta_err', 'smaj_dc', 'smaj_dc_err', 'smin_dc', 'smin_dc_err', 'theta_dc', 'theta_dc_err', 'ra', 'ra_err', 'dec', 'dec_err', 'smaj_asec', 'smaj_asec_err', 'smin_asec', 'smin_asec_err', 'theta_celes', 'theta_celes_err', 'theta_dc_celes', 'theta_dc_celes_err', 'error_radius', 'sig', 'chisq', 'reduced_chisq']
   source_params_file: ['peak', 'peak_err', 'flux', 'flux_err', 'x', 'y', 'ra', 'ra_err', 'dec', 'dec_err', 'smaj_asec', 'smaj_asec_err', 'smin_asec', 'smin_asec_err', 'theta_celes', 'theta_celes_err', 'sig', 'reduced_chisq']


# Finally, as positional arguments, the file list:
parser.add_argument("files", nargs="+", help="Image files for processing")
parser.add_argument("files", nargs="*", help="Image files for processing")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ik heb dit aangepast zodat ik ook --show-input aan kan roepen zonder een file mee te geven. De nargs="+" zorgde ervoor dat er een error werd gegooid als er geen file werd meegegeven. Dit doe ik nu zelf verderop in de code als de logia voor --show-input voorbij is en het tijd is voor echte processing doe ik zelf een check dat er in elk geval een file is meegegeven

@HannoSpreeuw
Copy link
Copy Markdown
Collaborator

It is great to have some check on which parameter values are actually used.

I guess that the appropriate level to do this is when image.Imagedata is being called, since a typical PySE run from an IPython shell would be something like this:

from sourcefinder.accessors.fitsimage import FitsImage
from sourcefinder.accessors import sourcefinder_image_from_accessor
some_im = sourcefinder_image_from_accessor(FitsImage("my_favourite_image.FITS", 
beam=(1,2,3)), conf=conf)
results = some_im.extract()

E.g. the beam parameters - beam=(1,2,3) - can be modified by the user at the level of FitsImage so you probably want to check which values are being processed at the level of
image.Imagedata.

@HannoSpreeuw
Copy link
Copy Markdown
Collaborator

But I guess this particular example does not apply to command-line usage.

fixed_coords = parse_monitoringlist_positions(
conf.image, str_name="fixed_posns", list_name="fixed_posns_file"
)

Copy link
Copy Markdown
Collaborator

@HannoSpreeuw HannoSpreeuw Jan 12, 2026

Choose a reason for hiding this comment

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

This is the implementation of the new feature and almost all of the rest is reformatting from Black?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Mostly, though there is the added argument to the parser around line 126

@HannoSpreeuw
Copy link
Copy Markdown
Collaborator

Would --show-args be a better name?

@tmillenaar
Copy link
Copy Markdown
Contributor Author

I would argue that some_im = sourcefinder_image_from_accessor(FitsImage("my_favourite_image.FITS", beam=(1,2,3)), conf=conf) is already sufficiently clear in a notebook context, since the user can evaluate exactly what the inputs to the function are, including the conf object that is passed at that moment. But indeed the current MR only applies to the CLI

@HannoSpreeuw HannoSpreeuw merged commit dfa89d3 into master Jan 13, 2026
9 checks passed
@HannoSpreeuw HannoSpreeuw deleted the print_inputs branch January 13, 2026 12:13
@HannoSpreeuw HannoSpreeuw mentioned this pull request Jan 15, 2026
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.

2 participants