Skip to content

Commit

Permalink
Update main for target source from coords
Browse files Browse the repository at this point in the history
  • Loading branch information
HealthyPear committed Dec 16, 2024
1 parent 8dab0fc commit 6db3a24
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions src/iact_estimator/scripts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import shutil

from astroplan import FixedTarget, Observer
from astropy.coordinates.name_resolve import NameResolveError
from astropy.time import Time
import astropy.units as u
from astropy.visualization import quantity_support
Expand All @@ -15,6 +16,7 @@
from ..io import read_yaml
from ..core import (
setup_logging,
load_target_source_coordinates,
initialize_model,
check_input_configuration,
prepare_data,
Expand Down Expand Up @@ -97,7 +99,15 @@ def main():
output_path = (
Path(args.output_path) if args.output_path is not None else Path.cwd()
)
source_name = args.source_name

logging.info("Loading configuration file")
config = read_yaml(args.config)

source_name = (
config["target_source"]["name"]
if config["target_source"]["name"]
else "test_source"
)

previous_output = len(
[file for file in output_path.rglob(f"**/{source_name}*")]
Expand All @@ -109,9 +119,6 @@ def main():

logger = setup_logging(args.log_level, source_name)

logger.info("Loading configuration file")
config = read_yaml(args.config)

logging.info("Validating input configuration")
if not check_input_configuration(config):
logging.critical(
Expand Down Expand Up @@ -175,7 +182,17 @@ def main():

logger.info("All expected operations have been perfomed succesfully.")

target_source = FixedTarget.from_name(source_name)
if source_name:
try:
target_source = FixedTarget.from_name(source_name)
except NameResolveError:
target_source = load_target_source_coordinates(config)
elif (
source_name != "test_source"
and config["target_source"]["coordinates"]["force"]
):
target_source = load_target_source_coordinates(config)

observer = Observer.at_site("Roque de los Muchachos")
time = Time(config["observation_datetime"])

Expand Down

0 comments on commit 6db3a24

Please sign in to comment.