galfitools.batch package

Submodules

galfitools.batch.batchGetBT module

Process a list of GALFIT files and compute B/T quantities.

This script reads a text file containing one GALFIT file path per line, changes to the directory of each file, applies get_bt() to the file, stores the results, and writes them to an output CSV file.

The stored path is relative to the directory where the program is launched.

Python 3.11+

class galfitools.batch.batchGetBT.BTResult(relative_path: str, bulge_total: float | None, totmag: float | None, n_components: int | None, success: bool, message: str = '')[source]

Bases: object

Store the processing result for one GALFIT file.

bulge_total: float | None
message: str
n_components: int | None
relative_path: str
success: bool
totmag: float | None
galfitools.batch.batchGetBT.mainbatchGetBT() int[source]

Run the script.

Returns:

Exit status code.

Return type:

int

galfitools.batch.batchGetBT.make_relative_path(file_path: Path, base_dir: Path) str[source]

Return the file path relative to the base directory.

If the file is not inside the base directory, return the full path.

Parameters:
  • file_path (Path) – Absolute path to the file.

  • base_dir (Path) – Base directory used to compute the relative path.

Returns:

Relative path if possible, otherwise absolute path as string.

Return type:

str

galfitools.batch.batchGetBT.print_summary(results: Iterable[BTResult]) None[source]

Print a short summary of the processing results.

Parameters:

results (Iterable[BTResult]) – Results to summarize.

galfitools.batch.batchGetBT.process_file(file_path: Path, base_dir: Path, dis: float, num_comp: int) BTResult[source]

Change to the file directory, process the file, and return the result.

Parameters:
  • file_path (Path) – GALFIT file to process.

  • base_dir (Path) – Directory from which relative paths are computed.

  • dis (float) – Maximum distance among components.

  • num_comp (int) – Number of component where the center will be taken.

Returns:

Result object with rounded outputs and status information.

Return type:

BTResult

galfitools.batch.batchGetBT.process_files(file_paths: Iterable[Path], base_dir: Path, dis: float, num_comp: int) list[BTResult][source]

Process all files in the input iterable.

Parameters:
  • file_paths (Iterable[Path]) – Files to process.

  • base_dir (Path) – Directory from which relative paths are computed.

  • dis (float) – Maximum distance among components.

  • num_comp (int) – Number of component where the center will be taken.

Returns:

Collected results for all files.

Return type:

list[BTResult]

galfitools.batch.batchGetBT.read_file_list(list_file: Path, encoding: str = 'utf-8') list[Path][source]

Read a text file containing one file path per line.

Empty lines and lines starting with ‘#’ are ignored.

Parameters:
  • list_file (Path) – Path to the file containing the list of input file paths.

  • encoding (str, optional) – File encoding.

Returns:

List of resolved input paths.

Return type:

list[Path]

galfitools.batch.batchGetBT.write_results(results: Iterable[BTResult], output_file: Path) None[source]

Write processing results to a CSV file.

Parameters:
  • results (Iterable[BTResult]) – Results to write.

  • output_file (Path) – Destination CSV file.

galfitools.batch.batchGetBarSize module

class galfitools.batch.batchGetBarSize.BarResult(relative_path: Path, input_galfit: Path, bar_size: float | None, bar_size_arcsec: float | None, success: bool, message: str = '')[source]

Bases: object

Store the processing result for one input file.

bar_size: float | None
bar_size_arcsec: float | None
input_galfit: Path
message: str = ''
relative_path: Path
success: bool
galfitools.batch.batchGetBarSize.getMulBarSize(list_file: str, dis: int, numcomp: int, plot: bool, ranx: list, out: str, red: bool, scale: float, method: str, output_file: str) float[source]

gets the bar length of the spiral galaxies

It runs getBarSize to estimate the barlength over multiple files given the path of each one in a file.

It assumes the bar model is the second component of the GALFIT file. Bar model can be a Sersic or Ferrer function. The rest of components must be Sersic (or related) models.

Parameters:
  • file (str) – file containing the paths of every GALFIT file

  • dis (int) – maximum list among components

  • numcomp (int) – Number of component where it’ll obtain center of all components. in other words it selects the galaxy that contains the bar if simultaneous fitting of galaxies was used.

  • plot (bool) – If True, it draws plots of the break and kappa radius

  • ranx (list) – range of search (xmin to xmax) for the kappa radius and break radius. If None, it will search in a range of r=1 to 2.5*Re of effetive radius of the bar model.

  • out (str) – Name of the output file for the DS9 ellipse region marking the bar.

  • output_file (str) – Name of the output file for the output barlength results

  • red (bool) – If True, draws DS9 region ellipse as red color

  • scale (float) – constant to multiply the bar length. Default =1

  • method (str) – indicates which method is used to measure the bar length. Options include ‘break_kappa’, ‘break’ ‘kappa’,’re’, ‘retot’. Default=’break_kappa’

