Skip to content

Commit

Permalink
Merge pull request #69 from SNflows/fix_sep_big
Browse files Browse the repository at this point in the history
Fix bug with sep
  • Loading branch information
emirkmo authored May 16, 2022
2 parents d6ee01c + 8d8ff81 commit ac0ef76
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 31 deletions.
13 changes: 2 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ jobs:
with:
python-version: 3.9

- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-py3.9-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-py3.9-
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
Expand All @@ -46,9 +37,9 @@ jobs:
run: |
# stop the build if there are Python syntax errors or undefined names
# For some reason we have to specifically ignore G001 as well
flake8 --select=E9,F63,F7,F82 --ignore=G001,G004 --show-source
flake8 --select=E9,F63,F7,F82 --show-source --ignore=G001,G004
# exit-zero treats all errors as warnings.
flake8 --exit-zero
# flake8 --exit-zero
# Run unit tests on Linux, OSX and Windows
pytest:
Expand Down
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ Installation instructions

>>> git clone https://github.com/SNflows/flows.git .

* All dependencies can be installed using the following command. It is recommended to do this in a dedicated `virtualenv <https://virtualenv.pypa.io/en/stable/>`_ or similar:
* Required dependencies can be installed using the following command. It is recommended to do this in a dedicated `virtualenv <https://virtualenv.pypa.io/en/stable/>`_ or similar:

>>> pip install -r requirements.txt
>>> pip install -r requirements_dev.txt # for tests/development

* Last step is to create a config-file. Create a file named "config.ini" and place it in the "flows" directory. Make sure that the file can only be read by you (``chmod 0600 config.ini``)!
This file can contain all the settings for running the pipeline. A minimal file for working with the pipeline is
Expand Down
17 changes: 14 additions & 3 deletions flows/reference_cleaning.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,22 @@ def add_target(self, target: Target, starid: int = 0) -> None:
self.xy = np.vstack(((target.pixel_column, target.pixel_row), self.xy))


def use_sep(image: FlowsImage):
def use_sep(image: FlowsImage, tries: int = 5, thresh: float = 5.):

# Use sep to for soure extraction
sep_background = sep.Background(image.image, mask=image.mask)
objects = sep.extract(image.image - sep_background, thresh=5., err=sep_background.globalrms, mask=image.mask,
deblend_cont=0.1, minarea=9, clean_param=2.0)
try:
objects = sep.extract(image.image - sep_background, thresh=thresh, err=sep_background.globalrms,
mask=image.mask, deblend_cont=0.1, minarea=9, clean_param=2.0)
except KeyboardInterrupt:
raise
except Exception:
logger.warning("SEP failed, trying again...")
if tries > 0:
thresh += 3
return use_sep(image, tries - 1, thresh * 2)
else:
raise
return References(table=objects)


Expand Down
48 changes: 32 additions & 16 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,38 @@ extend-ignore = E203
enable-extensions = G

ignore =
G004, # logger does not optimizes f strings but __str__ calls are ok for us.
E117, # over-indented (set when using tabs)
E127, # continuation line over-indented for visual indent
E128, # continuation line under-indented for visual indent
E201, # whitespace after '('
E202, # whitespace before ')'
E265, # block comment should start with '# '
E231, # missing whitespace after ','
E226, # missing whitespace around arithmetic operator
E261, # at least two spaces before inline comment
E302, # expected 2 blank lines, found 1
E305, # expected 2 blank lines after class or function definition, found 1
E501, # line too long
E701, # multiple statements on one line (colon)
W503, # Line break occurred before a binary operator
ET128, # (flake8-tabs) unexpected number of tabs and spaces at start of XXX
G004,
# logger does not optimizes f strings but __str__ calls are ok for us.
E117,
# over-indented (set when using tabs)
E127,
# continuation line over-indented for visual indent
E128,
# continuation line under-indented for visual indent
E201,
# whitespace after '('
E202,
# whitespace before ')'
E265,
# block comment should start with '# '
E231,
# missing whitespace after ','
E226,
# missing whitespace around arithmetic operator
E261,
# at least two spaces before inline comment
E302,
# expected 2 blank lines, found 1
E305,
# expected 2 blank lines after class or function definition, found 1
E501,
# line too long
E701,
# multiple statements on one line (colon)
W503,
# Line break occurred before a binary operator
ET128,
# (flake8-tabs) unexpected number of tabs and spaces at start of XXX

[tool:pytest]
addopts = --strict-markers --durations=10
Expand Down

0 comments on commit ac0ef76

Please sign in to comment.