Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow gaia data_dir to be absolute path #97

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions skycatalogs/objects/gaia_object.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import warnings
from functools import wraps
import itertools
from collections.abc import Iterable
from pathlib import PurePath
import numpy as np
Expand Down Expand Up @@ -157,7 +156,10 @@ def _read_fits(htm_id, gaia_config, sky_root, out_dict, logger, region=None):
f_dir = gaia_config['data_dir']
f_name = gaia_config['basename_template'].replace('(?P<htm>\\d+)',
f'{htm_id}')
f_path = os.path.join(sky_root, f_dir, f_name)
if os.path.isabs(f_dir):
f_path = os.path.join(f_dir, f_name)
else:
f_path = os.path.join(sky_root, f_dir, f_name)
if not os.path.isfile(f_path):
logger.info(f'No file for requested htm id {htm_id}')
return
Expand Down Expand Up @@ -236,6 +238,7 @@ class GaiaCollection(ObjectCollection):
def set_config(cls, config):
GaiaCollection._gaia_config = config
GaiaCollection._id_prefix = config['id_prefix']

@classmethod
def get_config(cls):
return GaiaCollection._gaia_config
Expand Down
2 changes: 1 addition & 1 deletion skycatalogs/utils/config_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def include(self, node: yaml.Node) -> list[Any] | dict[str, Any]:
raise yaml.constructor.ConstructorError

def extractFile(self, filepath: str) -> Any:
if filepath.startswith('/'):
if os.path.isabs(filepath):
actual_path = filepath
else:
actual_path = os.path.join(self._current_dir, filepath)
Expand Down