Returns:

Exit status code.

Return type:

int

See also

getBarSize

get the bar length

galfitools.batch.batchGetBarSize.mainbatchGetBarSize(argv=None) int[source]
galfitools.batch.batchGetBarSize.make_relative_path(file_path: Path, base_dir: Path) str[source]

Return the file path relative to the base directory.

If the file is not inside the base directory, return the full path.

Parameters:
  • file_path (Path) – Absolute path to the file.

  • base_dir (Path) – Base directory used to compute the relative path.

Returns:

Relative path if possible, otherwise absolute path as string.

Return type:

str

galfitools.batch.batchGetBarSize.print_summary(results: Iterable[BarResult]) None[source]

Print a short summary of the processing results.

Parameters:

results (Iterable[BarResult]) – Results to summarize.

galfitools.batch.batchGetBarSize.process_file(file_path: Path, base_dir: Path, dis, numcomp, plot, ranx, out, red, scale, method) BarResult[source]

Change to the file directory, process the file, and return the result.

Parameters:
  • file_path (Path) – File to process.

  • base_dir (Path) – Directory from which relative paths are computed.

  • parameters (rest of)

Returns:

Result object with status, computed bar size, and message.

Return type:

BarResult

galfitools.batch.batchGetBarSize.process_files(file_paths: Iterable[Path], base_dir: Path, dis, numcomp, plot, ranx, out, red, scale, method) list[BarResult][source]

Process all files in the input iterable.

Parameters:
  • file_paths (Iterable[Path]) – Files to process.

  • parameters (rest of)

Returns:

Collected results for all files.

Return type:

list[BarResult]

galfitools.batch.batchGetBarSize.read_file_list(list_file: Path, encoding: str = 'utf-8') list[Path][source]

Read a text file containing one file path per line.

Empty lines and lines starting with ‘#’ are ignored.

Parameters:
  • list_file (Path) – Path to the file containing the list of input file paths.

  • encoding (str, optional) – File encoding.

Returns:

List of resolved input paths.

Return type:

list[Path]

Raises:
galfitools.batch.batchGetBarSize.write_results(results: Iterable[BarResult], output_file: Path) None[source]

Write processing results to a CSV file.

Parameters:
  • results (Iterable[BarResult]) – Results to write.

  • output_file (Path) – Destination CSV file.

galfitools.batch.batchGetBreak module

Process a list of GALFIT files and compute the break radius using the second-derivative method.

This script reads a text file containing one GALFIT file path per line, changes to the directory of each file, applies getBreak2 to the file, stores the results, and writes them to an output CSV file.

The stored path is relative to the directory where the program is launched.

Python 3.11+

class galfitools.batch.batchGetBreak.Break2Result(relative_path: str, rbreak: float | None, n_components: int | None, theta: float | None, success: bool, message: str = '')[source]

Bases: object

Store the processing result for one GALFIT file.

message: str
n_components: int | None
rbreak: float | None
relative_path: str
success: bool
theta: float | None
galfitools.batch.batchGetBreak.build_parser() ArgumentParser[source]

Build and return the command-line argument parser.

Returns:

Configured argument parser.

Return type:

argparse.ArgumentParser

galfitools.batch.batchGetBreak.mainbatchGetBreak() int[source]

Run the script.

Returns:

Exit status code.

Return type:

int

galfitools.batch.batchGetBreak.make_relative_path(file_path: Path, base_dir: Path) str[source]

Return the file path relative to the base directory.

If the file is not inside the base directory, return the full path.

Parameters:
  • file_path (Path) – Absolute path to the file.

  • base_dir (Path) – Base directory used to compute the relative path.

Returns:

Relative path if possible, otherwise absolute path as string.

Return type:

str

galfitools.batch.batchGetBreak.print_summary(results: Iterable[Break2Result]) None[source]

Print a short summary of the processing results.

Parameters:

results (Iterable[Break2Result]) – Results to summarize.

galfitools.batch.batchGetBreak.process_file(file_path: Path, base_dir: Path, dis: float, angle: float | None, num_comp: int, plot: bool, ranx: tuple[float, float] | None) Break2Result[source]

Change to the file directory, process the file, and return the result.

Parameters:
  • file_path (Path) – GALFIT file to process.

  • base_dir (Path) – Directory from which relative paths are computed.

  • dis (float) – Maximum distance among components.

  • angle (float | None) – Position angle of the major axis of the galaxy.

  • num_comp (int) – Number of component used to define the center.

  • plot (bool) – If True, create diagnostic plots.

  • ranx (tuple[float, float] | None) – Range for plotting and searching.

Returns:

Result object with rounded outputs and status information.

Return type:

Break2Result

galfitools.batch.batchGetBreak.process_files(file_paths: Iterable[Path], base_dir: Path, dis: float, angle: float | None, num_comp: int, plot: bool, ranx: tuple[float, float] | None) list[Break2Result][source]

