Skip to content

Commit

Permalink
Merge pull request spacetelescope#434 from bhilbert4/install-requires…
Browse files Browse the repository at this point in the history
…-update

Update for pip install
  • Loading branch information
bhilbert4 committed Jan 23, 2020
2 parents 2cf5607 + 4a0864e commit ea14551
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 108 deletions.
10 changes: 8 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Master Branch
=============
1.3
===

Installation
------------

setup.py has been modified to support installation via pip and Pypi. Installation documentation has been updated to describe the new process.


Gain Values
-----------
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ reads of the detector are present.
## Installation and Documentation

The [main documentation for Mirage](https://mirage-data-simulator.readthedocs.io/en/latest/) is located on ReadTheDocs.

Please find detailed installation instructions on our [ReadTheDocs](https://mirage-data-simulator.readthedocs.io/en/latest/install.html) page.
[Detailed installation instructions](https://mirage-data-simulator.readthedocs.io/en/latest/install.html) can be found there.


## Examples
Expand All @@ -34,7 +33,7 @@ for imaging simulations, WFSS simulations, moving target

### Citation
If you find this package useful, please consider citing the Zenodo record using the DOI badge above.
Please find additional citation instructions in [CITATION](CITATION).
Please find additional citation instructions in [CITATION](CITATION).


## Contributing
Expand Down
126 changes: 49 additions & 77 deletions docs/install.rst
Original file line number Diff line number Diff line change
@@ -1,105 +1,77 @@
Installing MIRAGE
=================
There are two aspects to Mirage installation. First, the software itself must be installed. Once this is complete, there is a set of reference files which
must be downloaded. The preferred installation method is via :ref:`Pypi <pypi>`, as this is the latest stable version of the software.

The easiest way to get a working installation of Mirage is to use the YAML file in the root directory, ``environment.yml``, to create a MIRaGe-specific conda environment.

You can then use this environment whenever you need to use MIRaGe, or build upon it for any larger projects that require MIRaGe.
.. _pypi:

Set up a conda environment
--------------------------
First, be sure that your conda installation is up to date. Exit any currently activated environment, if necessary.::
Install from Pypi
-----------------

conda deactivate
conda update conda
Mirage is now hosted on `Pypi <https://pypi.org/project/mirage/>`_. To install the latest stable version of Mirage, use the commands below. In this example, we create
a conda environment called "mirage" and then install the software into that environment. After installing Mirage, there are three packages which must be installed separately.
These are: **jwst**, which is the JWST calibration pipeline software, and two packages that help to create dispersed data using the grisms.

Get a copy of the MIRaGe repository::

git clone https://github.com/spacetelescope/mirage.git

Move into the mirage directory and use the environment file to create a new environment. Give your environment a name you will recognize (here we choose ``mirage``)::

cd mirage
conda env create -f environment.yml -n mirage

Once the environment is built, activate it.::
::

conda create -n mirage python=3.6 -y
conda activate mirage
pip install healpy==1.12.5
pip install mirage
pip install git+https://github.com/npirzkal/GRISMCONF#egg=grismconf
pip install git+https://github.com/npirzkal/NIRCAM_Gsim#egg=nircam_gsim
pip install git+https://github.com/spacetelescope/jwst@0.14.2

Move out of the mirage directory before cloning and installing any of the depenencies.::

cd ../


Install Development-Version Dependencies
----------------------------------------

Unfortunately, there are conflicts with some of MIRaGe's dependencies that have not been addressed in the latest pip and conda versions. So, in order for MIRaGe to work, we need to download and install the development versions of those packages. (This will no longer be necessary once both packages make new releases.)

If you do not have a copy of the ``poppy`` or ``webbpsf`` git repositories, clone them::
.. tip::
Some of Mirage's dependencies rely on `Healpy <https://healpy.readthedocs.io/en/latest/>`_,. Healpy has released different wheels for different versions of Mac OSX. For example, healpy version 1.12.5
works for MacOSX 10.13 (High Sierra). If the version of healpy above does not work for your system, you may need to install a different version.

git clone git://github.com/spacetelescope/poppy.git
git clone git://github.com/spacetelescope/webbpsf.git
.. tip::
This method installs `webbpsf <https://webbpsf.readthedocs.io/en/latest/>`_ via pip. In this case, you must also `manually download the collection of webbpsf data files <https://webbpsf.readthedocs.io/en/latest/installation.html#installing-the-required-data-files>`_ If you install webbpsf via conda, the data files are downloaded and installed for you.

If you already have a local copy of these packages, first make sure you have the most up-to-date version. Here we assume that you have previously cloned
the repository and that the ``origin`` remote points to the package. This is git's default behavior. If in doubt, simply delete the local copies and re-clone
using the commands above.::

cd poppy
git fetch origin master
git pull origin master
Install the Development Version
-------------------------------

cd ../webbpsf
git fetch origin master
git pull origin master
cd ../
For those wishing to contribute to the code base, you can install Mirage by cloning and installing the repository. This is only
recommended for those looking to help with development. In general, those wishing only to use Mirage should install the latest stable version from :ref:`Pypi <pypi>`.

Then, install both ``poppy`` and ``webbpsf``::

pip install -e poppy
pip install -e webbpsf
Clone the Mirage repository::

git clone https://github.com/spacetelescope/mirage.git

Install MIRaGe
--------------

Next, install MIRaGe::

pip install -e mirage

This ``pip`` command will also always install all required dependencies (though in this case, they were already installed when we built our conda environment). If you want to know what dependencies MIRaGe requires,, the list of packages can
be viewed in the ``install_requires`` part of this repository's `setup.py file <../setup.py>`_.

Install Supporting Packages
---------------------------

If you plan to use MIRaGe to simulate **Wide Field Slitless (WFSS)** observations, you will also need to download two supporting packages:

- `NIRCam_Gsim <https://github.com/npirzkal/NIRCAM_Gsim>`_
- `GRISMCONF <https://github.com/npirzkal/GRISMCONF>`_
Installation can then be done via pip, which uses setup.py, or using the conda environment file that is included in the package.

For each of these packages, download the repository if you do not have a local copy::
To install using pip and setup.py:
Create and activate a new environment. In this example we call the environment "mirage". Then move into the mirage directory, and install Mirage into the new environment::

git clone https://github.com/npirzkal/NIRCAM_Gsim.git
git clone https://github.com/npirzkal/GRISMCONF.git
conda create -n mirage python=3.6 -y
conda activate mirage
cd mirage
pip install healpy==1.12.5
pip install .
pip install git+https://github.com/npirzkal/GRISMCONF#egg=grismconf
pip install git+https://github.com/npirzkal/NIRCAM_Gsim#egg=nircam_gsim
pip install git+https://github.com/spacetelescope/jwst@0.14.2

Or, if you already have a local copy, make sure you have the most recent version. Here we assume that you have previously cloned
the repository and that the ``origin`` remote points to the package. This is git's default behavior. If in doubt, simply delete the local copies and re-clone
using the commands above.::
.. tip::
Some of Mirage's dependencies rely on `Healpy <https://healpy.readthedocs.io/en/latest/>`_,. Healpy has released different wheels for different versions of Mac OSX. For example, healpy version 1.12.5
works for MacOSX 10.13 (High Sierra). If the version of healpy above does not work for your system, you may need to install a different version.

cd ../NIRCAM_Gsim
git fetch upstream master
git pull upstream master
cd ../
.. tip::
This method installs `webbpsf <https://webbpsf.readthedocs.io/en/latest/>`_ via pip. In this case, you must also `manually download the collection of webbpsf data files <https://webbpsf.readthedocs.io/en/latest/installation.html#installing-the-required-data-files>`_ If you install webbpsf via conda, the data files are downloaded and installed for you.

cd ../GRISMCONF
git fetch upstream master
git pull upstream master
cd ../
Or, to install using the environment file, again creating an environment called "mirage"::

Then install::
cd mirage
conda env create -f environment.yml --name mirage python=3.6
conda activate mirage
pip install .

pip install -e NIRCAM_Gsim
pip install -e GRISMCONF
.. tip::
For this latter case, packages are installed via conda. For `webbpsf <https://webbpsf.readthedocs.io/en/latest/installation.html#requirements-installation>`_, this means the data files will be downloaded and installed with the software itself. No manual installation of the data files is necessary.

.. _ref_file_collection:

Expand Down
17 changes: 10 additions & 7 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,30 @@ channels:
- conda-forge
- defaults
dependencies:
- asdf>=2.1.0.dev1+ga161518
- asdf>=2.1.0
- astropy==3.2.1
- astroquery>=0.3.8
- crds>=7.4.1
- gwcs>=0.10a.dev21+g75e92da
- healpy>=1.10
- gwcs>=0.11
- healpy>=1.12.5
- h5py>=2.8.0
- ipython
- jupyter
- jwxml>=0.3.0
- lxml>=3.6.4
- matplotlib>=3.0.0
- numpy>=1.16
- photutils>=0.6
- pip>=18.0
- pysynphot>=0.9.12
- pytest>=3.8.1
- python>=3.6,<3.7
- scipy>=1.1.0
- sphinx>=2.1
- synphot>=0.2.0
- webbpsf>=0.9.0
- yaml==0.1.7
- pyyaml>=5.1.2
- pip:
- jwst-backgrounds>=1.1.1
- pysiaf>=0.6.1
- git+https://github.com/spacetelescope/jwst@0.13.8
- git+https://github.com/spacetelescope/jwst@0.14.2
- git+https://github.com/npirzkal/GRISMCONF
- git+https://github.com/npirzkal/NIRCAM_Gsim
47 changes: 28 additions & 19 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,15 @@ def run(self):
print('!\n! Sphinx is not installed!\n!', file=sys.stderr)
exit(1)


# make sure jwst is available
try:
import jwst
except ImportError:
try:
subprocess.check_call(['git', 'clone',
'https://github.com/spacetelescope/jwst.git'])
sys.path.insert(1, 'jwst')
# import jwst
except subprocess.CalledProcessError as e:
print(e)
exit(1)

DOCS_REQUIRE = [
'sphinx',
'sphinx-automodapi',
'sphinx-rtd-theme',
'stsci-rtd-theme',
]
TESTS_REQUIRE = [
'pytest',
]

setup(
name='mirage',
Expand Down Expand Up @@ -92,17 +87,31 @@ def run(self):
use_scm_version=True,
setup_requires=['setuptools_scm'],
install_requires=[
'asdf>=1.2.0',
'asdf>=2.1.0',
'astropy>=3.2.1',
'astroquery>=0.3.8',
'crds>=7.4.1',
'gwcs>=0.11',
'h5py>=2.8.0',
'ipython',
'jupyter',
'jwst-backgrounds>=1.1.1',
'lxml>=3.6.4',
'matplotlib>=1.4.3',
'matplotlib>=3.0.0',
'numpy',
'photutils>=0.4.0',
'pysiaf>=0.6.1'
'scipy>=0.17',
'photutils>=0.7.2',
'pysiaf>=0.6.1',
'scipy>=1.1.0',
'synphot>=0.2.0',
'webbpsf>=0.9.0',
'pyyaml>=5.1.2'
],
include_package_data=True,
extras_require={
'docs': DOCS_REQUIRE,
'test': TESTS_REQUIRE,
},
tests_require=TESTS_REQUIRE,
cmdclass={
'build_sphinx': BuildSphinx
},)

0 comments on commit ea14551

Please sign in to comment.