Skip to content

Commit

Permalink
Merge branch 'master' into #93
Browse files Browse the repository at this point in the history
  • Loading branch information
msimet committed Jul 11, 2018
2 parents 7dd5362 + f2f2dfd commit 966f332
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 39 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ nosetests.xml
doc/_build
doc/html
doc/latex

.ropeproject/
.eggs/
*.bak
26 changes: 26 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
language: python

python:
- "2.7"
- "3.6"

install:
- pip install coverage
- pip install .

script:
- cd tests
- nosetests --with-coverage --cover-package=stile --with-doctest --cover-erase test_binning.py test_stile_utils.py

after_success:
- coverage xml
- codecov

deploy:
provider: pypi
user: msimet
password:
secure: secure_token
on:
tags: true
branch: master
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
7/11/18: Update code to python3
3/17/16: Update documentation to Sphinx standard and add documentation build files (issue #17)
2/17/16: Changes to correlation function plots & documentation (issue #77)
2/17/16: Changes to correlation function plots & documentation (issue #77)
2/10/15: Add a setup.py installer (issue #57)
8/26/14: Change from relying on compiled C-code corr2 to Python package TreeCorr (issue #33)
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Stile
Stile [![Build Status](https://travis-ci.org/msimet/Stile.svg?branch=master)](https://travis-ci.org/msimet/Stile)
=====

Stile: the Systematics Tests In LEnsing pipeline
Expand All @@ -7,7 +7,7 @@ Stile: the Systematics Tests In LEnsing pipeline
#### Installation instructions ####

Stile is a pure python package, no compilation needed. You can install it using:
> python setup.py install
> pip install stile
#### Dependencies ####
To run Stile, you must have:
Expand All @@ -17,17 +17,17 @@ To run Stile, you must have:

We also recommend:

- [TreeCorr](http://github.com/rmjarvis/TreeCorr), Mike Jarvis's 2-point correlation function code. All of our correlation function tests involve calls to this package.
- [TreeCorr](http://github.com/rmjarvis/TreeCorr), Mike Jarvis's 2-point correlation function code. All of our correlation function tests involve calls to this package.
- PyFITS/Astropy to handle FITS tables and images. Stile can run on ASCII tables, but is much slower.
- matplotlib to generate plots.

More dependencies may be added in the future.
Note that these dependencies will be automatically installed by pip. More dependencies may be added in the future.

-------------------------------------
#### Documentation ####

The documentation is available online at http://stile.readthedocs.io/. You can also build it using Sphinx in the `doc/` directory.

-------------------------------------

#### Current functionality ####
Expand All @@ -41,7 +41,7 @@ Right now, Stile can:
- Generate histograms.
- Perform any of the above tests for data with different binning schemes applied, using a simple method of specifying the bins.
- Interface with sufficiently recent versions of the HSC pipeline.

-------------------------------------

#### Wishlist ####
Expand All @@ -52,4 +52,3 @@ Over the upcoming months, we plan to add:
- Automatic drivers to run as many tests as your data set allows.
- A larger suite of example code.
- Tests on images, and the utilities to make those tests easier.

31 changes: 20 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
#!/usr/bin/env python
from setuptools import setup
from io import open

from distutils.core import setup
try:
import treecorr
except ImportError:
import warnings
warnings.warn("treecorr package cannot be imported. Installation will proceed, but you may "+
"wish to install it if you would like to use the correlation functions within "+
"Stile.")

# read the contents of the README file
with open('README.md', encoding="utf-8") as f:
long_description = f.read()

setup(name='Stile',
version='0.1',
description='Stile: Systematics Tests in Lensing pipeline',
author='The Stile team',
requirements=['numpy'],
install_requires=['numpy', 'treecorr', 'matplotlib', 'astropy<3'],
author_email='[email protected]',
url='https://github.com/msimet/Stile',
packages=['stile', 'stile.hsc'],
scripts=['bin/StileVisit.py', 'bin/StileVisitNoTract.py', 'bin/StileCCD.py',
'bin/StileCCDNoTract.py', 'bin/StilePatch.py', 'bin/StileTract.py']
'bin/StileCCDNoTract.py', 'bin/StilePatch.py', 'bin/StileTract.py'],
test_suite='nose.collector',
tests_require=['nose'],
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Science/Research',
'License :: OSI Approved',
'Operating System :: MacOS :: MacOS X',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Scientific/Engineering :: Physics'
]
)
2 changes: 1 addition & 1 deletion stile/file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
has_fits = False
import numpy
import os
import stile_utils
from . import stile_utils


def ReadFITSImage(file_name, hdu=0):
Expand Down
5 changes: 2 additions & 3 deletions stile/hsc/base_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,7 @@ def generateColumns(self, dataRef, catalog, mask_tuple, raw_cols, extra_col_dict

# offset for (x,y) if extra_col_dict has a column 'CCD'. Currently getMm() returns values
# in pixel. When the pipeline is updated, we should update this line as well.
if dataRef.dataId.has_key('ccd') and extra_col_dict.has_key(
'CCD') and ('x' in raw_cols or 'y' in raw_cols):
if 'ccd' in dataRef.dataId and 'CCD' in extra_col_dict and ('x' in raw_cols or 'y' in raw_cols):
xy0 = cameraGeomUtils.findCcd(dataRef.getButler().mapper.camera, cameraGeom.Id(
dataRef.dataId.get('ccd'))
).getPositionFromPixel(afwGeom.PointD(0., 0.)).getMm()
Expand Down Expand Up @@ -832,7 +831,7 @@ def run(self, visit, dataRefList):
catalogs.append(dataRef.get(self.catalog_type, immediate=True,
flags=afwTable.SOURCE_IO_NO_FOOTPRINTS))
except RuntimeError as e:
print e, ', skip this patch'
print(e, ', skip this patch')
catalogs = [self.removeFlaggedObjects(catalog) for catalog in catalogs]
sys_data_list = []
extra_col_dicts = [{} for catalog in catalogs]
Expand Down
8 changes: 4 additions & 4 deletions stile/stile_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def Parser():
"""
Returns an argparse Parser object with input args used by Stile and TreeCorr.
"""
import treecorr_utils
from . import treecorr_utils
import argparse
p = argparse.Parser(parent=treecorr_utils.Parser())
#TODO: add, obviously, EVERYTHING ELSE
Expand Down Expand Up @@ -111,7 +111,7 @@ def __init__(self, simple_stats):
self.simple_stats = simple_stats
for stat in self.simple_stats:
init_str = 'self.' + stat + '=None'
exec init_str
exec(init_str)

self.percentiles = None
self.values = None
Expand All @@ -127,11 +127,11 @@ def __str__(self):
# Loop over simple statistics and print them, if not None. Generically if one is None then
# all will be, so just check one.
test_str = "test_val = self."+("%s"%self.simple_stats[0])
exec test_str
exec(test_str)
if test_val is not None:
for stat in self.simple_stats:
this_string = 'this_val = self.'+stat
exec this_string
exec(this_string)
ret_str += '\t%s: %f\n'%(stat, this_val)
ret_str += '\n'

Expand Down
18 changes: 9 additions & 9 deletions stile/sys_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

import numpy
import stile
import stile_utils
from . import stile_utils
try:
import treecorr
from treecorr.corr2 import corr2_valid_params
Expand Down Expand Up @@ -445,24 +445,24 @@ def getCF(self, correlation_function_type, data, data2=None,
'data and random, and random2 if data2.')
elif correlation_function_type in ['gg', 'm2', 'kk']:
if random or random2:
print "Warning: randoms ignored for this correlation function type"
print("Warning: randoms ignored for this correlation function type")
elif correlation_function_type in ['ng', 'nm', 'nk']:
if data2 is None:
raise ValueError('Must include data2 for this correlation function type')
if random2 is not None:
print "Warning: random2 ignored for this correlation function type"
print("Warning: random2 ignored for this correlation function type")
elif correlation_function_type == 'norm':
if data2 is None:
raise ValueError('Must include data2 for this correlation function type')
if random is None:
raise ValueError('Must include random for this correlation function type')
if random2 is None:
print "Warning: random2 ignored for this correlation function type"
print("Warning: random2 ignored for this correlation function type")
elif correlation_function_type == 'kg':
if data2 is None:
raise ValueError('Must include data2 for this correlation function type')
if random is not None or random2 is not None:
print "Warning: randoms ignored for this correlation function type"
print("Warning: randoms ignored for this correlation function type")

data = self.makeCatalog(data, config=treecorr_kwargs, use_as_k=use_as_k,
use_chip_coords=use_chip_coords)
Expand Down Expand Up @@ -1104,9 +1104,9 @@ def __call__(self, array, percentiles=None, field=None, verbose=False, ignore_ba
# It's a catalog, not a simple array
if use_field is None:
raise RuntimeError('StatSysTest called on a catalog without specifying a field!')
if use_field not in use_array.dtype.fields.keys():
if use_field not in list(use_array.dtype.fields.keys()):
raise RuntimeError('Field %s is not in this catalog, which contains %s!'%
(use_field, use_array.dtype.fields.keys()))
(use_field, list(use_array.dtype.fields.keys())))
# Select the appropriate field for this catalog.
use_array = use_array[use_field]
# Now take care of case (b):
Expand Down Expand Up @@ -1171,7 +1171,7 @@ def __call__(self, array, percentiles=None, field=None, verbose=False, ignore_ba

# Print, if verbose=True.
if verbose:
print result.__str__()
print(result.__str__())

# Return.
return result
Expand Down Expand Up @@ -1685,7 +1685,7 @@ def HistoPlot(self, data_list, field=None, binning_style=None, nbins=None,
elif style_use is 'manual':
bins = nbins
else:
print "Unrecognized code for binning style, use default instead!"
print("Unrecognized code for binning style, use default instead!")
bins = nbins

if weights is True:
Expand Down
4 changes: 2 additions & 2 deletions stile/treecorr_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
program.
"""
import numpy
import file_io
from . import file_io
import treecorr
from treecorr.corr2 import corr2_valid_params

Expand Down Expand Up @@ -90,7 +90,7 @@ def ReadTreeCorrResultsFile(file_name):
:param file_name: The location of an output file from TreeCorr.
:returns: A numpy array corresponding to the data in ``file_name``.
"""
import stile_utils
from . import stile_utils
output = file_io.ReadASCIITable(file_name, comments='#')

if not len(output):
Expand Down

0 comments on commit 966f332

Please sign in to comment.