Process all files in the input iterable.

Parameters:
  • file_paths (Iterable[Path]) – Files to process.

  • base_dir (Path) – Directory from which relative paths are computed.

  • dis (float) – Maximum distance among components.

  • angle (float | None) – Position angle of the major axis of the galaxy.

  • num_comp (int) – Number of component used to define the center.

  • plot (bool) – If True, create diagnostic plots.

  • ranx (tuple[float, float] | None) – Range for plotting and searching.

Returns:

Collected results for all files.

Return type:

list[Break2Result]

galfitools.batch.batchGetBreak.read_file_list(list_file: Path, encoding: str = 'utf-8') list[Path][source]

Read a text file containing one file path per line.

Empty lines and lines starting with ‘#’ are ignored.

Parameters:
  • list_file (Path) – Path to the file containing the list of input file paths.

  • encoding (str, optional) – File encoding.

Returns:

List of resolved input paths.

Return type:

list[Path]

galfitools.batch.batchGetBreak.write_results(results: Iterable[Break2Result], output_file: Path) None[source]

Write processing results to a CSV file.

Parameters:
  • results (Iterable[Break2Result]) – Results to write.

  • output_file (Path) – Destination CSV file.

galfitools.batch.batchGetKappa module

Process a list of GALFIT files and compute the kappa radius.

This script reads a text file containing one GALFIT file path per line, changes to the directory of each file, applies get_kappa2() to the file, stores the results, and writes them to an output CSV file.

The stored path is relative to the directory where the program is launched.

Python 3.11+

class galfitools.batch.batchGetKappa.Kappa2Result(relative_path: str, rkappa: float | None, n_components: int | None, theta: float | None, success: bool, message: str = '')[source]

Bases: object

Store the processing result for one GALFIT file.

message: str
n_components: int | None
relative_path: str
rkappa: float | None
success: bool
theta: float | None
galfitools.batch.batchGetKappa.build_parser() ArgumentParser[source]

Build and return the command-line argument parser.

Returns:

Configured argument parser.

Return type:

argparse.ArgumentParser

galfitools.batch.batchGetKappa.mainbatchGetKappa() int[source]

Run the script.

Returns:

Exit status code.

Return type:

int

galfitools.batch.batchGetKappa.make_relative_path(file_path: Path, base_dir: Path) str[source]

Return the file path relative to the base directory.

If the file is not inside the base directory, return the full path.

Parameters:
  • file_path (Path) – Absolute path to the file.

  • base_dir (Path) – Base directory used to compute the relative path.

Returns:

Relative path if possible, otherwise absolute path as string.

Return type:

str

galfitools.batch.batchGetKappa.print_summary(results: Iterable[Kappa2Result]) None[source]

Print a short summary of the processing results.

Parameters:

results (Iterable[Kappa2Result]) – Results to summarize.

galfitools.batch.batchGetKappa.process_file(file_path: Path, base_dir: Path, dis: float, angle: float | None, num_comp: int, plot: bool, ranx: tuple[float, float] | None) Kappa2Result[source]

Change to the file directory, process the file, and return the result.

Parameters:
  • file_path (Path) – GALFIT file to process.

  • base_dir (Path) – Directory from which relative paths are computed.

  • dis (float) – Maximum distance among components.

  • angle (float | None) – Position angle of the major axis of the galaxy.

  • num_comp (int) – Number of component used to define the center.

  • plot (bool) – If True, create diagnostic plots.

  • ranx (tuple[float, float] | None) – Range for plotting and searching.

Returns:

Result object with rounded outputs and status information.

Return type:

Kappa2Result

galfitools.batch.batchGetKappa.process_files(file_paths: Iterable[Path], base_dir: Path, dis: float, angle: float | None, num_comp: int, plot: bool, ranx: tuple[float, float] | None) list[Kappa2Result][source]

Process all files in the input iterable.

Parameters:
  • file_paths (Iterable[Path]) – Files to process.

  • base_dir (Path) – Directory from which relative paths are computed.

  • dis (float) – Maximum distance among components.

  • angle (float | None) – Position angle of the major axis of the galaxy.

  • num_comp (int) – Number of component used to define the center.

  • plot (bool) – If True, create diagnostic plots.

  • ranx (tuple[float, float] | None) – Range for plotting and searching.

Returns:

Collected results for all files.

Return type:

list[Kappa2Result]

galfitools.batch.batchGetKappa.read_file_list(list_file: Path, encoding: str = 'utf-8') list[Path][source]

Read a text file containing one file path per line.

Empty lines and lines starting with ‘#’ are ignored.

Parameters:
  • list_file (Path) – Path to the file containing the list of input file paths.

  • encoding (str, optional) – File encoding.

Returns:

List of resolved input paths.

Return type:

list[Path]

