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

PEP8, flake8 and sphinx RST fixes #310

Merged
merged 5 commits into from
Sep 22, 2019
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
21 changes: 21 additions & 0 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Python flake8 check

on: [push]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Set up Python 3.6
uses: actions/setup-python@v1
with:
python-version: 3.6
- name: Lint with flake8
run: |
pip install flake8
# Note: only check files in Ska.engarchive package. Many other files in
# the repo are not maintained as PEP8 compliant.
flake8 . --count --exclude=docs/conf.py --ignore=W504 --max-line-length=100 --show-source --statistics
8 changes: 3 additions & 5 deletions proseco/acq.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import numpy as np
from scipy import ndimage, stats
from scipy.interpolate import interp1d
from astropy.table import Table
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am assuming that this was imported and not used.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct.

Copy link
Member Author

@taldcroft taldcroft Sep 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did run tests, but it isn't a bad idea as reviewer to just independently check out the repo in this branch and run python setup.py test or pytest proseco. Then you will know for sure about the import.


from chandra_aca.star_probs import acq_success_prob, prob_n_acq
from chandra_aca.transform import (pixels_to_yagzag, mag_to_count_rate,
Expand Down Expand Up @@ -155,7 +154,6 @@ def empty(cls):
out['halfw'] = np.full(fill_value=0, shape=(0,), dtype=np.int64)
return out


@property
def fid_set(self):
if not hasattr(self, '_fid_set'):
Expand Down Expand Up @@ -1301,7 +1299,7 @@ def p_fid_id_spoiler(self, box_size, fid_id, acqs):
fids = acqs.fids
if fids is None:
acqs.add_warning('Requested fid spoiler probability without '
'setting acqs.fids first')
'setting acqs.fids first')
return 1.0

p_fid_id_spoiler = 1.0
Expand All @@ -1311,8 +1309,8 @@ def p_fid_id_spoiler(self, box_size, fid_id, acqs):
# This should not happen, but ignore with a warning in any case. Non-candidate
# fid cannot spoil an acq star.
acqs.add_warning(f'Requested fid spoiler probability for fid '
f'{acqs.detector}-{fid_id} but it is '
f'not a candidate')
f'{acqs.detector}-{fid_id} but it is '
f'not a candidate')
else:
if fids.spoils(fid, self.acq, box_size):
p_fid_id_spoiler = 0.0
Expand Down
2 changes: 1 addition & 1 deletion proseco/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ def set_attrs_from_kwargs(self, **kwargs):
compute the effective T_ccd temperatures.

In this ACATable object:

- t_ccd_eff_{acq,guide} are the effective T_ccd values which are adjusted
if the actual t_ccd{acq,guide} values are above ACA.aca_t_ccd_penalty_limit.
- t_ccd_{acq,guide} are the actual (or predicted) values from the call
Expand All @@ -240,7 +241,6 @@ def set_attrs_from_kwargs(self, **kwargs):
self.t_ccd_eff_guide = get_effective_t_ccd(self.t_ccd_guide)
self.version = VERSION


