From 270f56ccefb8728227f03651abb9f8a351db541c Mon Sep 17 00:00:00 2001 From: Jayshil Date: Mon, 5 Feb 2024 16:40:43 +0100 Subject: [PATCH 1/2] Paths --- .gitignore | 1 + pipe/__init__.py | 3 ++- pipe/config/pipeconf.py | 21 +++++++++++++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index e4d05a0..4d21349 100644 --- a/.gitignore +++ b/.gitignore @@ -152,3 +152,4 @@ pipe/config/conf_rubicon.json pipe/config/conf_hydra.json conf_rubicon.json conf_hydra.json +*.DS_Store \ No newline at end of file diff --git a/pipe/__init__.py b/pipe/__init__.py index c9cae30..73991e7 100644 --- a/pipe/__init__.py +++ b/pipe/__init__.py @@ -28,4 +28,5 @@ ) from .pipe_control import PipeControl from .pipe_param import PipeParam -from .pipe_statistics import mad, sigma_clip \ No newline at end of file +from .pipe_statistics import mad, sigma_clip +from .config import conf \ No newline at end of file diff --git a/pipe/config/pipeconf.py b/pipe/config/pipeconf.py index 0a11c28..2975c58 100644 --- a/pipe/config/pipeconf.py +++ b/pipe/config/pipeconf.py @@ -2,14 +2,31 @@ import os import astropy.config as astropyconfig - def cache_dir(): return astropyconfig.get_cache_dir() -def get_conf_paths(): +def get_conf_paths(overwrite=False): # Get configuration information from setup.cfg conf_path = os.path.join(os.path.dirname(__file__), 'conf.json') + + if (not os.path.isfile(conf_path))|(overwrite): + # First creating a file + data_path = input('Please enter a path to the data files\nPress ENTER to use the home directory\n(a directory called cheops-pipe will be created inside the home directory): ') + ref_path = input('Please enter a path to the calibration files\nPress ENTER to use the home directory\n(a directory called cheops-pipe will be created inside the home directory): ') + if data_path == '': + data_path = os.path.expanduser('~') + '/cheops-pipe/Data' + if ref_path == '': + ref_path = os.path.expanduser('~') + '/cheops-pipe/Ref' + fconf = open(os.path.dirname(__file__) + '/conf.json', 'w') + fconf.write('{\n') + fconf.write('\t"data_root" : "' + data_path + '",\n') + fconf.write('\t"ref_lib_data" : "' + ref_path + '"\n') + fconf.write('}') + fconf.close() + # And loading it + conf_path = os.path.join(os.path.dirname(__file__), 'conf.json') + with open(conf_path, 'r') as confstream: confparse = json.load(confstream) data_root_cfg = confparse.get("data_root") From 9cc746f25e94a8f09ed273817159abb5ed372a30 Mon Sep 17 00:00:00 2001 From: Jayshil Date: Mon, 5 Feb 2024 16:48:41 +0100 Subject: [PATCH 2/2] changed the wording --- pipe/config/pipeconf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pipe/config/pipeconf.py b/pipe/config/pipeconf.py index 2975c58..76d78dd 100644 --- a/pipe/config/pipeconf.py +++ b/pipe/config/pipeconf.py @@ -12,8 +12,8 @@ def get_conf_paths(overwrite=False): if (not os.path.isfile(conf_path))|(overwrite): # First creating a file - data_path = input('Please enter a path to the data files\nPress ENTER to use the home directory\n(a directory called cheops-pipe will be created inside the home directory): ') - ref_path = input('Please enter a path to the calibration files\nPress ENTER to use the home directory\n(a directory called cheops-pipe will be created inside the home directory): ') + data_path = input('Please enter a path to the data files\nThe default path is ~/cheops-pipe/Data (press ENTER to use this): ') + ref_path = input('Please enter a path to the calibration files\nThe default path is ~/cheops-pipe/Ref (press ENTER to use this): ') if data_path == '': data_path = os.path.expanduser('~') + '/cheops-pipe/Data' if ref_path == '':