Config

This module manages configuration of the planetarypy package.

source

reset_non_urls

 reset_non_urls (source:dict, reset:str='')

*Reset all non-URL values in the config file.

This is useful for copying the private config file with new data items back into the source tree for a clean commit.*

Type Default Details
source dict source dictionary
reset str value to reset non URLs to
Returns dict

source

Config

 Config (config_path:str=None)

*Manage config stuff.

The key, value pairs found in the config file become attributes of the class instance after initialization. At minimum, there should be the storage_root attribute for storing data for this package.*

Type Default Details
config_path str None str or pathlib.Path

The Config() object

The config module instantiates a config object from the Config class. Its attributes can be used to access several aspects relevant to the configuration of planetarypy. Using an object approach enables easy growth and nesting over time.

config = Config(config_path="test_config.toml")
assert config.storage_root == Path.home() / "planetarypy_data"

source

Config.get_value

 Config.get_value (key:str)

Get sub-dictionary by nested key.

Type Details
key str A nested key in dotted format, e.g. cassini.uvis.indexes
Returns str Returning empty string if not existing, because Path(’’) is False which is handy (e.g. in ctx mod.)
config.list_indexes("mro.hirise")
['dtm', 'edr', 'rdr']
index = "missions.cassini.iss.indexes.moon_summary"
config.get_value(index)['url']
'https://pds-rings.seti.org/holdings/metadata/COISS_2xxx/COISS_2999/COISS_2999_moon_summary.lbl'

source

Config.set_value

 Config.set_value (nested_key:str, value:Union[float,str], save:bool=True)

Set value in sub-dic using dotted key.

Type Default Details
nested_key str A nested key in dotted format, e.g. cassini.uvis.ring_summary
value Union Value for the given key to be stored
save bool True Switch to control writing out to disk

source

Config.save

 Config.save ()

Write the TOML doc to file.

config.get_value(index)['url']
'https://pds-rings.seti.org/holdings/metadata/COISS_2xxx/COISS_2999/COISS_2999_moon_summary.lbl'
config.get_value("mro.ctx.datalevels")['edr']['url']
'https://pds-imaging.jpl.nasa.gov/data/mro/mars_reconnaissance_orbiter/ctx'

source

Config.ask_storage_root

 Config.ask_storage_root ()

*Use input() to ask user for the storage_root path.

The path will be stored in the TOML-dict and saved into existing config file at Class.path, either default or as given during init. storage_root attribute is set as well.*

config.missions
['cassini', 'mro', 'lro', 'go']
assert config.path.name == '.planetarypy_config.toml'
config.list_instruments("cassini")
['iss', 'uvis']
config.list_indexes("cassini.iss")
['index', 'inventory', 'moon_summary', 'ring_summary', 'saturn_summary']

source

Config.get_datalevels

 Config.get_datalevels (mission_instrument)

*Return configured data levels available for an instrument.

This currently simply points to the indexes, assuming that everything that has an index is also its own datalevel. In case it ever is not, we can add more here.*

Details
mission_instrument mission.instrument code, e.g. mro.hirise
config.get_datalevels("mro.hirise")
['dtm', 'edr', 'rdr']
from nbdev import nbdev_export

nbdev_export()