Skip to content

Commit

Permalink
Replaced wget with urllib.request, updated tutorials, errors and warn…
Browse files Browse the repository at this point in the history
…ings in get_model, bug fix get_data with petitCODE, smooth parameter in get_model
  • Loading branch information
Tomas Stolker committed Jan 30, 2020
1 parent d70b8df commit 23947fc
Show file tree
Hide file tree
Showing 35 changed files with 492 additions and 395 deletions.
6 changes: 3 additions & 3 deletions docs/tutorials/atmospheric_models.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@
],
"source": [
"database.add_model(model='drift-phoenix',\n",
" wavel_range=(0.5, 10.),\n",
" teff_range=None,\n",
" spec_res=None)"
" wavel_range=None,\n",
" spec_res=None,\n",
" teff_range=None)"
]
},
{
Expand Down
33 changes: 20 additions & 13 deletions docs/tutorials/color_magnitude_broadband.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"metadata": {},
"outputs": [],
"source": [
"import species\n",
"import wget\n",
"import numpy as np"
"import urllib.request\n",
"import numpy as np\n",
"import species"
]
},
{
Expand Down Expand Up @@ -201,7 +201,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The isochrones from the AMES-Cond and AMES-Dusty evolutionary models are downloaded with `wget`."
"The isochrones from the AMES-Cond and AMES-Dusty evolutionary models are downloaded with `urllib.request`."
]
},
{
Expand All @@ -221,11 +221,18 @@
}
],
"source": [
"wget.download('https://phoenix.ens-lyon.fr/Grids/AMES-Cond/ISOCHRONES/model.AMES-Cond-2000.M-0.0.NaCo.Vega',\n",
" out='data/model.AMES-Cond-2000.M-0.0.NaCo.Vega')\n",
"\n",
"wget.download('https://phoenix.ens-lyon.fr/Grids/AMES-Dusty/ISOCHRONES/model.AMES-dusty.M-0.0.NaCo.Vega',\n",
" out='data/model.AMES-dusty.M-0.0.NaCo.Vega')"
"urllib.request.urlretrieve('https://phoenix.ens-lyon.fr/Grids/AMES-Cond/ISOCHRONES/model.AMES-Cond-2000.M-0.0.NaCo.Vega',\n",
" 'data/model.AMES-Cond-2000.M-0.0.NaCo.Vega')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"urllib.request.urlretrieve('https://phoenix.ens-lyon.fr/Grids/AMES-Dusty/ISOCHRONES/model.AMES-dusty.M-0.0.NaCo.Vega',\n",
" 'data/model.AMES-dusty.M-0.0.NaCo.Vega')"
]
},
{
Expand Down Expand Up @@ -295,13 +302,13 @@
"source": [
"database.add_model(model='ames-cond',\n",
" wavel_range=(0.5, 10.),\n",
" teff_range=(100., 4000.),\n",
" spec_res=1000.)\n",
" spec_res=1000.,\n",
" teff_range=(100., 4000.))\n",
"\n",
"database.add_model(model='ames-dusty',\n",
" wavel_range=(0.5, 10.),\n",
" teff_range=(100., 4000.),\n",
" spec_res=1000.)"
" spec_res=1000.,\n",
" teff_range=(100., 4000.))"
]
},
{
Expand Down
30 changes: 19 additions & 11 deletions docs/tutorials/color_magnitude_narrowband.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"metadata": {},
"outputs": [],
"source": [
"import species\n",
"import wget\n",
"import numpy as np"
"import urllib.request\n",
"import numpy as np\n",
"import species"
]
},
{
Expand Down Expand Up @@ -1060,8 +1060,8 @@
"source": [
"database.add_model(model='ames-cond',\n",
" wavel_range=(0.5, 10.),\n",
" teff_range=(100., 4000.),\n",
" spec_res=1000.)"
" spec_res=1000.\n",
" teff_range=(100., 4000.))"
]
},
{
Expand Down Expand Up @@ -1090,8 +1090,8 @@
"source": [
"database.add_model(model='ames-dusty',\n",
" wavel_range=(0.5, 10.),\n",
" teff_range=(100., 4000.),\n",
" spec_res=1000.)"
" spec_res=1000.\n",
" teff_range=(100., 4000.))"
]
},
{
Expand All @@ -1118,10 +1118,18 @@
}
],
"source": [
"wget.download('https://phoenix.ens-lyon.fr/Grids/AMES-Cond/ISOCHRONES/model.AMES-Cond-2000.M-0.0.NaCo.Vega',\n",
" out='data/model.AMES-Cond-2000.M-0.0.NaCo.Vega')\n",
"wget.download('https://phoenix.ens-lyon.fr/Grids/AMES-Dusty/ISOCHRONES/model.AMES-dusty.M-0.0.NaCo.Vega',\n",
" out='data/model.AMES-dusty.M-0.0.NaCo.Vega')"
"urllib.request.urlretrieve('https://phoenix.ens-lyon.fr/Grids/AMES-Cond/ISOCHRONES/model.AMES-Cond-2000.M-0.0.NaCo.Vega',\n",
" 'data/model.AMES-Cond-2000.M-0.0.NaCo.Vega')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"urllib.request.urlretrieve('https://phoenix.ens-lyon.fr/Grids/AMES-Dusty/ISOCHRONES/model.AMES-dusty.M-0.0.NaCo.Vega',\n",
" 'data/model.AMES-dusty.M-0.0.NaCo.Vega')"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/data_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@
"source": [
"database.add_model(model='ames-cond',\n",
" wavel_range=(0.1, 6.),\n",
" teff_range=(2800., 3000.),\n",
" spec_res=1000.)"
" spec_res=1000.\n",
" teff_range=(2800., 3000.))"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/fitting_photometry.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
"source": [
"database.add_model(model='drift-phoenix',\n",
" wavel_range=None,\n",
" teff_range=None,\n",
" spec_res=None)"
" spec_res=None\n",
" teff_range=None)"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/flux_magnitude.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Initiating species v0.1.0... [DONE]\n",
"Initiating species v0.1.2... [DONE]\n",
"Creating species_config.ini... [DONE]\n",
"Database: /Users/tomasstolker/applications/species/docs/tutorials/species_database.hdf5\n",
"Data folder: /Users/tomasstolker/applications/species/docs/tutorials/data\n",
Expand All @@ -28,7 +28,7 @@
{
"data": {
"text/plain": [
"<species.core.setup.SpeciesInit at 0x1083eff28>"
"<species.core.setup.SpeciesInit at 0x108831e48>"
]
},
"execution_count": 1,
Expand Down Expand Up @@ -61,7 +61,7 @@
"text": [
"Adding filter: JWST/NIRCam.F115W... [DONE]\n",
"Downloading Vega spectrum (270 kB)... [DONE]\n",
"Adding Vega spectrum...[DONE]\n",
"Adding Vega spectrum... [DONE]\n",
"Flux density [W m-2 micron-1] = 4.15e-15 +/- 7.69e-16\n"
]
}
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/photometric_calibration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"metadata": {},
"outputs": [],
"source": [
"import urllib.request\n",
"import species\n",
"import wget\n",
"from IPython.display import Image"
]
},
Expand Down Expand Up @@ -187,8 +187,8 @@
}
],
"source": [
"wget.download('http://irtfweb.ifa.hawaii.edu/~spex/IRTF_Spectral_Library/Data/G8V_HD75732.txt',\n",
" out='data/G8V_HD75732.txt')"
"urllib.request.urlretrieve('http://irtfweb.ifa.hawaii.edu/~spex/IRTF_Spectral_Library/Data/G8V_HD75732.txt',\n",
" 'data/G8V_HD75732.txt')"
]
},
{
Expand Down
42 changes: 30 additions & 12 deletions docs/tutorials/synthetic_photometry.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"metadata": {},
"outputs": [],
"source": [
"import species\n",
"import wget\n",
"import numpy as np"
"import urllib.request\n",
"import numpy as np\n",
"import species"
]
},
{
Expand All @@ -27,7 +27,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Initiating species v0.1.0... [DONE]\n",
"Initiating species v0.1.2... [DONE]\n",
"Creating species_config.ini... [DONE]\n",
"Database: /Users/tomasstolker/applications/species/docs/tutorials/species_database.hdf5\n",
"Data folder: /Users/tomasstolker/applications/species/docs/tutorials/data\n",
Expand All @@ -39,7 +39,7 @@
{
"data": {
"text/plain": [
"<species.core.setup.SpeciesInit at 0x123ce14e0>"
"<species.core.setup.SpeciesInit at 0x12f882048>"
]
},
"execution_count": 2,
Expand All @@ -55,17 +55,35 @@
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"('data/plnt_Jupiter.txt', <http.client.HTTPMessage at 0x12f953f28>)"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"urllib.request.urlretrieve('http://irtfweb.ifa.hawaii.edu/~spex/IRTF_Spectral_Library/Data/plnt_Jupiter.txt',\n",
" 'data/plnt_Jupiter.txt')"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"wget.download('http://irtfweb.ifa.hawaii.edu/~spex/IRTF_Spectral_Library/Data/plnt_Jupiter.txt',\n",
" out='data/plnt_Jupiter.txt')\n",
"\n",
"wavelength, flux, error = np.loadtxt('data/plnt_Jupiter.txt', unpack=True)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -74,7 +92,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand All @@ -83,7 +101,7 @@
"text": [
"Adding filter: JWST/NIRCam.F115W... [DONE]\n",
"Downloading Vega spectrum (270 kB)... [DONE]\n",
"Adding Vega spectrum...[DONE]\n"
"Adding Vega spectrum... [DONE]\n"
]
}
],
Expand All @@ -94,7 +112,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"metadata": {},
"outputs": [
{
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ scipy ~= 1.4
spectres ~= 2.0
tqdm ~= 4.42
xlrd ~= 1.2
wget ~= 3.2
2 changes: 1 addition & 1 deletion species/analysis/fit_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def lnlike(param,
chisq += (item[0]-flux)**2 / item[1]**2

if spectrum is not None:
model = modelspec.get_model(paramdict, None)
model = modelspec.get_model(paramdict)

flux_new = spectres.spectres(new_spec_wavs=spectrum[:, 0],
old_spec_wavs=model.wavelength,
Expand Down
8 changes: 4 additions & 4 deletions species/core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self):
None
"""

print(f'Initiating species v{species.__version__}...', end='')
print(f'Initiating species v{species.__version__}...', end='', flush=True)

working_folder = os.path.abspath(os.getcwd())

Expand All @@ -33,7 +33,7 @@ def __init__(self):

if not os.path.isfile(config_file):

print('Creating species_config.ini...', end='')
print('Creating species_config.ini...', end='', flush=True)

with open(config_file, 'w') as file_obj:
file_obj.write('[species]\n')
Expand All @@ -53,12 +53,12 @@ def __init__(self):
print(f'Working folder: {working_folder}')

if not os.path.isfile(database_file):
print('Creating species_database.hdf5...', end='')
print('Creating species_database.hdf5...', end='', flush=True)
h5_file = h5py.File(database_file, 'w')
h5_file.close()
print(' [DONE]')

if not os.path.exists(data_folder):
print('Creating data folder...', end='')
print('Creating data folder...', end='', flush=True)
os.makedirs(data_folder)
print(' [DONE]')
Loading

0 comments on commit 23947fc

Please sign in to comment.