galfitools.batch.batchGetKappa.write_results(results: Iterable[Kappa2Result], output_file: Path) None[source]

Write processing results to a CSV file.

Parameters:
  • results (Iterable[Kappa2Result]) – Results to write.

  • output_file (Path) – Destination CSV file.

galfitools.batch.batchGetMeRad module

Process a list of GALFIT files and compute surface-brightness values at a given radius.

This script reads a text file containing one GALFIT file path per line, changes to the directory of each file, applies getMeRad() to the file, stores the results, and writes them to an output CSV file.

The stored path is relative to the directory where the program is launched.

Python 3.11+

class galfitools.batch.batchGetMeRad.MeRadResult(relative_path: str, totmag: float | None, meanmerad: float | None, merad: float | None, n_components: int | None, theta: float | None, success: bool, message: str = '')[source]

Bases: object

Store the processing result for one GALFIT file.

meanmerad: float | None
merad: float | None
message: str
n_components: int | None
relative_path: str
success: bool
theta: float | None
totmag: float | None
galfitools.batch.batchGetMeRad.mainbatchGetMeRad() int[source]

Run the script.

Returns:

Exit status code.

Return type:

int

galfitools.batch.batchGetMeRad.make_relative_path(file_path: Path, base_dir: Path) str[source]

Return the file path relative to the base directory.

If the file is not inside the base directory, return the full path.

Parameters:
  • file_path (Path) – Absolute path to the file.

  • base_dir (Path) – Base directory used to compute the relative path.

Returns:

Relative path if possible, otherwise absolute path as string.

Return type:

str

galfitools.batch.batchGetMeRad.print_summary(results: Iterable[MeRadResult]) None[source]

Print a short summary of the processing results.

Parameters:

results (Iterable[MeRadResult]) – Results to summarize.

galfitools.batch.batchGetMeRad.process_file(file_path: Path, base_dir: Path, dis: float, rad: float, angle: float, num_comp: int, mecorr: float) MeRadResult[source]

Change to the file directory, process the file, and return the result.

Parameters:
  • file_path (Path) – GALFIT file to process.

  • base_dir (Path) – Directory from which relative paths are computed.

  • dis (float) – Maximum distance among components.

  • rad (float) – Radius at which the surface brightness is computed.

  • angle (float) – Position angle of the major axis of the galaxy.

  • num_comp (int) – Number of component from which the center is determined.

  • mecorr (float) – Surface-brightness correction for universe expansion.

Returns:

Result object with rounded outputs and status information.

Return type:

MeRadResult

galfitools.batch.batchGetMeRad.process_files(file_paths: Iterable[Path], base_dir: Path, dis: float, rad: float, angle: float, num_comp: int, mecorr: float) list[MeRadResult][source]

Process all files in the input iterable.

Parameters:
  • file_paths (Iterable[Path]) – Files to process.

  • base_dir (Path) – Directory from which relative paths are computed.

  • dis (float) – Maximum distance among components.

  • rad (float) – Radius at which the surface brightness is computed.

  • angle (float) – Position angle of the major axis of the galaxy.

  • num_comp (int) – Number of component from which the center is determined.

  • mecorr (float) – Surface-brightness correction for universe expansion.

Returns:

Collected results for all files.

Return type:

list[MeRadResult]

galfitools.batch.batchGetMeRad.read_file_list(list_file: Path, encoding: str = 'utf-8') list[Path][source]

Read a text file containing one file path per line.

Empty lines and lines starting with ‘#’ are ignored.

Parameters:
  • list_file (Path) – Path to the file containing the list of input file paths.

  • encoding (str, optional) – File encoding.

Returns:

List of resolved input paths.

Return type:

list[Path]

galfitools.batch.batchGetMeRad.write_results(results: Iterable[MeRadResult], output_file: Path) None[source]

Write processing results to a CSV file.

Parameters:
  • results (Iterable[MeRadResult]) – Results to write.

  • output_file (Path) – Destination CSV file.

galfitools.batch.batchGetN module

Process a list of GALFIT files and estimate the Sersic index.

This script reads a text file containing one GALFIT file path per line, changes to the directory of each file, applies getN() to the file, stores the results, and writes them to an output CSV file.

The stored path is relative to the directory where the program is launched.

Python 3.11+

class galfitools.batch.batchGetN.NResult(relative_path: str, sersic: float | None, mean_ns: float | None, std_ns: float | None, totmag: float | None, n_components: int | None, theta: float | None, success: bool, message: str = '')[source]

Bases: object

Store the processing result for one GALFIT file.

mean_ns: float | None
message: str
n_components: int | None
relative_path: str
sersic: float | None
std_ns: float | None
success: bool
theta: float | None
totmag: float | None
galfitools.batch.batchGetN.build_parser() ArgumentParser[source]

Build and return the command-line argument parser.

Returns:

Configured argument parser.

Return type:

argparse.ArgumentParser

