Commit 9c875126 authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Small minor tweaks

1) Update README installation instructions
2) Put all set_up code into seperate named functions
3) Remove underhanded mpl backend setter
parent 35b898da
...@@ -35,11 +35,48 @@ the stripped down [miniconda](http://conda.pydata.org/miniconda.html) ...@@ -35,11 +35,48 @@ the stripped down [miniconda](http://conda.pydata.org/miniconda.html)
installation, or the full-featured installation, or the full-featured
[anaconda](https://www.continuum.io/downloads) (these are essentially the [anaconda](https://www.continuum.io/downloads) (these are essentially the
same, but the `anaconda` version installs a variety of useful packages such as same, but the `anaconda` version installs a variety of useful packages such as
`numpy` and `scipy` by default. `numpy` and `scipy` by default). Instructions to install miniconda/anaconda
are provided in the links.
### Dependencies
`pyfstat` makes use of a variety python modules listed as the
`imports` in the top of `pyfstat.py`. The first set are core modules (such as
`os`, `sys`) while the second set are external and need to be installed for
`pyfstat` to work properly. Please install the following widely available
modules:
* [numpy](http://www.numpy.org/)
* [matplotlib](http://matplotlib.org/)
* [scipy](https://www.scipy.org/)
* [emcee](http://dan.iel.fm/emcee/current/)
* [corner](https://pypi.python.org/pypi/corner/)
* [dill](https://pypi.python.org/pypi/dill)
* [tqdm](https://pypi.python.org/pypi/tqdm)(optional), if installed, this
provides a useful progress bar and estimate of the remaining run-time.
For an introduction to installing modules see
[here](https://docs.python.org/3.5/installing/index.html). If you are using
`pip`, to install all of these modules, run
```
$ pip install -r /PATH/TO/THIS/DIRECTORY/requirements.txt
```
If you have installed python from conda then `pip` itself can be installed via
`conda install pip`.
In addition to these modules, you also need a working **swig-enabled**
[`lalapps`](http://software.ligo.org/docs/lalsuite/lalsuite/) with
at least `lalpulsar`. A minimal confuration line to use when installing
`lalapps` is
```
$ ./configure --prefix=${HOME}/lalsuite-install --disable-all-lal --enable-lalpulsar --enable-lalapps --enable-swig
```
### `pyfstat` installation ### `pyfstat` installation
The script can be installed system wide via The script can be installed system wide, assuming you are in this directory, via
``` ```
$ python setup.py install $ python setup.py install
``` ```
...@@ -55,8 +92,8 @@ the module will be installed to whichever python executable you call it from. ...@@ -55,8 +92,8 @@ the module will be installed to whichever python executable you call it from.
The scripts require a path to ephemeris files in order to use the The scripts require a path to ephemeris files in order to use the
`lalpulsar.ComputeFstat` module. This can either be specified when initialising `lalpulsar.ComputeFstat` module. This can either be specified when initialising
each search, or more simply by placing a file `~/.pyfstat.conf` into your home each search (as one of the arguments), or simply by placing a file
directory which looks like `~/.pyfstat.conf` into your home directory which looks like
``` ```
earth_ephem = '/home/<USER>/lalsuite-install/share/lalpulsar/earth00-19-DE421.dat.gz' earth_ephem = '/home/<USER>/lalsuite-install/share/lalpulsar/earth00-19-DE421.dat.gz'
...@@ -64,34 +101,4 @@ sun_ephem = '/home/<USER>/lalsuite-install/share/lalpulsar/sun00-19-DE421.dat.gz ...@@ -64,34 +101,4 @@ sun_ephem = '/home/<USER>/lalsuite-install/share/lalpulsar/sun00-19-DE421.dat.gz
``` ```
here, we use the default ephemeris files provided with `lalsuite`. here, we use the default ephemeris files provided with `lalsuite`.
### Dependencies
The installation above will complete succesfully without the following
dependencies, but you will subsequently find various `ImportError` messages
when running `pyfstat` scripts if you haven't installed the following modules.
* swig-enabled [`lalapps`](http://software.ligo.org/docs/lalsuite/lalsuite/) with
at least `lalpulsar`. A minimal confuration line to use when installing
`lalapps` is
```
$ ./configure --prefix=${HOME}/lalsuite-install --disable-all-lal --enable-lalpulsar --enable-lalapps --enable-swig
```
* If using the MCMC tools, you will need to install the following python
modules
* [numpy](http://www.numpy.org/)
* [scipy](https://www.scipy.org/)
* [emcee](http://dan.iel.fm/emcee/current/)
* [corner](https://pypi.python.org/pypi/corner/)
* [dill](https://pypi.python.org/pypi/dill)
* [tqdm](https://pypi.python.org/pypi/tqdm)(optional), if installed, this
provides a useful progress bar and estimate of the remaining run-time.
To install all of these modules, run
```
$ pip install -r /PATH/TO/THIS/DIRECTORY/requirements.txt
```
where `pip` is the python package installer, if you have installed python
from conda then it can be installed via `conda install pip`.
...@@ -13,7 +13,6 @@ from collections import OrderedDict ...@@ -13,7 +13,6 @@ from collections import OrderedDict
import numpy as np import numpy as np
import matplotlib import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import scipy.special import scipy.special
import scipy.optimize import scipy.optimize
...@@ -23,60 +22,73 @@ import dill as pickle ...@@ -23,60 +22,73 @@ import dill as pickle
import lal import lal
import lalpulsar import lalpulsar
try:
from tqdm import tqdm
except ImportError:
def tqdm(x, *args, **kwargs):
return x
plt.rcParams['text.usetex'] = True
plt.rcParams['axes.formatter.useoffset'] = False
config_file = os.path.expanduser('~')+'/.pyfstat.conf' def set_up_optional_tqdm():
if os.path.isfile(config_file): try:
d = {} from tqdm import tqdm
with open(config_file, 'r') as f: except ImportError:
for line in f: def tqdm(x, *args, **kwargs):
k, v = line.split('=') return x
k = k.replace(' ', '')
v = v.replace(' ', '').replace("'", "").replace('"', '').replace('\n', '')
d[k] = v def set_up_matplotlib_defaults():
earth_ephem = d['earth_ephem'] plt.switch_backend('Agg')
sun_ephem = d['sun_ephem'] plt.rcParams['text.usetex'] = True
else: plt.rcParams['axes.formatter.useoffset'] = False
logging.warning('No ~/.pyfstat.conf file found please provide the paths '
'when initialising searches')
earth_ephem = None def set_up_ephemeris_configuration():
sun_ephem = None config_file = os.path.expanduser('~')+'/.pyfstat.conf'
if os.path.isfile(config_file):
parser = argparse.ArgumentParser() d = {}
parser.add_argument("-q", "--quite", help="Decrease output verbosity", with open(config_file, 'r') as f:
action="store_true") for line in f:
parser.add_argument("--no-interactive", help="Don't use interactive output", k, v = line.split('=')
action="store_true") k = k.replace(' ', '')
parser.add_argument("-c", "--clean", help="Don't use cached data", for item in [' ', "'", '"', '\n']:
action="store_true") v = v.replace(item, '')
parser.add_argument("-u", "--use-old-data", action="store_true") d[k] = v
parser.add_argument('-s', "--setup-only", action="store_true") earth_ephem = d['earth_ephem']
parser.add_argument('-n', "--no-template-counting", action="store_true") sun_ephem = d['sun_ephem']
parser.add_argument('unittest_args', nargs='*') else:
args, unknown = parser.parse_known_args() logging.warning('No ~/.pyfstat.conf file found please provide the '
sys.argv[1:] = args.unittest_args 'paths when initialising searches')
earth_ephem = None
if args.quite or args.no_interactive: sun_ephem = None
def tqdm(x, *args, **kwargs):
return x
def set_up_command_line_arguments():
logger = logging.getLogger() parser = argparse.ArgumentParser()
logger.setLevel(logging.DEBUG) parser.add_argument("-q", "--quite", help="Decrease output verbosity",
stream_handler = logging.StreamHandler() action="store_true")
if args.quite: parser.add_argument("--no-interactive", help="Don't use interactive",
stream_handler.setLevel(logging.WARNING) action="store_true")
else: parser.add_argument("-c", "--clean", help="Don't use cached data",
stream_handler.setLevel(logging.DEBUG) action="store_true")
stream_handler.setFormatter(logging.Formatter( parser.add_argument("-u", "--use-old-data", action="store_true")
'%(asctime)s %(levelname)-8s: %(message)s', datefmt='%H:%M')) parser.add_argument('-s', "--setup-only", action="store_true")
logger.addHandler(stream_handler) parser.add_argument('-n', "--no-template-counting", action="store_true")
parser.add_argument('unittest_args', nargs='*')
args, unknown = parser.parse_known_args()
sys.argv[1:] = args.unittest_args
if args.quite or args.no_interactive:
def tqdm(x, *args, **kwargs):
return x
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
stream_handler = logging.StreamHandler()
if args.quite:
stream_handler.setLevel(logging.WARNING)
else:
stream_handler.setLevel(logging.DEBUG)
stream_handler.setFormatter(logging.Formatter(
'%(asctime)s %(levelname)-8s: %(message)s', datefmt='%H:%M'))
logger.addHandler(stream_handler)
set_up_optional_tqdm()
set_up_matplotlib_defaults()
set_up_ephemeris_configuration()
set_up_command_line_arguments()
def round_to_n(x, n): def round_to_n(x, n):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment