Skip to content

Commit

Permalink
allow gaia data_dir to be absolute path
Browse files Browse the repository at this point in the history
  • Loading branch information
JoanneBogart committed May 11, 2024
1 parent 87a11c7 commit 67d63b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
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

0 comments on commit 67d63b1

Please sign in to comment.