galfitools.batch.batchGetN.mainbatchGetN() int[source]

Run the script.

Returns:

Exit status code.

Return type:

int

galfitools.batch.batchGetN.make_relative_path(file_path: Path, base_dir: Path) str[source]

Return the file path relative to the base directory.

If the file is not inside the base directory, return the full path.

Parameters:
  • file_path (Path) – Absolute path to the file.

  • base_dir (Path) – Base directory used to compute the relative path.

Returns:

Relative path if possible, otherwise absolute path as string.

Return type:

str

galfitools.batch.batchGetN.print_summary(results: Iterable[NResult]) None[source]

Print a short summary of the processing results.

Parameters:

results (Iterable[NResult]) – Results to summarize.

galfitools.batch.batchGetN.process_file(file_path: Path, base_dir: Path, dis: float, frac: float, angle: float | None, num_comp: int, plot: bool, const: float) NResult[source]

Change to the file directory, process the file, and return the result.

Parameters:
  • file_path (Path) – GALFIT file to process.

  • base_dir (Path) – Directory from which relative paths are computed.

  • dis (float) – Maximum distance among components.

  • frac (float) – Fraction of light.

  • angle (float | None) – Angle of the major axis of the galaxy.

  • num_comp (int) – Number of component used to define the center.

  • plot (bool) – If True, create the Sersic-index plot.

  • const (float) – Constant subtracted from the plot.

Returns:

Result object with rounded outputs and status information.

Return type:

NResult

galfitools.batch.batchGetN.process_files(file_paths: Iterable[Path], base_dir: Path, dis: float, frac: float, angle: float | None, num_comp: int, plot: bool, const: float) list[NResult][source]

Process all files in the input iterable.

Parameters:
  • file_paths (Iterable[Path]) – Files to process.

  • base_dir (Path) – Directory from which relative paths are computed.

  • dis (float) – Maximum distance among components.

  • frac (float) – Fraction of light.

  • angle (float | None) – Angle of the major axis of the galaxy.

  • num_comp (int) – Number of component used to define the center.

  • plot (bool) – If True, create the Sersic-index plot.

  • const (float) – Constant subtracted from the plot.

Returns:

Collected results for all files.

Return type:

list[NResult]

galfitools.batch.batchGetN.read_file_list(list_file: Path, encoding: str = 'utf-8') list[Path][source]

Read a text file containing one file path per line.

Empty lines and lines starting with ‘#’ are ignored.

Parameters:
  • list_file (Path) – Path to the file containing the list of input file paths.

  • encoding (str, optional) – File encoding.

Returns:

List of resolved input paths.

Return type:

list[Path]

galfitools.batch.batchGetN.write_results(results: Iterable[NResult], output_file: Path) None[source]

Write processing results to a CSV file.

Parameters:
  • results (Iterable[NResult]) – Results to write.

  • output_file (Path) – Destination CSV file.

galfitools.batch.batchGetReComp module

Process a list of GALFIT files and compute the effective radius or another light-fraction radius.

This script reads a text file containing one GALFIT file path per line, changes to the directory of each file, applies getReComp to the file, stores the results, and writes them to an output CSV file.

The stored path is relative to the directory where the program is launched.

Python 3.11+

class galfitools.batch.batchGetReComp.ReCompResult(relative_path: str, effrad: float | None, totmag: float | None, meanme: float | None, me: float | None, n_components: int | None, theta: float | None, success: bool, message: str = '')[source]

Bases: object

Store the processing result for one GALFIT file.

effrad: float | None
me: float | None
meanme: float | None
message: str
n_components: int | None
relative_path: str
success: bool
theta: float | None
totmag: float | None
galfitools.batch.batchGetReComp.build_parser() ArgumentParser[source]

Build and return the command-line argument parser.

Returns:

Configured argument parser.

Return type:

argparse.ArgumentParser

galfitools.batch.batchGetReComp.mainbatchGetReComp() int[source]

Run the script.

Returns:

Exit status code.

Return type:

int

galfitools.batch.batchGetReComp.make_relative_path(file_path: Path, base_dir: Path) str[source]

Return the file path relative to the base directory.

If the file is not inside the base directory, return the full path.

Parameters:
  • file_path (Path) – Absolute path to the file.

  • base_dir (Path) – Base directory used to compute the relative path.

Returns:

Relative path if possible, otherwise absolute path as string.

Return type:

str

galfitools.batch.batchGetReComp.print_summary(results: Iterable[ReCompResult]) None[source]

Print a short summary of the processing results.

Parameters:

results (Iterable[ReCompResult]) – Results to summarize.

galfitools.batch.batchGetReComp.process_file(file_path: Path, base_dir: Path, dis: float, eff: float, angle: float | None, num_comp: int, mecorr: float) ReCompResult[source]

Change to the file directory, process the file, and return the result.

