Skip to content

Commit

Permalink
Refactor automatic flagging
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Escudero committed Feb 8, 2025
1 parent aa271e9 commit bae96ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 12 additions & 0 deletions iop4lib/db/photopolresult.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,18 @@ def save(self, *args, **kwargs):
""" Overriden to enforce clean() before saving. See PhotoPolResult.__docstring__ for more info."""
self.clean()
super().save(*args, **kwargs)

# Auto-flagging

def auto_flag(self):

if self.p is not None and not (0 <= self.p <= 1):
self.set_flag(PhotoPolResult.FLAGS.BAD_POLARIMETRY)

if self.mag is not None and self.mag_err is not None and self.mag_err > 0.3:
self.set_flag(PhotoPolResult.FLAGS.BAD_PHOTOMETRY)

self.save()

# Host galaxy correction

Expand Down
8 changes: 2 additions & 6 deletions iop4lib/iop4.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ def process_epochs(epochname_list: Iterable[str], args):
logger.info("Auto-flagging points.")

for result in PhotoPolResult.objects.filter(epoch__in=epoch_L).all():
if result.p is not None and not (0 <= result.p <= 1):
result.set_flag(PhotoPolResult.FLAGS.BAD_POLARIMETRY)
result.save()
result.auto_flag()

logger.info("Applying corrections.")

Expand Down Expand Up @@ -162,9 +160,7 @@ def process_astrosource(args):
logger.info("Auto-flagging points.")

for result in PhotoPolResult.objects.filter(epoch__in=epoch_L).all():
if result.p is not None and not (0 <= result.p <= 1):
result.set_flag(PhotoPolResult.FLAGS.BAD_POLARIMETRY)
result.save()
result.auto_flag()

logger.info("Applying corrections.")

Expand Down

0 comments on commit bae96ca

Please sign in to comment.