From 7b3d3593ab95fb0a5896bff621a9adc4f68e38b1 Mon Sep 17 00:00:00 2001 From: Richard Hitier Date: Fri, 3 Nov 2023 11:20:03 +0100 Subject: [PATCH] Move inputs configs to inputs: section --- .gitignore | 1 + config.yml-dist | 162 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------- web/hp_cmd.py | 26 ++++++++++++++++++-------- web/run.py | 4 +++- 4 files changed, 133 insertions(+), 60 deletions(-) diff --git a/.gitignore b/.gitignore index 96826dc..fc3a8fe 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ venv/* # App VISITS .ipynb_checkpoints/ +config.yml diff --git a/config.yml-dist b/config.yml-dist index 35edf2d..00968dd 100644 --- a/config.yml-dist +++ b/config.yml-dist @@ -102,52 +102,12 @@ layers: inputs: + - slug: "om" + type: "input" name: "OMNI" - desc: "The default input." - - slug: "art" - name: "ACE-RT" - desc: "ACE Real ime" - - slug: "dsc" - name: "DISCOVER" - desc: "DISCOVER" - - slug: "solo" - name: "SOLAR-O" - desc: "Solar Orbiter" - - slug: "sa" - name: "STEREO-A" - desc: "The first of the STEREO (Solar Terrestrial Relations Observatory), a solar observation mission." - - slug: "sb" - name: "STEREO-B" - desc: "The second of the STEREO (Solar Terrestrial Relations Observatory), a solar observation mission." - -#Comets -#67P p67_orb_all -# -#Probes -#Maven maven_orb_cruise -#Juno juno_cruise_all -#Exomars exomars_cruise_all -#Rosetta ros_orb_cruise - -# To add a new target, you must : -# 1. Configure it here -# 2. Create the two related images in `web/static/img/target/` -# -# `slug` is used internally, and should match \[a-z0-9]+\ (NO dashes /!\) -# `name` is displayed in the time series (should be short) -# `title` appears on mouse hover, and can be longer -# `locked` is for sources that are "coming soon" -# `default` sources are shown to incoming visitors, others need user activation -# `orbit` holds the orbit configuration data -# `models` holds the configuration data for each model -# the slugs are ids for AMDA -targets: - - - type: 'input' - slug: 'om' - name: 'OMNI' title: 'Omni' + desc: "The default input." orbit: models: - slug: 'mercury-orb-all' @@ -165,11 +125,11 @@ targets: #atse: '' locked: false default: false - - - type: 'input' - slug: 'art' - name: 'ACE REAL TIME' + - slug: "art" + type: "input" + name: "ACE-RT" title: 'Ace RT' + desc: "ACE Real ime" orbit: models: - slug: 'mercury-orb-all' @@ -188,11 +148,11 @@ targets: #atse: '' locked: false default: false - - - type: 'input' - slug: 'dsc' - name: 'DISCOVER' + - slug: "dsc" + type: "input" + name: "DISCOVER" title: 'Discover' + desc: "DISCOVER" orbit: models: - slug: 'mercury-orb-all' @@ -214,7 +174,107 @@ targets: #atse: 'mercury_sw_da' locked: false default: false + - slug: "solo" + type: "input" + name: "SOLAR-O" + title: 'Solar Orbiter' + desc: "Solar Orbiter" + orbit: + models: + - slug: 'so-orb-all' + parameters: + xy_hee: 'so_xyz_hee' + models: + solo: + - slug: 'so-pas-momgr1' + parameters: + dens: 'pas_momgr_n' + vtot: 'pas_momgr_v_tot' + temp: 'pas_momgr_tav' + #pdyn: 'dsc_pdyn' + - slug: 'so-mag-1min' + parameters: + xy_b: 'solo_b_rtn' + #btan: 'mercury_sw_b' + #brad: 'mercury_sw_bx' + #atse: 'mercury_sw_da' + locked: false + default: false + - slug: "sa" + type: "input" + name: "STEREO-A" + title: 'STEREO-A' + desc: "The first of the STEREO (Solar Terrestrial Relations Observatory), a solar observation mission." + orbit: + models: + - slug: 'sta-l2-orb' + parameters: + xy_hee: 'sta_xyz_hee' + models: + sa: + - slug: 'sta-l2-pla' + parameters: + dens: 'np_sta' + vtot: 'vpbulk_sta' + #temp: '' + #pdyn: '' + - slug: 'sta-b-1min' + parameters: + xy_b: 'sta_b_rtn' + #btan: 'mercury_sw_b' + #brad: 'mercury_sw_bx' + #atse: 'mercury_sw_da' + locked: false + default: false + - slug: "sb" + type: "input" + name: "STEREO-B" + title: 'STEREO-B' + desc: "The second of the STEREO (Solar Terrestrial Relations Observatory), a solar observation mission." + orbit: + models: + - slug: 'stb-l2-orb' + parameters: + xy_hee: 'stb_xyz_hee' + models: + sb: + - slug: 'stb-l2-pla' + parameters: + dens: 'np_stb' + vtot: 'vpbulk_stb' + #temp: '' + #pdyn: '' + - slug: 'stb-b-1min' + parameters: + xy_b: 'stb_b_rtn' + #btan: '' + #brad: '' + #atse: '' + locked: false + default: false +#Comets +#67P p67_orb_all +# +#Probes +#Maven maven_orb_cruise +#Juno juno_cruise_all +#Exomars exomars_cruise_all +#Rosetta ros_orb_cruise + +# To add a new target, you must : +# 1. Configure it here +# 2. Create the two related images in `web/static/img/target/` +# +# `slug` is used internally, and should match \[a-z0-9]+\ (NO dashes /!\) +# `name` is displayed in the time series (should be short) +# `title` appears on mouse hover, and can be longer +# `locked` is for sources that are "coming soon" +# `default` sources are shown to incoming visitors, others need user activation +# `orbit` holds the orbit configuration data +# `models` holds the configuration data for each model +# the slugs are ids for AMDA +targets: - type: 'planet' slug: 'mercury' diff --git a/web/hp_cmd.py b/web/hp_cmd.py index 88ce106..4612aaf 100644 --- a/web/hp_cmd.py +++ b/web/hp_cmd.py @@ -5,16 +5,17 @@ from datetime import datetime import argparse if __name__ == "__main__": - hp_parser = argparse.ArgumentParser(prog='Descritpor', - description='description') + hp_parser = argparse.ArgumentParser(prog='Heliopropa Command tool') hp_parser.add_argument('-clog', '--console-log', action='store_true') hp_parser.add_argument('-s', '--dry-run', action='store_true') subparsers = hp_parser.add_subparsers(dest='hpcmd_name') + csvgen_parser = subparsers.add_parser('show_config', + help='Show configuration targets and inputs') csvgen_parser = subparsers.add_parser('csv_gen', - help='csv-gen help') + help='Generate CSV for given target/input (can be input/input)') csvgen_parser.add_argument('-a', '--all', action='store_true') csvgen_parser.add_argument('-t', '--target') csvgen_parser.add_argument('-i', '--input') @@ -26,18 +27,27 @@ if __name__ == "__main__": if args.console_log: _logger = init_console_logger() - if args.hpcmd_name == 'csv_gen': + if args.hpcmd_name == 'show_config': + for meteor in config['targets'] + config['inputs']: + meteor_type = meteor['type'] + meteor_name = f"'{meteor['name']}'" + meteor_slug = meteor['slug'] + meteor_models = ', '.join(list(meteor['models'].keys())) + print(f"{meteor_type:6} {meteor_slug:6} {meteor_name:11}: models = {meteor_models}") + elif args.hpcmd_name == 'csv_gen': # build default dates in not -b or not -e - sta, sto = get_default_sta_sto( args.begin, args.end) + sta, sto = get_default_sta_sto(args.begin, args.end) + + meteors_list = config['targets'] + config['inputs'] if args.all: # build the {target_slug: [input list]} dictionnary from config.yaml - targets = {t['slug']: list(t['models'].keys()) for t in config['targets']} + meteors_dict = {t['slug']: list(t['models'].keys()) for t in meteors_list} else: # todo: check -i an -t - targets = {args.target: [args.input]} + meteors_dict = {args.target: [args.input]} - for _t, _i_list in targets.items(): + for _t, _i_list in meteors_dict.items(): # print(_t, _i_list) for _i in _i_list: print(f"generating csv for {_t}/ {_i}") diff --git a/web/run.py b/web/run.py index a26e78b..fc1dd0f 100755 --- a/web/run.py +++ b/web/run.py @@ -420,7 +420,7 @@ def get_local_filename(url): def get_target_config(slug): - for s in config['targets']: # dumb + for s in config['targets'] + config['inputs']: # dumb if s['slug'] == slug: return s raise Exception("No target found in configuration for '%s'." % slug) @@ -1297,6 +1297,8 @@ def home(): parameters = sorted(parameters, key=lambda x: x['position']) input_slug = get_input_slug_from_query() targets = [t for t in config['targets'] if not t['locked']] + # now add the input_slug configuration as a target to be plotted + targets = [get_target_config(input_slug)] + targets started_at, stopped_at = get_interval_from_query(request) for i, target in enumerate(targets): targets[i]['catalog_layers'] = get_catalog_layers( -- libgit2 0.21.2