Parameters:
  • file_path (Path) – GALFIT file to process.

  • base_dir (Path) – Directory from which relative paths are computed.

  • dis (float) – Maximum distance among components.

  • eff (float) – Fraction of total light.

  • angle (float | None) – Position angle of the major axis of the galaxy.

  • num_comp (int) – Number of component used to define the center.

  • mecorr (float) – Surface-brightness correction for universe expansion.

Returns:

Result object with rounded outputs and status information.

Return type:

ReCompResult

galfitools.batch.batchGetReComp.process_files(file_paths: Iterable[Path], base_dir: Path, dis: float, eff: float, angle: float | None, num_comp: int, mecorr: float) list[ReCompResult][source]

Process all files in the input iterable.

Parameters:
  • file_paths (Iterable[Path]) – Files to process.

  • base_dir (Path) – Directory from which relative paths are computed.

  • dis (float) – Maximum distance among components.

  • eff (float) – Fraction of total light.

  • angle (float | None) – Position angle of the major axis of the galaxy.

  • num_comp (int) – Number of component used to define the center.

  • mecorr (float) – Surface-brightness correction for universe expansion.

Returns:

Collected results for all files.

Return type:

list[ReCompResult]

galfitools.batch.batchGetReComp.read_file_list(list_file: Path, encoding: str = 'utf-8') list[Path][source]

Read a text file containing one file path per line.

Empty lines and lines starting with ‘#’ are ignored.

Parameters:
  • list_file (Path) – Path to the file containing the list of input file paths.

  • encoding (str, optional) – File encoding.

Returns:

List of resolved input paths.

Return type:

list[Path]

galfitools.batch.batchGetReComp.write_results(results: Iterable[ReCompResult], output_file: Path) None[source]

Write processing results to a CSV file.

Parameters:
  • results (Iterable[ReCompResult]) – Results to write.

  • output_file (Path) – Destination CSV file.

galfitools.batch.batchGetSlope module

Process a list of GALFIT files and compute the slope radius.

This script reads a text file containing one GALFIT file path per line, changes to the directory of each file, applies getSlope to the file, stores the results, and writes them to an output CSV file.

The stored path is relative to the directory where the program is launched.

Python 3.11+

class galfitools.batch.batchGetSlope.SlopeResult(relative_path: str, rgam: float | None, n_components: int | None, theta: float | None, success: bool, message: str = '')[source]

Bases: object

Store the processing result for one GALFIT file.

message: str
n_components: int | None
relative_path: str
rgam: float | None
success: bool
theta: float | None
galfitools.batch.batchGetSlope.build_parser() ArgumentParser[source]

Build and return the command-line argument parser.

Returns:

Configured argument parser.

Return type:

argparse.ArgumentParser

galfitools.batch.batchGetSlope.mainbatchGetSlope() int[source]

Run the script.

Returns:

Exit status code.

Return type:

int

galfitools.batch.batchGetSlope.make_relative_path(file_path: Path, base_dir: Path) str[source]

Return the file path relative to the base directory.

If the file is not inside the base directory, return the full path.

Parameters:
  • file_path (Path) – Absolute path to the file.

  • base_dir (Path) – Base directory used to compute the relative path.

Returns:

Relative path if possible, otherwise absolute path as string.

Return type:

str

galfitools.batch.batchGetSlope.print_summary(results: Iterable[SlopeResult]) None[source]

Print a short summary of the processing results.

Parameters:

results (Iterable[SlopeResult]) – Results to summarize.

galfitools.batch.batchGetSlope.process_file(file_path: Path, base_dir: Path, dis: float, slope: float, angle: float | None, num_comp: int, plot: bool, ranx: tuple[float, float] | None) SlopeResult[source]

Change to the file directory, process the file, and return the result.

Parameters:
  • file_path (Path) – GALFIT file to process.

  • base_dir (Path) – Directory from which relative paths are computed.

  • dis (float) – Maximum distance among components.

  • slope (float) – Value of the slope at which the radius is determined.

  • angle (float | None) – Position angle of the major axis of the galaxy.

  • num_comp (int) – Number of component used to define the center.

  • plot (bool) – If True, create a diagnostic plot.

  • ranx (tuple[float, float] | None) – Range for plotting.

Returns:

Result object with rounded outputs and status information.

Return type:

SlopeResult

galfitools.batch.batchGetSlope.process_files(file_paths: Iterable[Path], base_dir: Path, dis: float, slope: float, angle: float | None, num_comp: int, plot: bool, ranx: tuple[float, float] | None) list[SlopeResult][source]

Process all files in the input iterable.

Parameters:
  • file_paths (Iterable[Path]) – Files to process.

  • base_dir (Path) – Directory from which relative paths are computed.

  • dis (float) – Maximum distance among components.

  • slope (float) – Value of the slope at which the radius is determined.

  • angle (float | None) – Position angle of the major axis of the galaxy.

  • num_comp (int) – Number of component used to define the center.

  • plot (bool) – If True, create a diagnostic plot.

  • ranx (tuple[float, float] | None) – Range for plotting.

