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

Suppress astropy warnings #318

Merged
merged 5 commits into from
Sep 7, 2020
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
3 changes: 3 additions & 0 deletions pipeline/config_template.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ USE_CONDON_ERRORS = {{ use_condon_errors }}
# Sometimes the local rms for a source is reported as 0 by selavy.
# Choose a value to use for the local rms in these cases
SELAVY_LOCAL_RMS_ZERO_FILL_VALUE = {{ selavy_local_rms_zero_fill_value }} # mJy

# Hide astropy warnings
SUPPRESS_ASTROPY_WARNINGS = {{ suppress_astropy_warnings }}
1 change: 1 addition & 0 deletions pipeline/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ class PipelineRunForm(forms.Form):
flux_perc_error = forms.FloatField()
selavy_local_rms_zero_fill_value = forms.FloatField()
use_condon_errors = forms.BooleanField(required=False)
suppress_astropy_warnings = forms.BooleanField(required=False)
5 changes: 5 additions & 0 deletions pipeline/management/commands/runpipeline.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import logging
import traceback
import warnings

from django.core.management.base import BaseCommand, CommandError

Expand All @@ -9,6 +10,7 @@
from pipeline.pipeline.utils import get_create_p_run
from pipeline.utils.utils import StopWatch
from ..helpers import get_p_run_name
from astropy.utils.exceptions import AstropyWarning


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -64,6 +66,9 @@ def handle(self, *args, **options):
logger.exception('Config error:\n%s', e)
raise CommandError(f'Config error:\n{e}')

if pipeline.config.SUPPRESS_ASTROPY_WARNINGS:
warnings.simplefilter("ignore", category=AstropyWarning)

# Create the pipeline run in DB
p_run, flag_exist = get_create_p_run(
pipeline.name,
Expand Down
11 changes: 9 additions & 2 deletions templates/generic_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,19 @@ <h5 class="modal-title m-0 font-weight-bold text-primary" id="exampleModalLabel"
</div>
</div>
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="condomErrorSwitch" {% if runconfig.use_condon_errors %} checked="checked" {% endif %} name="use_condon_errors">
<label class="custom-control-label font-weight-bold text-gray-800" for="condomErrorSwitch">Use Condon Errors</label>
<input type="checkbox" class="custom-control-input" id="condonErrorSwitch" {% if runconfig.use_condon_errors %} checked="checked" {% endif %} name="use_condon_errors">
<label class="custom-control-label font-weight-bold text-gray-800" for="condonErrorSwitch">Use Condon Errors</label>
<a href="#" data-toggle="tooltip" data-placement="top" title=
"Replaces the selavy catalogue flux and positional errors with those defined by Condon '97, calculated by the pipeline."
><i class="fas fa-info-circle"></i></a>
</div>
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="astropyWarnSwitch" {% if runconfig.suppress_astropy_warnings %} checked="checked" {% endif %} name="suppress_astropy_warnings">
<label class="custom-control-label font-weight-bold text-gray-800" for="astropyWarnSwitch">Suppress Astropy Warnings</label>
<a href="#" data-toggle="tooltip" data-placement="top" title=
"Removes the Astropy warnings from the pipeline run output."
><i class="fas fa-info-circle"></i></a>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-secondary btn-icon-split" type="button" data-dismiss="modal">
Expand Down
1 change: 1 addition & 0 deletions webinterface/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@
'flux_perc_error': 0,
'use_condon_errors': True,
'selavy_local_rms_zero_fill_value': 0.2,
'suppress_astropy_warnings': True
}

# default max concurrent pipeline runs
Expand Down