Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lintify sourcextractor #430

Merged
merged 2 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 6 additions & 6 deletions mirar/processors/astromatic/sextractor/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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(
Expand Down Expand Up @@ -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)
11 changes: 6 additions & 5 deletions mirar/processors/astromatic/sextractor/sourceextractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions mirar/processors/astrometry/autoastrometry/autoastrometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
):
Expand Down Expand Up @@ -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,
):
Expand Down
4 changes: 2 additions & 2 deletions mirar/processors/astrometry/autoastrometry/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
Loading