Returns:

Collected results for all files.

Return type:

list[SlopeResult]

galfitools.batch.batchGetSlope.read_file_list(list_file: Path, encoding: str = 'utf-8') list[Path][source]

Read a text file containing one file path per line.

Empty lines and lines starting with ‘#’ are ignored.

Parameters:
  • list_file (Path) – Path to the file containing the list of input file paths.

  • encoding (str, optional) – File encoding.

Returns:

List of resolved input paths.

Return type:

list[Path]

galfitools.batch.batchGetSlope.write_results(results: Iterable[SlopeResult], output_file: Path) None[source]

Write processing results to a CSV file.

Parameters:
  • results (Iterable[SlopeResult]) – Results to write.

  • output_file (Path) – Destination CSV file.

galfitools.batch.batchSersic2Ferrer module

script to process a list of GALFIT files and convert Sersic bar components to Ferrer components.

This script reads a text file containing one GALFIT file path per line, changes to the directory of each file, applies Sersic2Ferrer() to the file, stores the results, and writes them to an output CSV file.

The stored path is relative to the directory where the program is launched.

class galfitools.batch.batchSersic2Ferrer.Sersic2FerrerResult(relative_input_path: str, relative_output_path: str | None, success: bool, message: str = '')[source]

Bases: object

Store the processing result for one GALFIT file.

message: str
relative_input_path: str
relative_output_path: str | None
success: bool
galfitools.batch.batchSersic2Ferrer.build_parser() ArgumentParser[source]

Build and return the command-line argument parser.

Returns:

Configured argument parser.

Return type:

argparse.ArgumentParser

galfitools.batch.batchSersic2Ferrer.mainbatchSersic2Ferrer() int[source]

Run the script.

Returns:

Exit status code.

Return type:

int

galfitools.batch.batchSersic2Ferrer.make_output_name(file_path: Path, suffix: str) str[source]

Build the output GALFIT file name for one input file.

Parameters:
  • file_path (Path) – Input file path.

  • suffix (str) – Suffix added before the file extension.

Returns:

Output file name.

Return type:

str

galfitools.batch.batchSersic2Ferrer.make_relative_path(file_path: Path, base_dir: Path) str[source]

Return the file path relative to the base directory.

If the file is not inside the base directory, return the full path.

Parameters:
  • file_path (Path) – Absolute path to the file.

  • base_dir (Path) – Base directory used to compute the relative path.

Returns:

Relative path if possible, otherwise absolute path as string.

Return type:

str

galfitools.batch.batchSersic2Ferrer.print_summary(results: Iterable[Sersic2FerrerResult]) None[source]

Print a short summary of the processing results.

Parameters:

results (Iterable[Sersic2FerrerResult]) – Results to summarize.

galfitools.batch.batchSersic2Ferrer.process_file(file_path: Path, base_dir: Path, alpha: bool, beta: bool, suffix: str) Sersic2FerrerResult[source]

Change to the file directory, process the file, and return the result.

Parameters:
  • file_path (Path) – GALFIT file to process.

  • base_dir (Path) – Directory from which relative paths are computed.

  • alpha (bool) – If True, leave the Ferrer alpha parameter free.

  • beta (bool) – If True, leave the Ferrer beta parameter free.

  • suffix (str) – Suffix used to build the output file name.

Returns:

Result object with status information.

Return type:

Sersic2FerrerResult

galfitools.batch.batchSersic2Ferrer.process_files(file_paths: Iterable[Path], base_dir: Path, alpha: bool, beta: bool, suffix: str) list[Sersic2FerrerResult][source]

Process all files in the input iterable.

Parameters:
  • file_paths (Iterable[Path]) – Files to process.

  • base_dir (Path) – Directory from which relative paths are computed.

  • alpha (bool) – If True, leave the Ferrer alpha parameter free.

  • beta (bool) – If True, leave the Ferrer beta parameter free.

  • suffix (str) – Suffix used to build the output file name.

Returns:

Collected results for all files.

Return type:

list[Sersic2FerrerResult]

galfitools.batch.batchSersic2Ferrer.read_file_list(list_file: Path, encoding: str = 'utf-8') list[Path][source]

Read a text file containing one file path per line.

Empty lines and lines starting with ‘#’ are ignored.

Parameters:
  • list_file (Path) – Path to the file containing the list of input file paths.

  • encoding (str, optional) – File encoding.

Returns:

List of resolved input paths.

Return type:

list[Path]

galfitools.batch.batchSersic2Ferrer.write_results(results: Iterable[Sersic2FerrerResult], output_file: Path) None[source]

Write processing results to a CSV file.

Parameters:
  • results (Iterable[Sersic2FerrerResult]) – Results to write.

  • output_file (Path) – Destination CSV file.