def get_review_table(self):
"""Get ACAReviewTable object based on self.

Expand Down
88 changes: 44 additions & 44 deletions proseco/characteristics.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,50 +43,50 @@
[-374, -374, 347, 347]] # Fid trap

bad_star_set = set([36178592,
39980640,
185871616,
188751528,
190977856,
260968880,
260972216,
261621080,
296753512,
300948368,
301078152,
301080376,
301465776,
335025128,
335028096,
350392600,
414324824,
444743456,
465456712,
490220520,
502793400,
509225640,
570033768,
614606480,
637144600,
647632648,
650249416,
656409216,
690625776,
692724384,
788418168,
849226688,
914493824,
956175008,
989598624,
1004817824,
1016736608,
1044122248,
1117787424,
1130635848,
1130649544,
1161827976,
1196953168,
1197635184,
1158290496])
39980640,
185871616,
188751528,
190977856,
260968880,
260972216,
261621080,
296753512,
300948368,
301078152,
301080376,
301465776,
335025128,
335028096,
350392600,
414324824,
444743456,
465456712,
490220520,
502793400,
509225640,
570033768,
614606480,
637144600,
647632648,
650249416,
656409216,
690625776,
692724384,
788418168,
849226688,
914493824,
956175008,
989598624,
1004817824,
1016736608,
1044122248,
1117787424,
1130635848,
1130649544,
1161827976,
1196953168,
1197635184,
1158290496])

# Add in entries from the AGASC supplement file, if possible, warn otherwise
agasc_supplement_file = Path(os.environ['SKA']) / 'data' / 'agasc' / 'agasc_supplement.h5'
Expand Down
1 change: 1 addition & 0 deletions proseco/characteristics_acq.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def _get_fid_acq_stages():
out.add_index('spoiler_score')
return out


fid_acq_stages = _get_fid_acq_stages()

# For a given box size, set the mag limit to the magnitude where one expects
Expand Down
63 changes: 31 additions & 32 deletions proseco/characteristics_guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"Intercept": 9,
"Slope": 0.5,
"MagDiffLimit": -1 * np.inf,
}
}

# Search Stages
stages = [{"Stage": 1,
Expand All @@ -44,77 +44,76 @@
"MagLimit": [6.2, 10.2],
"DoBminusVcheck": 1,
"Spoiler": {
"BgPixThresh": 25,
"RegionFrac": .05,
},
"BgPixThresh": 25,
"RegionFrac": .05,
},
"Imposter": {
"CentroidOffsetLim": .2,
}},
"CentroidOffsetLim": .2,
}},
{"Stage": 2,
"SigErrMultiplier": 2,
"ASPQ1Lim": 0,
"MagLimit": [6.2, 10.2],
"DoBminusVcheck": 1,
"Spoiler": {
"BgPixThresh": 25,
"RegionFrac": .05,
},
"BgPixThresh": 25,
"RegionFrac": .05,
},
"Imposter": {
"CentroidOffsetLim": .5,
}},
"CentroidOffsetLim": .5,
}},
{"Stage": 3,
"SigErrMultiplier": 1,
"ASPQ1Lim": 10,
"MagLimit": [6.1, 10.3],
"DoBminusVcheck": 1,
"Spoiler": {
"BgPixThresh": 25,
"RegionFrac": .05,
},
"BgPixThresh": 25,
"RegionFrac": .05,
},
"Imposter": {
"CentroidOffsetLim": 1.0,
}},
"CentroidOffsetLim": 1.0,
}},
{"Stage": 4,
"SigErrMultiplier": 0,
"ASPQ1Lim": 20,
"MagLimit": [6.0, 10.3],
"DoBminusVcheck": 1,
"Spoiler": {
"BgPixThresh": 25,
"RegionFrac": .05,
},
"BgPixThresh": 25,
"RegionFrac": .05,
},
"Imposter": {
"CentroidOffsetLim": 2.0,
}},
"CentroidOffsetLim": 2.0,
}},
{"Stage": 5,
"SigErrMultiplier": 0,
"ASPQ1Lim": 20,
"MagLimit": [5.9, 10.3],
"DoBminusVcheck": 0,
"Spoiler": {
"BgPixThresh": 25,
"RegionFrac": .05,
},
"BgPixThresh": 25,
"RegionFrac": .05,
},
"Imposter": {
"CentroidOffsetLim": 3.5,
}},
"CentroidOffsetLim": 3.5,
}},
{"Stage": 6,
"SigErrMultiplier": 0,
"ASPQ1Lim": 20,
"MagLimit": [5.6, 10.3],
"DoBminusVcheck": 0,
"Spoiler": {
"BgPixThresh": 25,
"RegionFrac": .05,
},
"BgPixThresh": 25,
"RegionFrac": .05,
},
"Imposter": {
"CentroidOffsetLim": 4.0,
},
"CentroidOffsetLim": 4.0,
},
}
]



# Guide cluster checks.
# Index is the "n_minus" value, so n - 0 stars need minimum 2500 max separation
# n - 1 stars require 1000 arcsec separation.
Expand Down
26 changes: 14 additions & 12 deletions proseco/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,14 @@ def __repr__(self):
return (f'<{self.__class__.__name__} name={self.name} default={self.default} '
f'pickle={self.pickle}>')


class QuatMetaAttribute(MetaAttribute):
def __set__(self, instance, value):
if not isinstance(value, Quat):
value = Quat(value)
instance.meta[self.name] = value


class IntMetaAttribute(MetaAttribute):
def __set__(self, instance, value):
instance.meta[self.name] = int(value)
Expand Down Expand Up @@ -1154,7 +1156,7 @@ def add_agasc_id(self, agasc_id):
self.add_row(stars[0])

def add_fake_constellation(self, n_stars=8, size=1500, mag=7.0, **attrs):
"""
r"""
Add a fake constellation of up to 8 stars consisting of a cross and square::

*
Expand Down Expand Up @@ -1206,7 +1208,7 @@ def add_fake_constellation(self, n_stars=8, size=1500, mag=7.0, **attrs):
self.add_fake_star(**{name: val for name, val in zip(names, vals)})

def add_fake_star(self, **star):
"""
r"""
Add a star to the current StarsTable.

The input kwargs must have at least:
Expand Down Expand Up @@ -1383,48 +1385,48 @@ def get_kwargs_from_starcheck_text(obs_text, include_cat=False, force_catalog=Fa
'sim_offset': 0,
'focus_offset': 0}
try:
kw['obsid'] = int(re.search("OBSID:\s(\d+).*", obs_text).group(1))
except:
kw['obsid'] = int(re.search(r"OBSID:\s(\d+).*", obs_text).group(1))
except Exception:
# Nothing else will work so raise an exception
raise ValueError('text does not have OBSID: <obsid>, does not look like appropriate text')

try:
out = get_coords(obs_text)
kw['att'] = [out['point_ra'], out['point_dec'], out['point_roll']]
except:
except Exception:
try:
out = get_manvrs(obs_text)[-1]
kw['att'] = [out['target_Q1'], out['target_Q2'], out['target_Q3'], out['target_Q4']]
except:
except Exception:
pass

try:
out = get_manvrs(obs_text)[-1]
kw['man_angle'] = out['angle_deg']
except:
except Exception:
pass

try:
out = get_dither(obs_text)
kw['dither'] = (out['dither_y_amp'], out['dither_z_amp'])
except:
except Exception:
pass

try:
ccd_temp = get_pred_temp(obs_text)
kw['t_ccd'] = ccd_temp
except:
except Exception:
pass

try:
starcat_hdr = get_starcat_header(obs_text)
kw['date'] = starcat_hdr['mp_starcat_time']
except:
except Exception:
pass

try:
cat = Table(get_catalog(obs_text))
except:
except Exception:
pass
else:
fid_or_mon = np.in1d(cat['type'], ('FID', 'MON'))
Expand All @@ -1444,7 +1446,7 @@ def get_kwargs_from_starcheck_text(obs_text, include_cat=False, force_catalog=Fa
kw['detector'] = targ['sci_instr']
kw['sim_offset'] = targ['sim_z_offset_steps']
kw['focus_offset'] = 0
except:
except Exception:
pass

return kw
Loading