Skip to content

Commit

Permalink
Merge 5c72bd0 into a44cfc5
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-neal committed Nov 2, 2018
2 parents a44cfc5 + 5c72bd0 commit dcd2b97
Show file tree
Hide file tree
Showing 26 changed files with 80 additions and 75 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ before_script:

# Prepare atmosphere models
- make atmos V=1
# - python eniric_scripts/split_atmmodel.py -b K H J Y Z TEST
# - python eniric_scripts/bary_shift_atmmodel.py -b K H J Y Z TEST
# - python scripts/split_atmmodel.py -b K H J Y Z TEST
# - python scripts/bary_shift_atmmodel.py -b K H J Y Z TEST

script:
- pytest --cov=eniric --cov-report term-missing --durations 5
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ include eniric/config.yaml
include tests/config.yaml
include docs/Notebooks/*.ipynb
include docs/Notebooks/config.yaml
include eniric_scripts *
include scripts *
include Makefile
include paper/*
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ clean-data:
rm --force --recursive data/test_data/resampled

data:
python eniric_scripts/make_test_data.py
python scripts/make_test_data.py

atmos:
split_atmmodel.py -b ALL
Expand Down
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
[![PyPI version](https://badge.fury.io/py/eniric.svg)](https://badge.fury.io/py/eniric)

`Eniric` is a Python 3 software to compute the theoretical Radial Velocity (RV) precision of stellar spectra.
`Eniric` is an overhaul and extension to the code used in [Figueria et al. 2016](http://dx.doi.org/10.1051/0004-6361/201526900) to analysis the precision of M-dwarf stars.
Extending the performance and usability, it is able to be used on any synthetic spectra from the [PHOENIX-ACES](http://phoenix.astro.physik.uni-goettingen.de) and [BT-Settl](https://phoenix.ens-lyon.fr/Grids/BT-Settl/CIFIST2011_2015/FITS/) (CIFIST2001-2015) libraries.
`Eniric` is an overhaul and extension to the code used in [Figueria et al. 2016](http://dx.doi.org/10.1051/0004-6361/201526900) to analysis the precision of M-dwarf stars.
Extending the performance and usability, it is able to be used on any synthetic spectra from the [PHOENIX-ACES](http://phoenix.astro.physik.uni-goettingen.de) and [BT-Settl](https://phoenix.ens-lyon.fr/Grids/BT-Settl/CIFIST2011_2015/FITS/) (CIFIST2001-2015) libraries.

Checkout the [wiki here](https://github.com/jason-neal/eniric/wiki)!

Expand Down Expand Up @@ -59,7 +59,7 @@ see [here](https://github.com/iancze/Starfish) for more information about instal
For **windows** installation of `Starfish` also see [starfish#87](see https://github.com/iancze/Starfish/issues/87).

##### Requirements for `Eniric` :
These should be automatically installed (if not present) when installing `eniric`.
These should be automatically installed (if not present) when installing `eniric`.
- astropy
- joblib>=0.12.3
- matplotlib
Expand All @@ -70,7 +70,7 @@ These should be automatically installed (if not present) when installing `eniric
- scipy
- tqdm

If want to use known working pinned versions they can be found in `requirements_dev.txt`.
If want to use known working pinned versions they can be found in `requirements_dev.txt`.
To install these run `pip install -r requirements_dev.txt`.

##### Extra requirements for Starfish:
Expand All @@ -79,25 +79,25 @@ To install these run `pip install -r requirements_dev.txt`.
- h5py
- scikit-learn

If you are not going to use `eniric` to analyze PHOENIX-ACES or BT-Settl synthetic spectral models then you may
If you are not going to use `eniric` to analyze PHOENIX-ACES or BT-Settl synthetic spectral models then you may
get away with not installing it (some tests will just xfail).


## Preparation
#### Data download
To download the data for eniric, an atmopsheric transmission spectra and some test Spectra run the
To download the data for eniric, an atmopsheric transmission spectra and some test Spectra run the
following from the main repo directory

Linux:
`download_eniric_data.sh`

Windows:
`... `
`... `

This should place the data in `data/atmmodel` and `data/testdata` where it can be found for testing.

### Configuration
`Eniric` uses a `config.yaml` file which is required in directory where you are running `Eniric`. (i.e. the current directory)
`Eniric` uses a `config.yaml` file which is required in directory where you are running `Eniric`. (i.e. the current directory)
to specify some paths, such as the location the the synthetic spectral library.

```
Expand All @@ -110,7 +110,7 @@ The paths can either be a string or a list of strings to pass to `os.path.join`

You can use the `config.yaml` to specify custom wavelength ranges to use
```
bands:
bands:
all: [..., myband] # add myband to all list
custom_bands:
Expand All @@ -119,12 +119,12 @@ custom_bands:

You can then pass `myband` to the `band` arguments in `Eniric` scripts/functions.

This based off `Starfish` and although many keywords are needed to be present
This based off `Starfish` and although many keywords are needed to be present
for `Starfish` to run they are not used for `Eniric`'s usage of `Starfish` and are fine left blank.


#### Atmospheric data:
To perform telluric masking and account for the transmission of Earth's atmosphere a telluric spectra is required.
To perform telluric masking and account for the transmission of Earth's atmosphere a telluric spectra is required.
`Eniric` includes the telluric spectra uses in Figueira et al. 2016, averaged over 2014.
To automatically prepare the telluric masks, splitting into bands and applying the barycentric expansion run the following scripts:
- `split_atmmodel.py`
Expand All @@ -137,21 +137,21 @@ To change the telluric line cutoff depth you to 4% can pass (default = 2%) you c

`split_atmmodel.py --cutoff-depth 4`

You can specify your own telluric mask instead.
By keeping it in the same format and setting atmmodel parameters in `config.yaml` you can make use of the
You can specify your own telluric mask instead.
By keeping it in the same format and setting atmmodel parameters in `config.yaml` you can make use of the
these scripts and the`Atmosphere` class which can perform the mask cutoff and doppler shifting.

Or you can manually apply your own masking function as the mask parameter to the `rv_precision` function.

### Convolutions
The most computational component in `Eniric` is the convolutions. To help with this we use parallel prcessing and caching.

- *Caching*:
- *Caching*:
The convolution results are cached using Joblib to avoid repeating the convoutions. This can be disabled by
setting the `location: None` in the `config.yaml`.

- *Parallel Processing*:
The default number of processors used is one less then the total number of cores (N-1).
The default number of processors used is one less then the total number of cores (N-1).
You can change this by specifying the `num_procs`.
Setting `num_procs = 0` or `1` disables parallel processing.

Expand Down Expand Up @@ -186,12 +186,12 @@ It includes:
- Resolution convolution
- Re-sampling

Some scripts are given in `eniric_scripts` to run this preparation over all desired parameters automatically. You will have to modify the paths to things.
Some scripts are given in `scripts` to run this preparation over all desired parameters automatically. You will have to modify the paths to things.


#### Precision Calculations

`python eniric_scripts/nIR_precision.py`
`python scripts/nIR_precision.py`

This takes in the processed spectra and performs the precision calculations for all 3 conditions outlined in the original paper.
- Cond1. Total information
Expand All @@ -215,13 +215,13 @@ Create an empty dir to hold your analysis.
Create data dir with re-sampled, results, phoenix_dat
Copy config.yaml and adjust the paths relative to what you created and to the raw phoenix spectra.

eniric_scripts/prepare_spectra.py - This opens the phoenix flux spectra, add wavelength axis in microns and converts flux to photon counts. It saves this in the phoenix_dat dir. (The copy of wavelengths does waste space.)
scripts/prepare_spectra.py - This opens the phoenix flux spectra, add wavelength axis in microns and converts flux to photon counts. It saves this in the phoenix_dat dir. (The copy of wavelengths does waste space.)

eniric_scripts/nIR_run.py - Perform the resolution and rotational convolution on the prepared spectra.
scripts/nIR_run.py - Perform the resolution and rotational convolution on the prepared spectra.

This also does the re-sampling.

e.g. python ../Codes/eniric/eniric_scripts/nIR_run.py -s M0 M3 M6 M9 -b Y J H K -v 1.0 5.0 10.0 -R 60000 80000 100000 --sample_rate 3
e.g. python ../Codes/eniric/scripts/nIR_run.py -s M0 M3 M6 M9 -b Y J H K -v 1.0 5.0 10.0 -R 60000 80000 100000 --sample_rate 3


## Background
Expand Down
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ install:
- cmd: "move tests\\config.yaml config.yaml"

# Downloading Eniric data with powershell script for windows
- ps: ".\\eniric_scripts\\ps_download_eniric_data.ps1"
- ps: ".\\scripts\\ps_download_eniric_data.ps1"
# Generate data # Should not do much as data already downloaded.
- cmd: "%PYTHON%\\python.exe eniric\\obsolete\\make_test_data.py"

# Prepare atmosphere models
- cmd: "%PYTHON%\\python.exe eniric_scripts\\split_atmmodel.py -b ALL"
- cmd: "%PYTHON%\\python.exe eniric_scripts\\bary_shift_atmmodel.py -b ALL"
- cmd: "%PYTHON%\\python.exe scripts\\split_atmmodel.py -b ALL"
- cmd: "%PYTHON%\\python.exe scripts\\bary_shift_atmmodel.py -b ALL"

build: off

Expand Down
2 changes: 1 addition & 1 deletion docs/Notebooks/Convolution_speeds.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"\n",
"from eniric.broaden import rotational_convolution, resolution_convolution\n",
"from eniric.utilities import band_limits, load_aces_spectrum, wav_selector\n",
"from eniric_scripts.aces_precision import convolve_and_resample \n"
"from scripts.aces_precision import convolve_and_resample \n"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/Notebooks/Incremental_precision.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"source": [
"import matplotlib.pyplot as plt\n",
"from eniric.Qcalculator import incremental_rv, incremental_quality\n",
"from eniric_scripts.aces_precision import convolve_and_resample \n",
"from scripts.aces_precision import convolve_and_resample \n",
"from eniric.snr_normalization import snr_constant_band\n",
"from eniric.utilities import load_aces_spectrum"
]
Expand Down
2 changes: 1 addition & 1 deletion docs/Notebooks/Precison_with_doppler-K-band.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"\n",
"from eniric.broaden import rotational_convolution, resolution_convolution\n",
"from eniric.utilities import band_limits, load_aces_spectrum, wav_selector\n",
"from eniric_scripts.phoenix_precision import convolve_and_resample \n",
"from scripts.phoenix_precision import convolve_and_resample \n",
"from eniric.snr_normalization import snr_constant_band\n",
"from eniric.Qcalculator import rv_precision, quality\n",
"from eniric.utilities import doppler_shift_wav, doppler_shift_flux\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/Notebooks/Precison_with_doppler-Z-band.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"\n",
"from eniric.broaden import rotational_convolution, resolution_convolution\n",
"from eniric.utilities import band_limits, load_aces_spectrum, wav_selector\n",
"from eniric_scripts.phoenix_precision import convolve_and_resample \n",
"from scripts.phoenix_precision import convolve_and_resample \n",
"from eniric.snr_normalization import snr_constant_band\n",
"from eniric.Qcalculator import rv_precision, quality\n",
"from eniric.utilities import doppler_shift_wav, doppler_shift_flux\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/Notebooks/Split_verse_Weighted_masking.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"\n",
"from eniric.atmosphere import Atmosphere\n",
"from eniric.legacy import mask_clumping, RVprec_calc_masked\n",
"from eniric_scripts.aces_precision import convolve_and_resample\n",
"from scripts.aces_precision import convolve_and_resample\n",
"from eniric.snr_normalization import snr_constant_band\n",
"from eniric import Qcalculator as Q\n",
"from eniric.utilities import band_limits, load_aces_spectrum, wav_selector\n"
Expand Down
4 changes: 2 additions & 2 deletions docs/Notebooks/atmosphere_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
"outputs": [],
"source": [
"# # Preparation scripts to run if needed\n",
"# %run \"../../eniric_scripts/split_atmosphere.py -b {0}\".format(band)\n",
"# %run \"../../eniric_scripts/bary_shift_atmmodel.py -b {0}\".format(band)\n"
"# %run \"../../scripts/split_atmosphere.py -b {0}\".format(band)\n",
"# %run \"../../scripts/bary_shift_atmmodel.py -b {0}\".format(band)\n"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions eniric/obsolete/make_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
if __name__ == "__main__":
print("Eniric paths: {}".format(eniric.paths))

# subprocess.call("python eniric_scripts/prepare_data.py -s M0 M3 M6 M9 -l 4.50 -m 0.0", shell=True)
# subprocess.call("python scripts/prepare_data.py -s M0 M3 M6 M9 -l 4.50 -m 0.0", shell=True)
prepare_data(
startype=["M0", "M3", "M6", "M9"],
temp=[],
Expand All @@ -33,7 +33,7 @@
] # type: List[Tuple[List[str], List[str], List[int], List[str]]]

for (sptype, band, vel, res) in parameters:
# subprocess.call(["python eniric_scripts/nIR_run.py
# subprocess.call(["python scripts/nIR_run.py
# -s {0} -b {1} -R {2} -v {3}".format(sptype, band, res, vel)], shell=True)

nir_run(startype=sptype, vsini=vel, resolution=res, band=band, verbose=False)
2 changes: 1 addition & 1 deletion paper/paper.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ statistical weight for an external reason.
For example, masks derived from an atmospheric absorption spectrum can be used to explore the treatment
and correction the atmospheric absorption on the RV precision [@figueira_radial_2016].

The script [`phoenix_precision.py`](https://github.com/jason-neal/eniric/blob/develop/eniric_scripts/phoenix_precision.py) is provided to compute relative RV precisions of any synthetic spectra in the
The script [`phoenix_precision.py`](https://github.com/jason-neal/eniric/blob/develop/scripts/phoenix_precision.py) is provided to compute relative RV precisions of any synthetic spectra in the
[*PHOENIX-ACES*](http://phoenix.astro.physik.uni-goettingen.de) [@husser_new_2013] and
[*BT-Settl* (CIFIST2011-2015)](https://phoenix.ens-lyon.fr/Grids/BT-Settl/CIFIST2011_2015/FITS/) [@baraffe_new_2015] synthetic libraries,
given the identifying spectral parameters, making use of *Starfish*'s
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions eniric_scripts/csv2tsv.py → scripts/csv2tsv.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python
import sys

import pandas

"""Simple script using pandas to transform from *.csv to *.tsv"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if [ ! -d "$DIRECTORY" ]; then
fi
(cd $DIRECTORY
wget "https://www.dropbox.com/s/raw/uab283lmkaptsib/Average_TAPAS_2014.dat.tar.gz"
../../eniric_scripts/untar_here.py Average_TAPAS_2014.dat.tar.gz
../../scripts/untar_here.py Average_TAPAS_2014.dat.tar.gz
)


Expand All @@ -28,7 +28,7 @@ fi

(cd $DIRECTORY2
wget "https://www.dropbox.com/s/raw/oq2x7dsjeuxrf7t/obsolete.tar.gz"
../../eniric_scripts/untar_here.py obsolete.tar.gz
../../scripts/untar_here.py obsolete.tar.gz
rm obsolete.tar.gz
)

Expand All @@ -44,7 +44,7 @@ fi

(cd $DIRECTORY3
wget "https://www.dropbox.com/s/raw/i4cxjrhcbx6e37x/precision.tar.gz"
../eniric_scripts/untar_here.py precision.tar.gz
../scripts/untar_here.py precision.tar.gz
rm precision.tar.gz
)

Expand All @@ -56,6 +56,6 @@ fi
# So putting Phoenix data in dropbox now also.
(cd $DIRECTORY2
wget "https://www.dropbox.com/s/raw/skg8zwi7vnxgesj/data_raw.tar.gz"
../../eniric_scripts/untar_here.py data_raw.tar.gz
../../scripts/untar_here.py data_raw.tar.gz
rm data_raw.tar.gz
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import os
from typing import List, Tuple


import numpy as np
import multiprocess as mprocess
import numpy as np
from astropy import units as u
from astropy.units import Quantity
from numpy import ndarray
Expand Down Expand Up @@ -235,7 +234,7 @@ def do_analysis(
wav, flux, vsini, R, ref_band, sampling, **conv_kwargs
)
snr_normalize = snr_constant_band(
wav_ref, sampled_ref, snr=snr, band=ref_band, sampling=sampling, verbose=verbose,
wav_ref, sampled_ref, snr=snr, band=ref_band, sampling=sampling, verbose=verbose
)
sampled_flux = sampled_flux / snr_normalize

Expand Down Expand Up @@ -365,9 +364,7 @@ def is_already_computed(
"""Check if any combinations have already been preformed.
Correct is boolean for applied Artigau correction."""
model_par_str_args = model_format_args(model, pars)
rv_template = (
"{0:5d},{1:3.01f},{2:4.01f},{3:3.01f},{4:s},{5:3d}k,{6:4.01f},{7:3.01f},{8:3.01f},{9:1d}"
)
rv_template = "{0:5d},{1:3.01f},{2:4.01f},{3:3.01f},{4:s},{5:3d}k,{6:4.01f},{7:3.01f},{8:3.01f},{9:1d}"
no_rv_template = (
"{0:5d},{1:3.01f},{2:4.01f},{3:3.01f},{4:s},{5:3d}k,{6:4.01f},{7:3.01f},{8:1d}"
)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ mkdir $DIRECTORY
wget "https://www.dropbox.com/s/raw/uab283lmkaptsib/Average_TAPAS_2014.dat.tar.gz" -UseBasicParsing -OutFile ".\data\atmmodel\Average_TAPAS_2014.dat.tar.gz"


# Precision data
# Precision data
cd ".\data\"
wget "https://www.dropbox.com/s/raw/i4cxjrhcbx6e37x/precision.tar.gz" -UseBasicParsing -OutFile ".\precision.tar.gz"
dir
python ..\eniric_scripts\untar_here.py "precision.tar.gz"
python ..\scripts\untar_here.py "precision.tar.gz"
cd $HOMEDIR


Expand All @@ -42,21 +42,21 @@ cd $DIRECTORY
dir
# obsolete data
wget "https://www.dropbox.com/s/raw/oq2x7dsjeuxrf7t/obsolete.tar.gz" -UseBasicParsing -OutFile "obsolete.tar.gz"
python ..\..\eniric_scripts\untar_here.py ".\obsolete.tar.gz"
python ..\..\scripts\untar_here.py ".\obsolete.tar.gz"
del "obsolete.tar.gz"

# Phoenix-raw data and BT-settl raw data
wget "https://www.dropbox.com/s/raw/skg8zwi7vnxgesj/data_raw.tar.gz" -UseBasicParsing -OutFile "data_raw.tar.gz"
dir
python ..\..\eniric_scripts\untar_here.py ".\data_raw.tar.gz"
python ..\..\scripts\untar_here.py ".\data_raw.tar.gz"
del "data_raw.tar.gz"

cd $HOMEDIR

# # Phoenix-raw data
# wget "https://www.dropbox.com/s/raw/09fqard9l5s87zo/phoenix-raw.tar.gz" -UseBasicParsing -OutFile "phoenix-raw.tar.gz"
# dir
# python ..\..\eniric_scripts\untar_here.py ".\phoenix-raw.tar.gz"
# python ..\..\scripts\untar_here.py ".\phoenix-raw.tar.gz"
# del "phoenix-raw.tar.gz"
#
# cd $HOMEDIR
Expand All @@ -74,4 +74,4 @@ cd $HOMEDIR
# }
# cd $DIRECTORY
# wget https://phoenix.ens-lyon.fr/Grids/BT-Settl/CIFIST2011_2015/FITS/lte039.0-4.5-0.0a+0.0.BT-Settl.spec.fits.gz -UseBasicParsing -OutFile "lte039.0-4.5-0.0a+0.0.BT-Settl.spec.fits.gz"
# cd $HOMEDIR
# cd $HOMEDIR
File renamed without changes.
File renamed without changes.

0 comments on commit dcd2b97

Please sign in to comment.