Skip to content

Conversation

@chkim-usgs
Copy link
Contributor

@chkim-usgs chkim-usgs commented Aug 29, 2025

Couple things

  • Adds kernels key to ISD
  • Adds remove_kernels key option to for the props dict in ale.loads()
  • Adds misc key if user enters their own kernels
  • Converts kernels json value to dict type if it is initially a list

Licensing

This project is mostly composed of free and unencumbered software released into the public domain, and we are unlikely to accept contributions that are not also released into the public domain. Somewhere near the top of each file should have these words:

This work is free and unencumbered software released into the public domain. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain.

  • I dedicate any and all copyright interest in this software to the public domain. I make this dedication for the benefit of the public at large and to the detriment of my heirs and successors. I intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

jrcain-usgs
jrcain-usgs previously approved these changes Sep 10, 2025
@chkim-usgs chkim-usgs requested a review from Kelvinrr September 11, 2025 12:27
Comment on lines 91 to 92
else:
self._kernels = self._props['kernels']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be worth checking if it's a dict formatted like a spiceQL kernel set.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you envisioning something that checks the kernel keys against valid kernel type names (like [ck, pck, spk, etc.])?

Copy link
Collaborator

@Kelvinrr Kelvinrr Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, basically. The easiest thing is probably to try to load it as a kernel set? Might need a function in SpiceQL to check.

res.instrument_id
with res as driver:
isd = formatter(driver)
if 'remove_kernels' in props and props['remove_kernels'] is True and 'kernels' in isd:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be better for it to be "attach_kernels", having a flag being a often a bit odd.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want to confirm, we want kernels added to ISD as default? We can have attach_kernels be default True and users can explicitly set it to False is they want kernels removed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, change to attach_kernels and default to true.

# else:
# isd["kernels"] = {}
if 'kernels' in driver_data and isinstance(driver.kernels, dict):
isd["kernels"] = {k: v for k, v in driver.kernels.items() if not "_quality" in k and not driver.spiceql_mission in k }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to keep the quality keys. Otherwise how would they know the quality of the CKs/SPKs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the quality omission was in the original logic but I can add them back.

Comment on lines +213 to +220
kernels_dict = {}
for k in driver.kernels:
k_split = k.split('/')
k_type = k_split[2]
if k_type in kernels_dict and isinstance(kernels_dict[k_type], list):
kernels_dict[k_type].append(k)
else:
kernels_dict.update({k_type: [k]})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am guessing this is to try to identify the kernel types? Might be best to make that a function in SpiceQL, since SpiceQL can use the Config to identify them more effectively. Short term I think it's fine to leave this here.

Comment on lines 34 to 42
def test_load_kernels(test_kernels):
label_file = get_image_label('AS15-M-1450', 'isis3')
compare_dict = get_isd("apollometric")
isd_str = ale.loads(label_file, props={'kernels': test_kernels}, verbose=True)
isd_obj = json.loads(isd_str)
print(json.dumps(isd_obj, indent=2))
print("======================")
print(json.dumps(compare_dict, indent=2))
assert isd_obj['kernels']['misc']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With how much new logic you added, you should also test the dict case. Also, if a list is formatted as expected if you are trying to identify kernel types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants