Skip to content

Commit

Permalink
Changed more functions to only get aux data class
Browse files Browse the repository at this point in the history
changed functions create_assist_ephemeris and furnish_spiceypy to only get the aux data class. Also added comment in bootstrap.py on how to download new files
  • Loading branch information
Little-Ryugu committed Dec 13, 2024
1 parent c1d880d commit 914398b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/sorcha/ephemeris/simulation_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ def create_ephemeris(orbits_df, pointings_df, args, sconfigs):
ephemeris_csv_filename = os.path.join(args.outpath, args.output_ephemeris_file)

verboselog("Building ASSIST ephemeris object.")
ephem, gm_sun, gm_total = create_assist_ephemeris(args, sconfigs)
ephem, gm_sun, gm_total = create_assist_ephemeris(args, sconfigs.auxiliary)
verboselog("Furnishing SPICE kernels.")
furnish_spiceypy(args, sconfigs)
furnish_spiceypy(args, sconfigs.auxiliary)
verboselog("Generating ASSIST+REBOUND simulations.")
sim_dict = generate_simulations(ephem, gm_sun, gm_total, orbits_df, args)
pixel_dict = defaultdict(list)
Expand Down
32 changes: 16 additions & 16 deletions src/sorcha/ephemeris/simulation_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
from sorcha.utilities.generate_meta_kernel import build_meta_kernel_file


def create_assist_ephemeris(args, sconfigs) -> tuple:
def create_assist_ephemeris(args, auxconfigs) -> tuple:
"""Build the ASSIST ephemeris object
Parameter
---------
sconfigs: dataclass
Dataclass of configuration file arguments.
auxconfigs: dataclass
Dataclass of auxiliary configuration file arguments.
Returns
---------
Ephem : ASSIST ephemeris obejct
Expand All @@ -43,9 +43,9 @@ def create_assist_ephemeris(args, sconfigs) -> tuple:
"""
pplogger = logging.getLogger(__name__)

retriever = make_retriever(sconfigs.auxiliary, args.ar_data_file_path)
planets_file_path = retriever.fetch(sconfigs.auxiliary.jpl_planets)
small_bodies_file_path = retriever.fetch(sconfigs.auxiliary.jpl_small_bodies)
retriever = make_retriever(auxconfigs, args.ar_data_file_path)
planets_file_path = retriever.fetch(auxconfigs.jpl_planets)
small_bodies_file_path = retriever.fetch(auxconfigs.jpl_small_bodies)
ephem = Ephem(planets_path=planets_file_path, asteroids_path=small_bodies_file_path)
gm_sun = ephem.get_particle("Sun", 0).m
gm_total = sum(sorted([ephem.get_particle(i, 0).m for i in range(27)]))
Expand All @@ -56,31 +56,31 @@ def create_assist_ephemeris(args, sconfigs) -> tuple:
return ephem, gm_sun, gm_total


def furnish_spiceypy(args, sconfigs):
def furnish_spiceypy(args, auxconfigs):
"""
Builds the SPICE kernel, downloading the required files if needed
Parameters
-----------
sconfigs: dataclass
Dataclass of configuration file arguments.
auxconfigs: dataclass
Dataclass of auxiliary configuration file arguments.
"""
# The goal here would be to download the spice kernel files (if needed)
# Then call spice.furnish(<filename>) on each of those files.

pplogger = logging.getLogger(__name__)

retriever = make_retriever(sconfigs.auxiliary, args.ar_data_file_path)
retriever = make_retriever(auxconfigs, args.ar_data_file_path)

for kernel_file in sconfigs.auxiliary.ordered_kernel_files:
for kernel_file in auxconfigs.ordered_kernel_files:
retriever.fetch(kernel_file)

# check if the META_KERNEL file exists. If it doesn't exist, create it.
if not os.path.exists(os.path.join(retriever.abspath, sconfigs.auxiliary.meta_kernel)):
build_meta_kernel_file(sconfigs.auxiliary, retriever)
if not os.path.exists(os.path.join(retriever.abspath, auxconfigs.meta_kernel)):
build_meta_kernel_file(auxconfigs, retriever)

# try to get the META_KERNEL file. If it's not there, error out.
try:
meta_kernel = retriever.fetch(sconfigs.auxiliary.meta_kernel)
meta_kernel = retriever.fetch(auxconfigs.meta_kernel)
except ValueError:
pplogger.error(
"ERROR: furnish_spiceypy: Must create meta_kernel.txt by running `bootstrap_sorcha_data_files` on the command line."
Expand Down Expand Up @@ -182,9 +182,9 @@ def precompute_pointing_information(pointings_df, args, sconfigs):
pointings_df : pandas dataframe
The original dataframe with several additional columns of precomputed values.
"""
ephem, _, _ = create_assist_ephemeris(args, sconfigs)
ephem, _, _ = create_assist_ephemeris(args, sconfigs.auxiliary)

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

Expand Down
3 changes: 2 additions & 1 deletion src/sorcha_cmdline/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def execute(args):
import concurrent.futures
from sorcha.utilities.sorchaConfigs import auxiliaryConfigs

# default file names and urls (stored in auxiliaryConfigs)
# Bootstrap will always take the default filenames and urls (stored in auxiliaryConfigs) for the current version of sorcha.
# A user can download new files by running sorcha and specifying in the config file under the section [AUXILIARY] a new filename and url.

default_files = auxiliaryConfigs()
# create the Pooch retriever that tracks and retrieves the requested files
Expand Down
4 changes: 2 additions & 2 deletions tests/ephemeris/test_pixdict.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def test_pixeldict(tmp_path):
filterpointing = precompute_pointing_information(filterpointing, args, configs)
args = sorchaArguments(cmd_args_dict)

ephem, gm_sun, gm_total = create_assist_ephemeris(args,configs)
furnish_spiceypy(args,configs)
ephem, gm_sun, gm_total = create_assist_ephemeris(args,configs.auxiliary)
furnish_spiceypy(args,configs.auxiliary)

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

0 comments on commit 914398b

Please sign in to comment.