= Config(config_path="test_config.toml") config
Config
planetarypy
package.
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 |
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.
assert config.storage_root == Path.home() / "planetarypy_data"
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.) |
"mro.hirise") config.list_indexes(
['dtm', 'edr', 'rdr']
= "missions.cassini.iss.indexes.moon_summary" index
'url'] config.get_value(index)[
'https://pds-rings.seti.org/holdings/metadata/COISS_2xxx/COISS_2999/COISS_2999_moon_summary.lbl'
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 |
Config.save
Config.save ()
Write the TOML doc to file.
'url'] config.get_value(index)[
'https://pds-rings.seti.org/holdings/metadata/COISS_2xxx/COISS_2999/COISS_2999_moon_summary.lbl'
"mro.ctx.datalevels")['edr']['url'] config.get_value(
'https://pds-imaging.jpl.nasa.gov/data/mro/mars_reconnaissance_orbiter/ctx'
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'
"cassini") config.list_instruments(
['iss', 'uvis']
"cassini.iss") config.list_indexes(
['index', 'inventory', 'moon_summary', 'ring_summary', 'saturn_summary']
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 |
"mro.hirise") config.get_datalevels(
['dtm', 'edr', 'rdr']
from nbdev import nbdev_export
nbdev_export()