Commit 7b3d3593ab95fb0a5896bff621a9adc4f68e38b1

Authored by hitier
1 parent 10389e8d
Exists in rhitier-dev

Move inputs configs to inputs: section

Showing 4 changed files with 133 additions and 60 deletions   Show diff stats
.gitignore
... ... @@ -21,3 +21,4 @@ venv/*
21 21 # App
22 22 VISITS
23 23 .ipynb_checkpoints/
  24 +config.yml
... ...
config.yml-dist
... ... @@ -102,52 +102,12 @@ layers:
102 102  
103 103  
104 104 inputs:
  105 +
105 106 - slug: "om"
  107 + type: "input"
106 108 name: "OMNI"
107   - desc: "The default input."
108   - - slug: "art"
109   - name: "ACE-RT"
110   - desc: "ACE Real ime"
111   - - slug: "dsc"
112   - name: "DISCOVER"
113   - desc: "DISCOVER"
114   - - slug: "solo"
115   - name: "SOLAR-O"
116   - desc: "Solar Orbiter"
117   - - slug: "sa"
118   - name: "STEREO-A"
119   - desc: "The first of the STEREO (Solar Terrestrial Relations Observatory), a solar observation mission."
120   - - slug: "sb"
121   - name: "STEREO-B"
122   - desc: "The second of the STEREO (Solar Terrestrial Relations Observatory), a solar observation mission."
123   -
124   -#Comets
125   -#67P p67_orb_all
126   -#
127   -#Probes
128   -#Maven maven_orb_cruise
129   -#Juno juno_cruise_all
130   -#Exomars exomars_cruise_all
131   -#Rosetta ros_orb_cruise
132   -
133   -# To add a new target, you must :
134   -# 1. Configure it here
135   -# 2. Create the two related images in `web/static/img/target/`
136   -#
137   -# `slug` is used internally, and should match \[a-z0-9]+\ (NO dashes /!\)
138   -# `name` is displayed in the time series (should be short)
139   -# `title` appears on mouse hover, and can be longer
140   -# `locked` is for sources that are "coming soon"
141   -# `default` sources are shown to incoming visitors, others need user activation
142   -# `orbit` holds the orbit configuration data
143   -# `models` holds the configuration data for each model
144   -# the slugs are ids for AMDA
145   -targets:
146   -
147   - - type: 'input'
148   - slug: 'om'
149   - name: 'OMNI'
150 109 title: 'Omni'
  110 + desc: "The default input."
151 111 orbit:
152 112 models:
153 113 - slug: 'mercury-orb-all'
... ... @@ -165,11 +125,11 @@ targets:
165 125 #atse: ''
166 126 locked: false
167 127 default: false
168   -
169   - - type: 'input'
170   - slug: 'art'
171   - name: 'ACE REAL TIME'
  128 + - slug: "art"
  129 + type: "input"
  130 + name: "ACE-RT"
172 131 title: 'Ace RT'
  132 + desc: "ACE Real ime"
173 133 orbit:
174 134 models:
175 135 - slug: 'mercury-orb-all'
... ... @@ -188,11 +148,11 @@ targets:
188 148 #atse: ''
189 149 locked: false
190 150 default: false
191   -
192   - - type: 'input'
193   - slug: 'dsc'
194   - name: 'DISCOVER'
  151 + - slug: "dsc"
  152 + type: "input"
  153 + name: "DISCOVER"
195 154 title: 'Discover'
  155 + desc: "DISCOVER"
196 156 orbit:
197 157 models:
198 158 - slug: 'mercury-orb-all'
... ... @@ -214,7 +174,107 @@ targets:
214 174 #atse: 'mercury_sw_da'
215 175 locked: false
216 176 default: false
  177 + - slug: "solo"
  178 + type: "input"
  179 + name: "SOLAR-O"
  180 + title: 'Solar Orbiter'
  181 + desc: "Solar Orbiter"
  182 + orbit:
  183 + models:
  184 + - slug: 'so-orb-all'
  185 + parameters:
  186 + xy_hee: 'so_xyz_hee'
  187 + models:
  188 + solo:
  189 + - slug: 'so-pas-momgr1'
  190 + parameters:
  191 + dens: 'pas_momgr_n'
  192 + vtot: 'pas_momgr_v_tot'
  193 + temp: 'pas_momgr_tav'
  194 + #pdyn: 'dsc_pdyn'
  195 + - slug: 'so-mag-1min'
  196 + parameters:
  197 + xy_b: 'solo_b_rtn'
  198 + #btan: 'mercury_sw_b'
  199 + #brad: 'mercury_sw_bx'
  200 + #atse: 'mercury_sw_da'
  201 + locked: false
  202 + default: false
  203 + - slug: "sa"
  204 + type: "input"
  205 + name: "STEREO-A"
  206 + title: 'STEREO-A'
  207 + desc: "The first of the STEREO (Solar Terrestrial Relations Observatory), a solar observation mission."
  208 + orbit:
  209 + models:
  210 + - slug: 'sta-l2-orb'
  211 + parameters:
  212 + xy_hee: 'sta_xyz_hee'
  213 + models:
  214 + sa:
  215 + - slug: 'sta-l2-pla'
  216 + parameters:
  217 + dens: 'np_sta'
  218 + vtot: 'vpbulk_sta'
  219 + #temp: ''
  220 + #pdyn: ''
  221 + - slug: 'sta-b-1min'
  222 + parameters:
  223 + xy_b: 'sta_b_rtn'
  224 + #btan: 'mercury_sw_b'
  225 + #brad: 'mercury_sw_bx'
  226 + #atse: 'mercury_sw_da'
  227 + locked: false
  228 + default: false
  229 + - slug: "sb"
  230 + type: "input"
  231 + name: "STEREO-B"
  232 + title: 'STEREO-B'
  233 + desc: "The second of the STEREO (Solar Terrestrial Relations Observatory), a solar observation mission."
  234 + orbit:
  235 + models:
  236 + - slug: 'stb-l2-orb'
  237 + parameters:
  238 + xy_hee: 'stb_xyz_hee'
  239 + models:
  240 + sb:
  241 + - slug: 'stb-l2-pla'
  242 + parameters:
  243 + dens: 'np_stb'
  244 + vtot: 'vpbulk_stb'
  245 + #temp: ''
  246 + #pdyn: ''
  247 + - slug: 'stb-b-1min'
  248 + parameters:
  249 + xy_b: 'stb_b_rtn'
  250 + #btan: ''
  251 + #brad: ''
  252 + #atse: ''
  253 + locked: false
  254 + default: false
217 255  
  256 +#Comets
  257 +#67P p67_orb_all
  258 +#
  259 +#Probes
  260 +#Maven maven_orb_cruise
  261 +#Juno juno_cruise_all
  262 +#Exomars exomars_cruise_all
  263 +#Rosetta ros_orb_cruise
  264 +
  265 +# To add a new target, you must :
  266 +# 1. Configure it here
  267 +# 2. Create the two related images in `web/static/img/target/`
  268 +#
  269 +# `slug` is used internally, and should match \[a-z0-9]+\ (NO dashes /!\)
  270 +# `name` is displayed in the time series (should be short)
  271 +# `title` appears on mouse hover, and can be longer
  272 +# `locked` is for sources that are "coming soon"
  273 +# `default` sources are shown to incoming visitors, others need user activation
  274 +# `orbit` holds the orbit configuration data
  275 +# `models` holds the configuration data for each model
  276 +# the slugs are ids for AMDA
  277 +targets:
218 278  
219 279 - type: 'planet'
220 280 slug: 'mercury'
... ...
web/hp_cmd.py
... ... @@ -5,16 +5,17 @@ from datetime import datetime
5 5 import argparse
6 6  
7 7 if __name__ == "__main__":
8   - hp_parser = argparse.ArgumentParser(prog='Descritpor',
9   - description='description')
  8 + hp_parser = argparse.ArgumentParser(prog='Heliopropa Command tool')
10 9  
11 10 hp_parser.add_argument('-clog', '--console-log', action='store_true')
12 11 hp_parser.add_argument('-s', '--dry-run', action='store_true')
13 12  
14 13 subparsers = hp_parser.add_subparsers(dest='hpcmd_name')
15 14  
  15 + csvgen_parser = subparsers.add_parser('show_config',
  16 + help='Show configuration targets and inputs')
16 17 csvgen_parser = subparsers.add_parser('csv_gen',
17   - help='csv-gen help')
  18 + help='Generate CSV for given target/input (can be input/input)')
18 19 csvgen_parser.add_argument('-a', '--all', action='store_true')
19 20 csvgen_parser.add_argument('-t', '--target')
20 21 csvgen_parser.add_argument('-i', '--input')
... ... @@ -26,18 +27,27 @@ if __name__ == "__main__":
26 27 if args.console_log:
27 28 _logger = init_console_logger()
28 29  
29   - if args.hpcmd_name == 'csv_gen':
  30 + if args.hpcmd_name == 'show_config':
  31 + for meteor in config['targets'] + config['inputs']:
  32 + meteor_type = meteor['type']
  33 + meteor_name = f"'{meteor['name']}'"
  34 + meteor_slug = meteor['slug']
  35 + meteor_models = ', '.join(list(meteor['models'].keys()))
  36 + print(f"{meteor_type:6} {meteor_slug:6} {meteor_name:11}: models = {meteor_models}")
  37 + elif args.hpcmd_name == 'csv_gen':
30 38 # build default dates in not -b or not -e
31   - sta, sto = get_default_sta_sto( args.begin, args.end)
  39 + sta, sto = get_default_sta_sto(args.begin, args.end)
  40 +
  41 + meteors_list = config['targets'] + config['inputs']
32 42  
33 43 if args.all:
34 44 # build the {target_slug: [input list]} dictionnary from config.yaml
35   - targets = {t['slug']: list(t['models'].keys()) for t in config['targets']}
  45 + meteors_dict = {t['slug']: list(t['models'].keys()) for t in meteors_list}
36 46 else:
37 47 # todo: check -i an -t
38   - targets = {args.target: [args.input]}
  48 + meteors_dict = {args.target: [args.input]}
39 49  
40   - for _t, _i_list in targets.items():
  50 + for _t, _i_list in meteors_dict.items():
41 51 # print(_t, _i_list)
42 52 for _i in _i_list:
43 53 print(f"generating csv for {_t}/ {_i}")
... ...
web/run.py
... ... @@ -420,7 +420,7 @@ def get_local_filename(url):
420 420  
421 421  
422 422 def get_target_config(slug):
423   - for s in config['targets']: # dumb
  423 + for s in config['targets'] + config['inputs']: # dumb
424 424 if s['slug'] == slug:
425 425 return s
426 426 raise Exception("No target found in configuration for '%s'." % slug)
... ... @@ -1297,6 +1297,8 @@ def home():
1297 1297 parameters = sorted(parameters, key=lambda x: x['position'])
1298 1298 input_slug = get_input_slug_from_query()
1299 1299 targets = [t for t in config['targets'] if not t['locked']]
  1300 + # now add the input_slug configuration as a target to be plotted
  1301 + targets = [get_target_config(input_slug)] + targets
1300 1302 started_at, stopped_at = get_interval_from_query(request)
1301 1303 for i, target in enumerate(targets):
1302 1304 targets[i]['catalog_layers'] = get_catalog_layers(
... ...