-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from FormingWorlds/osf
Osf
- Loading branch information
Showing
9 changed files
with
133 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,14 @@ https://proteus-code.readthedocs.io | |
* `git clone [email protected]:FormingWorlds/JANUS.git` | ||
* `cd JANUS` | ||
* `pip install -e .` | ||
3. Download spectral files from the [OSF repository](https://osf.io/vehxg/) | ||
* Set the environment variable FWL_DATA to define where the spectral data files will be stored | ||
* `export FWL_DATA=...` | ||
* Run the following commands within a python environment (or script) to download all basic spectral files | ||
* `from janus.utils.data import DownloadSpectralFiles` | ||
* `DownloadSpectralFiles()` | ||
* Alternatively, you can specify which spectral data you want to download, and optionally the number of bands | ||
* `DownloadSpectralFiles("/Frostflow", 4096)` | ||
|
||
### Run instructions | ||
In the examples folder you can find python scripts showing typical usecases/workflows of atmosphere modelling with Janus. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ dependencies = [ | |
'natsort', | ||
'netcdf4', | ||
'numpy', | ||
'osfclient', | ||
'pandas', | ||
'scipy', | ||
'seaborn', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import os | ||
from osfclient.api import OSF | ||
|
||
#project ID of the stellar evolution tracks folder in the OSF | ||
project_id = 'vehxg' | ||
|
||
basic_list =[ | ||
"/Dayspring/256", | ||
"/Frostflow/256", | ||
"/Legacy", | ||
"/Mallard", | ||
"/Oak", | ||
"/Reach", | ||
"/stellar_spectra" | ||
] | ||
|
||
def download_folder(storage, folder_name, local_path): | ||
'''' | ||
Download a specific folder in the OSF repository | ||
Inputs : | ||
- storage : OSF storage name | ||
- folder_name : folder name to be downloaded | ||
- local_path : local repository where data are saved | ||
''' | ||
for file in storage.files: | ||
if file.path.startswith(folder_name): | ||
local_file_path = local_path + file.path | ||
#Create local directory if needed | ||
os.makedirs(os.path.dirname(local_file_path), exist_ok=True) | ||
#Download the file | ||
with open(local_file_path, 'wb') as local_file: | ||
file.write_to(local_file) | ||
return | ||
|
||
def DownloadSpectralFiles(fname="",nband=256): | ||
'''' | ||
Download spectral files data | ||
Inputs : | ||
- fname (optional) : folder name, i.e. "/Dayspring" | ||
if not provided download all the basic list | ||
- nband (optional) : number of band = 16, 48, 256, 4096 | ||
(only relevant for Dayspring, Frostflow and Honeyside) | ||
''' | ||
|
||
#Check if data environment variable is set up | ||
fwl_data_dir = os.getenv('FWL_DATA') | ||
if os.environ.get("FWL_DATA") == None: | ||
raise Exception("The FWL_DATA environment variable where spectral data will be downloaded needs to be set up!") | ||
|
||
#Create spectral file data repository if not existing | ||
data_dir = fwl_data_dir + "/spectral_files" | ||
if not os.path.exists(data_dir): | ||
os.makedirs(data_dir) | ||
|
||
#Link with OSF project repository | ||
osf = OSF() | ||
project = osf.project(project_id) | ||
storage = project.storage('osfstorage') | ||
|
||
#If no folder specified download all basic list | ||
if not fname: | ||
for folder in basic_list: | ||
print(folder) | ||
download_folder(storage,folder,data_dir) | ||
elif fname in ["/Dayspring","/Frostflow","/Honeyside"]: | ||
print("HERE ") | ||
folder = fname + "/" + str(nband) | ||
print(folder) | ||
download_folder(storage,folder,data_dir) | ||
elif fname in ["/Kynesgrove","/Legacy","/Mallard","/Oak","/Reach","/stellar_spectra"]: | ||
folder = fname | ||
download_folder(storage,folder,data_dir) | ||
else: | ||
print("Unrecognised folder name in DownloadSpectralFiles") | ||
|
||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters