Skip to content

Commit

Permalink
Changed Observatory class to only get aux data class
Browse files Browse the repository at this point in the history
  • Loading branch information
Little-Ryugu committed Dec 13, 2024
1 parent 331b122 commit c1d880d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/sorcha/ephemeris/simulation_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def create_ephemeris(orbits_df, pointings_df, args, sconfigs):
verboselog("Generating ASSIST+REBOUND simulations.")
sim_dict = generate_simulations(ephem, gm_sun, gm_total, orbits_df, args)
pixel_dict = defaultdict(list)
observatories = Observatory(args, sconfigs)
observatories = Observatory(args, sconfigs.auxiliary)

output = StringIO()
in_memory_csv = writer(output)
Expand Down
14 changes: 7 additions & 7 deletions src/sorcha/ephemeris/simulation_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,33 +129,33 @@ class Observatory:
Class containing various utility tools related to the calculation of the observatory position
"""

def __init__(self, args, sconfigs, oc_file=None):
def __init__(self, args, auxconfigs, oc_file=None):
"""
Initialization method
Parameters
----------
args : dictionary or `sorchaArguments` object
dictionary of command-line arguments.
sconfigs: dataclass
auxconfigs: dataclass
Dataclass of configuration file arguments.
oc_file : str
Path for the file with observatory codes
"""
self.observatoryPositionCache = {} # previously calculated positions to speed up the process

if oc_file == None:
retriever = make_retriever(sconfigs.auxiliary, args.ar_data_file_path)
retriever = make_retriever(auxconfigs, args.ar_data_file_path)

# is the file available locally, if so, return the full path
if os.path.isfile(os.path.join(retriever.abspath, sconfigs.auxiliary.observatory_codes)):
obs_file_path = retriever.fetch(sconfigs.auxiliary.observatory_codes)
if os.path.isfile(os.path.join(retriever.abspath, auxconfigs.observatory_codes)):
obs_file_path = retriever.fetch(auxconfigs.observatory_codes)

# if the file is not local, download, and decompress it, then return the path.
else:
obs_file_path = retriever.fetch(
sconfigs.auxiliary.observatory_codes_compressed,
processor=Decompress(name=sconfigs.auxiliary.observatory_codes),
auxconfigs.observatory_codes_compressed,
processor=Decompress(name=auxconfigs.observatory_codes),
)

else:
Expand Down
2 changes: 1 addition & 1 deletion src/sorcha/ephemeris/simulation_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def precompute_pointing_information(pointings_df, args, sconfigs):

furnish_spiceypy(args, sconfigs)
obsCode = sconfigs.simulation.ar_obs_code
observatories = Observatory(args, sconfigs)
observatories = Observatory(args, sconfigs.auxiliary)

# vectorize the calculation to get x,y,z vector from ra/dec
vectors = ra_dec2vec(
Expand Down
2 changes: 1 addition & 1 deletion tests/ephemeris/test_pixdict.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_pixeldict(tmp_path):
furnish_spiceypy(args,configs)

sim_dict = generate_simulations(ephem, gm_sun, gm_total, orbits_df, args)
observatory = Observatory(sconfigs=configs,args=None, oc_file=get_test_filepath("ObsCodes_test.json"))
observatory = Observatory(auxconfigs=configs.auxiliary,args=None, oc_file=get_test_filepath("ObsCodes_test.json"))

pixdict = PixelDict(54800.0 + 2400000.5, sim_dict, ephem, "Z20", observatory, picket_interval=1, nside=32)

Expand Down
10 changes: 4 additions & 6 deletions tests/ephemeris/test_simulation_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
from sorcha.utilities.sorchaConfigs import sorchaConfigs, auxiliaryConfigs

def test_observatory_compared_to_original():
sconfigs = sorchaConfigs()
sconfigs.auxiliary = auxiliaryConfigs()
observatory = sp.Observatory(sconfigs=sconfigs,args=None, oc_file=get_test_filepath("ObsCodes_test.json"))
auxconfigs = auxiliaryConfigs()
observatory = sp.Observatory(auxconfigs=auxconfigs,args=None, oc_file=get_test_filepath("ObsCodes_test.json"))
obs = observatory.ObservatoryXYZ

# Reference tuples were taken from Matt Holman's original notebook
Expand All @@ -19,9 +18,8 @@ def test_observatory_compared_to_original():


def test_observatory_for_moving_observatories():
sconfigs = sorchaConfigs()
sconfigs.auxiliary = auxiliaryConfigs()
observatory = sp.Observatory(sconfigs=sconfigs,args=None, oc_file=get_test_filepath("ObsCodes_test.json"))
auxconfigs = auxiliaryConfigs()
observatory = sp.Observatory(auxconfigs=auxconfigs,args=None, oc_file=get_test_filepath("ObsCodes_test.json"))
obs = observatory.ObservatoryXYZ

assert obs["250"] == (None, None, None)

0 comments on commit c1d880d

Please sign in to comment.