diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 8614c625c..99418a8a4 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -26,4 +26,4 @@ jobs: poetry install - name: Analysing the code with pylint run: | - poetry run pylint mirar --fail-under=9.64 + poetry run pylint mirar --fail-under=9.66 diff --git a/mirar/processors/astromatic/sextractor/settings.py b/mirar/processors/astromatic/sextractor/settings.py index 050c9e978..ab12f4f95 100644 --- a/mirar/processors/astromatic/sextractor/settings.py +++ b/mirar/processors/astromatic/sextractor/settings.py @@ -24,8 +24,8 @@ def write_param_file(param_path: str = default_param_path): ELLIPTICITY FWHM_IMAGE FLAGS""" - with open(param_path, "w") as pf: - pf.write(params) + with open(param_path, "w", encoding="utf8") as param_f: + param_f.write(params) def write_conv_file(conv_path: str = default_conv_path): @@ -38,8 +38,8 @@ def write_conv_file(conv_path: str = default_conv_path): 2 4 2 1 2 1 """ - with open(conv_path, "w") as cf: - cf.write(convol) + with open(conv_path, "w", encoding="utf8") as conv_f: + conv_f.write(convol) def write_config_file( @@ -125,5 +125,5 @@ def write_config_file( XML_NAME sex.xml # Filename for XML output SATUR_KEY {saturation_key} # keyword for saturation level (in ADUs) """ - with open(config_path, "w") as pf: - pf.write(configs) + with open(config_path, "w", encoding="utf8") as conf_f: + conf_f.write(configs) diff --git a/mirar/processors/astromatic/sextractor/sourceextractor.py b/mirar/processors/astromatic/sextractor/sourceextractor.py index eadb04482..d2c078836 100644 --- a/mirar/processors/astromatic/sextractor/sourceextractor.py +++ b/mirar/processors/astromatic/sextractor/sourceextractor.py @@ -15,7 +15,7 @@ # sextractor_cmd = os.getenv("SEXTRACTOR_CMD") -default_saturation = 10000000000.0 +DEFAULT_SATURATION = 10000000000.0 default_config_path = os.path.join(astromatic_config_dir, "astrom.sex") default_param_path = os.path.join(astromatic_config_dir, "astrom.param") default_filter_name = os.path.join(astromatic_config_dir, "default.conv") @@ -30,7 +30,7 @@ class SextractorError(ExecutionError): # Either run sextractor locally or on docker -local_sextractor = True +LOCAL_SEXTRACTOR = True # Functions to parse commands and generate appropriate sextractor files @@ -132,7 +132,7 @@ def run_sextractor(images: str | list, output_dir: str, *args, **kwargs): def run_sextractor_single( img: str, output_dir: str, - catalog_name: Optional[str] = None, + catalog_name: Optional[Path] = None, config: str = default_config_path, parameters_name: str = default_param_path, filter_name: str = default_filter_name, @@ -205,10 +205,11 @@ def run_sextractor_single( if mag_zp is not None: cmd += f" -MAG_ZEROPOINT {mag_zp}" + try: execute(cmd, output_dir) - except ExecutionError as e: - raise SextractorError(e) + except ExecutionError as exc: + raise SextractorError(exc) from exc if write_regions: output_catalog = get_table_from_ldac(catalog_name) diff --git a/mirar/processors/astrometry/autoastrometry/autoastrometry.py b/mirar/processors/astrometry/autoastrometry/autoastrometry.py index d288dff04..896fea296 100644 --- a/mirar/processors/astrometry/autoastrometry/autoastrometry.py +++ b/mirar/processors/astrometry/autoastrometry/autoastrometry.py @@ -32,7 +32,7 @@ write_config_file, write_param_file, ) -from mirar.processors.astromatic.sextractor.sourceextractor import default_saturation +from mirar.processors.astromatic.sextractor.sourceextractor import DEFAULT_SATURATION from mirar.processors.astrometry.autoastrometry.crossmatch import ( crosscheck_source_lists, distance_match, @@ -85,7 +85,7 @@ def autoastrometry( outfile: str = "", output_dir: str = base_output_dir, temp_file: Optional[str] = None, - saturation: float = default_saturation, + saturation: float = DEFAULT_SATURATION, no_rot: bool = False, min_fwhm: float = DEFAULT_MIN_FWHM, max_fwhm: float = DEFAULT_MAX_FWHM, @@ -557,7 +557,7 @@ def run_autoastrometry_single( overwrite: bool = False, outfile: Optional[str] = None, output_dir: str = base_output_dir, - saturation: float = default_saturation, + saturation: float = DEFAULT_SATURATION, no_rot: bool = False, write_crosscheck_files: bool = False, ): @@ -668,7 +668,7 @@ def run_autoastrometry_batch( overwrite: bool = False, outfile: Optional[str] = None, output_dir: str = base_output_dir, - saturation: float = default_saturation, + saturation: float = DEFAULT_SATURATION, no_rot: bool = False, write_crosscheck_files: bool = False, ): diff --git a/mirar/processors/astrometry/autoastrometry/detect.py b/mirar/processors/astrometry/autoastrometry/detect.py index a8def018e..9629b877c 100644 --- a/mirar/processors/astrometry/autoastrometry/detect.py +++ b/mirar/processors/astrometry/autoastrometry/detect.py @@ -16,7 +16,7 @@ default_starnnw_path, ) from mirar.processors.astromatic.sextractor.sourceextractor import ( - default_saturation, + DEFAULT_SATURATION, run_sextractor_single, ) from mirar.processors.astrometry.autoastrometry.errors import AstrometrySourceError @@ -43,7 +43,7 @@ def get_img_src_list( min_fwhm: float = DEFAULT_MIN_FWHM, max_fwhm: float = DEFAULT_MAX_FWHM, max_ellip: float = 0.5, - saturation: float = default_saturation, + saturation: float = DEFAULT_SATURATION, config_path: str = default_config_path, output_catalog: Optional[str | Path] = None, write_crosscheck_files: bool = False,