galfitools.batch.batch_galfit module

Batch-run GALFIT over input files listed in a text file.

Files located in the same directory are always executed sequentially. Files located in different directories may be executed concurrently.

Each non-empty, non-comment line must contain the path to a GALFIT input file:

/obj1/z/galfit.init /obj1/z/galfit2.init /obj2/z/galfit.init

Features

  • Serial execution with –jobs 1

  • Parallel execution with –jobs N

  • Files in the same directory never run simultaneously

  • Safe subprocess execution without shell=True

  • Ignores empty lines and lines beginning with ‘#’

  • Checks whether every input file exists

  • Continues processing after failures

  • Captures return code, stdout, and stderr

  • Optional verbose output

  • Optional CSV summary

Exit status

  • 0 if every job succeeds

  • 1 if one or more jobs fail

  • 2 for command-line or input-list errors

class galfitools.batch.batch_galfit.JobResult(input_file: Path, success: bool, returncode: int, stdout: str, stderr: str, error_message: str | None = None)[source]

Bases: object

Store the result of one GALFIT execution.

error_message: str | None = None
input_file: Path
returncode: int
stderr: str
stdout: str
success: bool
class galfitools.batch.batch_galfit.ProgressTracker(total: int, completed: int = 0, lock: lock = <factory>)[source]

Bases: object

Maintain a thread-safe count of completed jobs.

advance(input_file: Path) None[source]

Increment and print the completed-job count.

completed: int = 0
lock: lock
total: int
galfitools.batch.batch_galfit.batch_galfit() int[source]

Run the command-line program.

galfitools.batch.batch_galfit.expand_path(path_text: str) Path[source]

Expand environment variables and the user home directory.

galfitools.batch.batch_galfit.group_files_by_directory(files: Sequence[Path]) dict[Path, list[Path]][source]

Group input files according to their resolved parent directory.

The file order within each directory follows the order in the list file.

galfitools.batch.batch_galfit.log(message: str) None[source]

Print a timestamped message in a thread-safe way.

galfitools.batch.batch_galfit.normalize_executable(executable: str) str[source]

Normalize an executable path.

Executable names such as ‘galfit’ are left unchanged so they can be found through PATH. Explicit relative paths such as ‘./bin/galfit’ are converted to absolute paths because subprocesses run from each input directory.

galfitools.batch.batch_galfit.parse_args() Namespace[source]

Parse command-line arguments.

galfitools.batch.batch_galfit.print_failure_details(results: Iterable[JobResult]) None[source]

Print detailed output for failed jobs.

galfitools.batch.batch_galfit.print_streams(result: JobResult) None[source]

Print captured output for one GALFIT job.

galfitools.batch.batch_galfit.print_summary(results: Sequence[JobResult]) None[source]

Print the final execution summary.

galfitools.batch.batch_galfit.read_list_file(list_file: Path) list[Path][source]

Read GALFIT input paths from a text file.

Empty lines and lines beginning with ‘#’ are ignored. Relative paths are interpreted relative to the current working directory.

galfitools.batch.batch_galfit.run_directory_group(directory: Path, files: Sequence[Path], galfit_bin: str, imax: int, verbose: bool, progress: ProgressTracker) list[JobResult][source]

Run all GALFIT files from one directory sequentially.

This function is submitted as one executor task. Therefore, no two input files from the same directory can run simultaneously.

galfitools.batch.batch_galfit.run_galfit(input_file: Path, galfit_bin: str, imax: int, verbose: bool = False) JobResult[source]

Run GALFIT on one input file.

GALFIT is executed from the directory containing the input file. Only the input filename is passed to GALFIT:

galfit galfit.init

Parameters:
  • input_file – GALFIT initial-parameters file.

  • galfit_bin – GALFIT executable name or absolute path.

  • verbose – Print captured stdout and stderr when True.

Returns:

Execution status and captured output.

Return type:

JobResult

galfitools.batch.batch_galfit.run_parallel(files: Sequence[Path], galfit_bin: str, imax: int, jobs: int, verbose: bool) list[JobResult][source]

Run directories concurrently while serializing files within each directory.

The effective parallelism cannot exceed the number of unique directories.

galfitools.batch.batch_galfit.run_serial(files: Sequence[Path], galfit_bin: str, imax: int, verbose: bool) list[JobResult][source]

Run every GALFIT input file sequentially.

galfitools.batch.batch_galfit.validate_input_files(paths: Iterable[Path]) tuple[list[Path], list[JobResult]][source]

Separate valid files from missing or invalid paths.

Returns:

  • valid_files – Input paths that exist and are regular files.

  • invalid_results – Failure results corresponding to invalid paths.

galfitools.batch.batch_galfit.write_summary_csv(results: Sequence[JobResult], csv_path: Path) None[source]

Write execution results to a CSV file.

Module contents