Commit 297a7dfcb69e43cf00a86b585bb78fea2032ab6a

Authored by Goutte
1 parent 034132c6

Add support for inputs STEREO-A, STEREO-B, L1 (needs testing)

1 ## Nicolas 1 ## Nicolas
2 2
3 - [ ] séries temporelles en échelle log ou linéaire 3 - [ ] séries temporelles en échelle log ou linéaire
  4 +- [ ] quant on zoome modifier l'échelle en Y afin qu'elle s'adapte aux valeurs maximales de l'intervalle du zoom
4 - [ ] permettre à l'utilisateur de choisir inner heliosphere (jusqu'à mars) ou outer heliosphere (jusqu'à saturne) pour la visualisation des éphémérides planétaires 5 - [ ] permettre à l'utilisateur de choisir inner heliosphere (jusqu'à mars) ou outer heliosphere (jusqu'à saturne) pour la visualisation des éphémérides planétaires
5 - [ ] rajouter uranus et neptune comme planètes cibles 6 - [ ] rajouter uranus et neptune comme planètes cibles
6 - [ ] rajouter MAVEN, New Horizons, Cassini, Galileo, ExoMars comme spacecraft cible 7 - [ ] rajouter MAVEN, New Horizons, Cassini, Galileo, ExoMars comme spacecraft cible
7 - [ ] prévoir la possibilité à l'utilisateur d'afficher le temps en Day Of Year 8 - [ ] prévoir la possibilité à l'utilisateur d'afficher le temps en Day Of Year
8 -- [ ] quant on zoome modifier l'échelle en Y afin qu'elle s'adapte aux valeurs maximales de l'intervalle du zoom  
9 - [ ] modifier le bandeau vertical d'affichage des choix utilisateurs pour qu'il soit plus petit (en particulier les champs paramètres) 9 - [ ] modifier le bandeau vertical d'affichage des choix utilisateurs pour qu'il soit plus petit (en particulier les champs paramètres)
10 -- [ ] ajouter dans le bandeau vertical un onglet INPUT DATA avec 3 choix possibles: STEREO-A, STEREO-B, L1  
11 - [ ] ajouter dans le bandeau vertical un onglet LAYERS avec 3 choix possibles: Jupiter Thermosphere Model, HST Jupiter Observations, HST Saturn Observations 10 - [ ] ajouter dans le bandeau vertical un onglet LAYERS avec 3 choix possibles: Jupiter Thermosphere Model, HST Jupiter Observations, HST Saturn Observations
12 - [ ] ajouter un bouton ALERT qui permet d'ouvrir une nouvelle page de formulaire ou l'utilisateur entrerait les données suivantes: 11 - [ ] ajouter un bouton ALERT qui permet d'ouvrir une nouvelle page de formulaire ou l'utilisateur entrerait les données suivantes:
13 * email 12 * email
@@ -32,6 +31,7 @@ @@ -32,6 +31,7 @@
32 31
33 - [ ] Rework the images of Rosetta and Juno 32 - [ ] Rework the images of Rosetta and Juno
34 - [ ] Enable p67 33 - [ ] Enable p67
  34 +- [x] Add support for inputs STEREO-A, STEREO-B, L1
35 - [x] More ticks along X-axis (I tried, but it does not behave as expected) 35 - [x] More ticks along X-axis (I tried, but it does not behave as expected)
36 - [x] Smaller footer credits 36 - [x] Smaller footer credits
37 - [x] Move the version to the footer 37 - [x] Move the version to the footer
@@ -46,6 +46,17 @@ authors: @@ -46,6 +46,17 @@ authors:
46 46
47 amda: "http://cdpp.irap.omp.eu/BASE/DDService/getDataUrl.php?dataSet={dataSet}&StartTime={startTime}&StopTime={stopTime}" 47 amda: "http://cdpp.irap.omp.eu/BASE/DDService/getDataUrl.php?dataSet={dataSet}&StartTime={startTime}&StopTime={stopTime}"
48 48
  49 +inputs:
  50 + - slug: "l1"
  51 + name: "L1"
  52 + desc: "The default input."
  53 + - slug: "sa"
  54 + name: "STEREO-A"
  55 + desc: "The first of the STEREO (Solar Terrestrial Relations Observatory), a solar observation mission."
  56 + - slug: "sb"
  57 + name: "STEREO-B"
  58 + desc: "The second of the STEREO (Solar Terrestrial Relations Observatory), a solar observation mission."
  59 +
49 #Targets 60 #Targets
50 #Earth earth_orb_all 61 #Earth earth_orb_all
51 #Jupiter jupiter_orb_all 62 #Jupiter jupiter_orb_all
@@ -75,12 +86,17 @@ targets: @@ -75,12 +86,17 @@ targets:
75 name: 'Mercury' 86 name: 'Mercury'
76 title: 'Mercury' 87 title: 'Mercury'
77 orbit: 88 orbit:
78 - models:  
79 - - slug: 'mercury_orb_all'  
80 - semimajor: 0  
81 - semiminor: 0 89 + models:
  90 + - slug: 'mercury_orb_all'
  91 + semimajor: 0
  92 + semiminor: 0
82 models: 93 models:
83 - - slug: 'tao_mercury_sw' 94 + l1:
  95 + - slug: 'tao_mercury_sw'
  96 + sa:
  97 + - slug: 'tao_mercury_sw'
  98 + sb:
  99 + - slug: 'tao_mercury_sw'
84 locked: false 100 locked: false
85 default: true 101 default: true
86 - type: 'planet' 102 - type: 'planet'
@@ -88,12 +104,17 @@ targets: @@ -88,12 +104,17 @@ targets:
88 name: 'Venus' 104 name: 'Venus'
89 title: 'Venus' 105 title: 'Venus'
90 orbit: 106 orbit:
91 - models:  
92 - - slug: 'venus_orb_all'  
93 - semimajor: 0.72333199  
94 - semiminor: 0.7233154 107 + models:
  108 + - slug: 'venus_orb_all'
  109 + semimajor: 0.72333199
  110 + semiminor: 0.7233154
95 models: 111 models:
96 - - slug: 'tao_venus_sw' 112 + l1:
  113 + - slug: 'tao_venus_sw'
  114 + sa:
  115 + - slug: 'tao_venus_sw'
  116 + sb:
  117 + - slug: 'tao_venus_sw'
97 locked: false 118 locked: false
98 default: true 119 default: true
99 - type: 'planet' 120 - type: 'planet'
@@ -101,42 +122,71 @@ targets: @@ -101,42 +122,71 @@ targets:
101 name: 'Earth' 122 name: 'Earth'
102 title: 'Earth' 123 title: 'Earth'
103 orbit: 124 orbit:
104 - models: [] # Earth has no orbit models, we hard-coded it to (1, 0) 125 + models: [] # Earth has no orbit models, we hard-coded it to (1, 0)
105 models: 126 models:
106 - - slug: 'omni_hour_all'  
107 - - slug: 'ace_swepam_real'  
108 - parameters:  
109 - dens: 'Dens'  
110 - vtot: 'Vel'  
111 - temp: 'Temp' 127 + l1:
  128 + - slug: 'omni_hour_all'
  129 + - slug: 'ace_swepam_real'
  130 + parameters:
  131 + dens: 'Dens'
  132 + vtot: 'Vel'
  133 + temp: 'Temp'
  134 + sa:
  135 + - slug: 'omni_hour_all'
  136 + - slug: 'ace_swepam_real'
  137 + parameters:
  138 + dens: 'Dens'
  139 + vtot: 'Vel'
  140 + temp: 'Temp'
  141 + sb:
  142 + - slug: 'omni_hour_all'
  143 + - slug: 'ace_swepam_real'
  144 + parameters:
  145 + dens: 'Dens'
  146 + vtot: 'Vel'
  147 + temp: 'Temp'
112 locked: false 148 locked: false
113 default: true 149 default: true
114 - type: 'planet' 150 - type: 'planet'
115 slug: 'mars' 151 slug: 'mars'
116 name: 'Mars' 152 name: 'Mars'
117 title: 'Mars' 153 title: 'Mars'
118 - models:  
119 - - slug: 'tao_mars_sw'  
120 - - slug: 'tao_mars_swrt'  
121 orbit: 154 orbit:
122 - models:  
123 - - slug: 'mars_orb_all'  
124 - semimajor: 1.52366231  
125 - semiminor: 1.51700011 155 + models:
  156 + - slug: 'mars_orb_all'
  157 + semimajor: 1.52366231
  158 + semiminor: 1.51700011
  159 + models:
  160 + l1:
  161 + - slug: 'tao_mars_sw'
  162 + - slug: 'tao_mars_swrt'
  163 + sa:
  164 + - slug: 'tao_mars_sw'
  165 + - slug: 'tao_mars_swrt'
  166 + sb:
  167 + - slug: 'tao_mars_sw'
  168 + - slug: 'tao_mars_swrt'
126 locked: false 169 locked: false
127 default: true 170 default: true
128 - type: 'planet' 171 - type: 'planet'
129 slug: 'jupiter' 172 slug: 'jupiter'
130 name: 'Jupiter' 173 name: 'Jupiter'
131 title: 'Jupiter' 174 title: 'Jupiter'
132 - models:  
133 - - slug: 'tao_jup_sw'  
134 - - slug: 'tao_jup_swrt'  
135 orbit: 175 orbit:
136 - models:  
137 - - slug: 'jupiter_orb_all'  
138 - semimajor: 5.45516759  
139 - semiminor: 4.95155843 176 + models:
  177 + - slug: 'jupiter_orb_all'
  178 + semimajor: 5.45516759
  179 + semiminor: 4.95155843
  180 + models:
  181 + l1:
  182 + - slug: 'tao_jup_sw'
  183 + - slug: 'tao_jup_swrt'
  184 + sa:
  185 + - slug: 'tao_jup_sw'
  186 + - slug: 'tao_jup_swrt'
  187 + sb:
  188 + - slug: 'tao_jup_sw'
  189 + - slug: 'tao_jup_swrt'
140 locked: false 190 locked: false
141 default: true 191 default: true
142 - type: 'planet' 192 - type: 'planet'
@@ -144,12 +194,17 @@ targets: @@ -144,12 +194,17 @@ targets:
144 name: 'Saturn' 194 name: 'Saturn'
145 title: 'Saturn' 195 title: 'Saturn'
146 orbit: 196 orbit:
147 - models:  
148 - - slug: 'saturn_orb_all'  
149 - semimajor: 9.53707032  
150 - semiminor: 9.5230773 197 + models:
  198 + - slug: 'saturn_orb_all'
  199 + semimajor: 9.53707032
  200 + semiminor: 9.5230773
151 models: 201 models:
152 - - slug: 'tao_sat_sw' 202 + l1:
  203 + - slug: 'tao_sat_sw'
  204 + sa:
  205 + - slug: 'tao_sat_sw'
  206 + sb:
  207 + - slug: 'tao_sat_sw'
153 locked: false 208 locked: false
154 default: true 209 default: true
155 - type: 'probe' 210 - type: 'probe'
@@ -157,16 +212,21 @@ targets: @@ -157,16 +212,21 @@ targets:
157 name: 'Rosetta' 212 name: 'Rosetta'
158 title: 'Rosetta' 213 title: 'Rosetta'
159 orbit: 214 orbit:
160 - models:  
161 - - slug: 'ros_orb_cruise'  
162 - stopped_at: '2014-08-02T00:00:00'  
163 - - slug: 'p67_orb_all'  
164 - started_at: '2014-08-02T00:00:00'  
165 - #stopped_at: '2016-09-30T11:19:00'  
166 - parameters:  
167 - hee: 'XYZ_HEE' 215 + models:
  216 + - slug: 'ros_orb_cruise'
  217 + stopped_at: '2014-08-02T00:00:00'
  218 + - slug: 'p67_orb_all'
  219 + started_at: '2014-08-02T00:00:00'
  220 + #stopped_at: '2016-09-30T11:19:00'
  221 + parameters:
  222 + hee: 'XYZ_HEE'
168 models: 223 models:
169 - - slug: 'tao_ros_sw' 224 + l1:
  225 + - slug: 'tao_ros_sw'
  226 + sa:
  227 + - slug: 'tao_ros_sw'
  228 + sb:
  229 + - slug: 'tao_ros_sw'
170 locked: false 230 locked: false
171 default: false 231 default: false
172 - type: 'probe' 232 - type: 'probe'
@@ -174,13 +234,18 @@ targets: @@ -174,13 +234,18 @@ targets:
174 name: 'Juno' 234 name: 'Juno'
175 title: 'Juno' 235 title: 'Juno'
176 orbit: 236 orbit:
177 - models:  
178 - - slug: 'juno_cruise_all'  
179 - stopped_at: '2016-07-05T03:53:00'  
180 - - slug: 'jupiter_orb_all'  
181 - started_at: '2016-07-05T03:53:00' 237 + models:
  238 + - slug: 'juno_cruise_all'
  239 + stopped_at: '2016-07-05T03:53:00'
  240 + - slug: 'jupiter_orb_all'
  241 + started_at: '2016-07-05T03:53:00'
182 models: 242 models:
183 - - slug: 'tao_juno_sw' 243 + l1:
  244 + - slug: 'tao_juno_sw'
  245 + sa:
  246 + - slug: 'tao_juno_sw'
  247 + sb:
  248 + - slug: 'tao_juno_sw'
184 locked: false 249 locked: false
185 default: false 250 default: false
186 - type: 'comet' 251 - type: 'comet'
@@ -188,12 +253,17 @@ targets: @@ -188,12 +253,17 @@ targets:
188 name: 'Churyumov-Gerasimenko' 253 name: 'Churyumov-Gerasimenko'
189 title: 'Churyumov-Gerasimenko (coming soon)' 254 title: 'Churyumov-Gerasimenko (coming soon)'
190 orbit: 255 orbit:
191 - models:  
192 - - slug: 'p67_orb_all'  
193 - parameters:  
194 - hee: 'XYZ_HEE' 256 + models:
  257 + - slug: 'p67_orb_all'
  258 + parameters:
  259 + hee: 'XYZ_HEE'
195 models: 260 models:
196 - - slug: 'tao_p67_sw' # fixme 261 + l1:
  262 + - slug: 'tao_p67_sw' # fixme
  263 + sa:
  264 + - slug: 'tao_p67_sw' # fixme
  265 + sb:
  266 + - slug: 'tao_p67_sw' # fixme
197 locked: true 267 locked: true
198 default: false 268 default: false
199 269
@@ -419,14 +419,17 @@ def retrieve_amda_netcdf(orbiter, what, started_at, stopped_at): @@ -419,14 +419,17 @@ def retrieve_amda_netcdf(orbiter, what, started_at, stopped_at):
419 return list(set(local_netc_files)) # remove possible dupes 419 return list(set(local_netc_files)) # remove possible dupes
420 420
421 421
422 -def get_data_for_target(target_config, started_at, stopped_at): 422 +def get_data_for_target(
  423 + target_config,
  424 + started_at, stopped_at,
  425 + input_slug='l1'):
423 """ 426 """
424 :return: dict whose keys are datetime as str, values tuples of data 427 :return: dict whose keys are datetime as str, values tuples of data
425 """ 428 """
426 log.debug("Grabbing data for '%s'..." % target_config['slug']) 429 log.debug("Grabbing data for '%s'..." % target_config['slug'])
427 430
428 try: 431 try:
429 - models = target_config['models'] 432 + models = target_config['models'][input_slug]
430 except Exception as e: 433 except Exception as e:
431 abort(500, "Invalid model configuration for '%s' : %s" 434 abort(500, "Invalid model configuration for '%s' : %s"
432 % (target_config['slug'], str(e))) 435 % (target_config['slug'], str(e)))
@@ -459,7 +462,7 @@ def get_data_for_target(target_config, started_at, stopped_at): @@ -459,7 +462,7 @@ def get_data_for_target(target_config, started_at, stopped_at):
459 raise Exception("No variable '%s' found in NetCDF." % _keys[_key]) 462 raise Exception("No variable '%s' found in NetCDF." % _keys[_key])
460 return [None] * len(_nc.variables['Time']) # slow -- use numpy! 463 return [None] * len(_nc.variables['Time']) # slow -- use numpy!
461 464
462 - # Override them using the configuration, maybe also put these in config ? 465 + # Override these using the model configuration
463 default_nc_keys = { 466 default_nc_keys = {
464 'hee': 'HEE', 467 'hee': 'HEE',
465 'vtot': 'V', 468 'vtot': 'V',
@@ -576,14 +579,17 @@ def get_data_for_target(target_config, started_at, stopped_at): @@ -576,14 +579,17 @@ def get_data_for_target(target_config, started_at, stopped_at):
576 return all_data 579 return all_data
577 580
578 581
579 -def generate_csv_contents(target_slug, started_at, stopped_at): 582 +def generate_csv_contents(target_slug, input_slug, started_at, stopped_at):
580 target_config = get_target_config(target_slug) 583 target_config = get_target_config(target_slug)
581 log.debug("Crunching CSV contents for '%s'..." % target_config['name']) 584 log.debug("Crunching CSV contents for '%s'..." % target_config['name'])
582 si = StringIO.StringIO() 585 si = StringIO.StringIO()
583 cw = csv_writer(si) 586 cw = csv_writer(si)
584 cw.writerow(PROPERTIES) 587 cw.writerow(PROPERTIES)
585 588
586 - all_data = get_data_for_target(target_config, started_at, stopped_at) 589 + all_data = get_data_for_target(
  590 + target_config=target_config, input_slug=input_slug,
  591 + started_at=started_at, stopped_at=stopped_at
  592 + )
587 593
588 log.debug("Writing and sorting CSV for '%s'..." % target_config['slug']) 594 log.debug("Writing and sorting CSV for '%s'..." % target_config['slug'])
589 for dkey in sorted(all_data): 595 for dkey in sorted(all_data):
@@ -593,15 +599,15 @@ def generate_csv_contents(target_slug, started_at, stopped_at): @@ -593,15 +599,15 @@ def generate_csv_contents(target_slug, started_at, stopped_at):
593 return si.getvalue() 599 return si.getvalue()
594 600
595 601
596 -def generate_csv_file_if_needed(target_slug, started_at, stopped_at):  
597 - filename = "%s_%s_%s.csv" % (target_slug,  
598 - started_at.strftime(FILE_DATE_FMT),  
599 - stopped_at.strftime(FILE_DATE_FMT)) 602 +def generate_csv_file_if_needed(target_slug, input_slug, started_at, stopped_at):
  603 + filename = "%s_%s_%s_%s.csv" % (target_slug, input_slug,
  604 + started_at.strftime(FILE_DATE_FMT),
  605 + stopped_at.strftime(FILE_DATE_FMT))
600 local_csv_file = join(CACHE_DIR, filename) 606 local_csv_file = join(CACHE_DIR, filename)
601 607
602 generate = True 608 generate = True
603 if isfile(local_csv_file): 609 if isfile(local_csv_file):
604 - # It need to have more than one line to not be empty (headers) 610 + # It needs to have more than one line to not be empty (headers)
605 with open(local_csv_file) as f: 611 with open(local_csv_file) as f:
606 cnt = 0 612 cnt = 0
607 for _ in f: 613 for _ in f:
@@ -683,6 +689,16 @@ def remove_files_created_before(date, in_directory): @@ -683,6 +689,16 @@ def remove_files_created_before(date, in_directory):
683 return removed_files 689 return removed_files
684 690
685 691
  692 +def get_input_slug_from_query(inp=None):
  693 + if inp is None:
  694 + input_slug = request.args.get('input_slug', 'l1')
  695 + else:
  696 + input_slug = inp
  697 + if input_slug not in [i.slug for i in config.inputs]:
  698 + input_slug = 'l1' # be tolerant instead of yelling loudly
  699 + return input_slug
  700 +
  701 +
686 def get_hit_counter(): 702 def get_hit_counter():
687 hit_count_path = get_path("../VISITS") 703 hit_count_path = get_path("../VISITS")
688 704
@@ -730,9 +746,11 @@ def home(): @@ -730,9 +746,11 @@ def home():
730 increment_hit_counter() 746 increment_hit_counter()
731 parameters = PARAMETERS.values() 747 parameters = PARAMETERS.values()
732 parameters.sort(key=lambda x: x['position']) 748 parameters.sort(key=lambda x: x['position'])
  749 + input_slug = get_input_slug_from_query()
733 return render_view('home.html.jinja2', { 750 return render_view('home.html.jinja2', {
734 'targets': config['targets'], 751 'targets': config['targets'],
735 'parameters': parameters, 752 'parameters': parameters,
  753 + 'input_slug': input_slug,
736 'planets': [s for s in config['targets'] if s['type'] == 'planet'], 754 'planets': [s for s in config['targets'] if s['type'] == 'planet'],
737 'probes': [s for s in config['targets'] if s['type'] == 'probe'], 755 'probes': [s for s in config['targets'] if s['type'] == 'probe'],
738 'comets': [s for s in config['targets'] if s['type'] == 'comet'], 756 'comets': [s for s in config['targets'] if s['type'] == 'comet'],
@@ -740,12 +758,13 @@ def home(): @@ -740,12 +758,13 @@ def home():
740 }) 758 })
741 759
742 760
743 -@app.route("/<target>_<started_at>_<stopped_at>.csv")  
744 -def download_target_csv(target, started_at, stopped_at): 761 +@app.route("/<target>_<inp>_<started_at>_<stopped_at>.csv")
  762 +def download_target_csv(target, inp, started_at, stopped_at):
745 """ 763 """
746 Grab data and orbit data for the specified `target`, 764 Grab data and orbit data for the specified `target`,
747 rearrange it and return it as a CSV file. 765 rearrange it and return it as a CSV file.
748 `started_at` and `stopped_at` should be UTC. 766 `started_at` and `stopped_at` should be UTC.
  767 + `inp` is the input slug, l1 or sa or sb.
749 """ 768 """
750 check_target_config(target) 769 check_target_config(target)
751 try: 770 try:
@@ -756,20 +775,24 @@ def download_target_csv(target, started_at, stopped_at): @@ -756,20 +775,24 @@ def download_target_csv(target, started_at, stopped_at):
756 stopped_at = datetime.datetime.strptime(stopped_at, FILE_DATE_FMT) 775 stopped_at = datetime.datetime.strptime(stopped_at, FILE_DATE_FMT)
757 except: 776 except:
758 abort(400, "Invalid stopped_at parameter : '%s'." % stopped_at) 777 abort(400, "Invalid stopped_at parameter : '%s'." % stopped_at)
  778 + input_slug = get_input_slug_from_query(inp=inp)
759 779
760 - filename = "%s_%s_%s.csv" % (target,  
761 - started_at.strftime(FILE_DATE_FMT),  
762 - stopped_at.strftime(FILE_DATE_FMT)) 780 + filename = "%s_%s_%s_%s.csv" % (target, input_slug,
  781 + started_at.strftime(FILE_DATE_FMT),
  782 + stopped_at.strftime(FILE_DATE_FMT))
763 local_csv_file = join(CACHE_DIR, filename) 783 local_csv_file = join(CACHE_DIR, filename)
764 - generate_csv_file_if_needed(target, started_at, stopped_at) 784 + generate_csv_file_if_needed(
  785 + target_slug=target, input_slug=input_slug,
  786 + started_at=started_at, stopped_at=stopped_at
  787 + )
765 if not isfile(local_csv_file): 788 if not isfile(local_csv_file):
766 abort(500, "Could not cache CSV file at '%s'." % local_csv_file) 789 abort(500, "Could not cache CSV file at '%s'." % local_csv_file)
767 790
768 return send_from_directory(CACHE_DIR, filename) 791 return send_from_directory(CACHE_DIR, filename)
769 792
770 793
771 -@app.route("/<targets>_<started_at>_<stopped_at>.tar.gz")  
772 -def download_targets_tarball(targets, started_at, stopped_at): 794 +@app.route("/<targets>_<inp>_<started_at>_<stopped_at>.tar.gz")
  795 +def download_targets_tarball(targets, inp, started_at, stopped_at):
773 """ 796 """
774 Grab data and orbit data for each of the specified `targets`, 797 Grab data and orbit data for each of the specified `targets`,
775 in their own CSV file, and make a tarball of them. 798 in their own CSV file, and make a tarball of them.
@@ -801,24 +824,35 @@ def download_targets_tarball(targets, started_at, stopped_at): @@ -801,24 +824,35 @@ def download_targets_tarball(targets, started_at, stopped_at):
801 sta = started_at.strftime(FILE_DATE_FMT) 824 sta = started_at.strftime(FILE_DATE_FMT)
802 sto = stopped_at.strftime(FILE_DATE_FMT) 825 sto = stopped_at.strftime(FILE_DATE_FMT)
803 826
804 - gzip_filename = "%s_%s_%s.tar.gz" % (separator.join(targets), sta, sto) 827 + input_slug = get_input_slug_from_query(inp=inp)
  828 +
  829 + gzip_filename = "%s_%s_%s_%s.tar.gz" % (
  830 + separator.join(targets), input_slug, sta, sto
  831 + )
805 local_gzip_file = join(CACHE_DIR, gzip_filename) 832 local_gzip_file = join(CACHE_DIR, gzip_filename)
806 833
807 if not isfile(local_gzip_file): 834 if not isfile(local_gzip_file):
808 log.debug("Creating the CSV files for the tarball...") 835 log.debug("Creating the CSV files for the tarball...")
809 for target_config in targets_configs: 836 for target_config in targets_configs:
810 - filename = "%s_%s_%s.csv" % (target_config['slug'], sta, sto) 837 + filename = "%s_%s_%s_%s.csv" % (
  838 + target_config['slug'], input_slug, sta, sto
  839 + )
811 local_csv_file = join(CACHE_DIR, filename) 840 local_csv_file = join(CACHE_DIR, filename)
812 if not isfile(local_csv_file): 841 if not isfile(local_csv_file):
813 with open(local_csv_file, mode="w+") as f: 842 with open(local_csv_file, mode="w+") as f:
814 - f.write(generate_csv_contents(target_config['slug'],  
815 - started_at=started_at,  
816 - stopped_at=stopped_at)) 843 + f.write(generate_csv_contents(
  844 + target_slug=target_config['slug'],
  845 + started_at=started_at,
  846 + stopped_at=stopped_at,
  847 + input_slug=input_slug
  848 + ))
817 849
818 log.debug("Creating the tarball '%s'..." % local_gzip_file) 850 log.debug("Creating the tarball '%s'..." % local_gzip_file)
819 with tarfile.open(local_gzip_file, "w:gz") as tar: 851 with tarfile.open(local_gzip_file, "w:gz") as tar:
820 for target_config in targets_configs: 852 for target_config in targets_configs:
821 - filename = "%s_%s_%s.csv" % (target_config['slug'], sta, sto) 853 + filename = "%s_%s_%s_%s.csv" % (
  854 + target_config['slug'], input_slug, sta, sto
  855 + )
822 local_csv_file = join(CACHE_DIR, filename) 856 local_csv_file = join(CACHE_DIR, filename)
823 tar.add(local_csv_file, arcname=filename) 857 tar.add(local_csv_file, arcname=filename)
824 858
@@ -828,8 +862,8 @@ def download_targets_tarball(targets, started_at, stopped_at): @@ -828,8 +862,8 @@ def download_targets_tarball(targets, started_at, stopped_at):
828 return send_from_directory(CACHE_DIR, gzip_filename) 862 return send_from_directory(CACHE_DIR, gzip_filename)
829 863
830 864
831 -@app.route("/<targets>_<params>_<started_at>_<stopped_at>.nc")  
832 -def download_targets_netcdf(targets, params, started_at, stopped_at): 865 +@app.route("/<targets>_<inp>_<params>_<started_at>_<stopped_at>.nc")
  866 +def download_targets_netcdf(targets, inp, params, started_at, stopped_at):
833 """ 867 """
834 Grab data and orbit data for the specified `target`, 868 Grab data and orbit data for the specified `target`,
835 rearrange it and return it as a NetCDF file. 869 rearrange it and return it as a NetCDF file.
@@ -867,8 +901,11 @@ def download_targets_netcdf(targets, params, started_at, stopped_at): @@ -867,8 +901,11 @@ def download_targets_netcdf(targets, params, started_at, stopped_at):
867 sta = started_at.strftime(date_fmt) 901 sta = started_at.strftime(date_fmt)
868 sto = stopped_at.strftime(date_fmt) 902 sto = stopped_at.strftime(date_fmt)
869 903
870 - nc_filename = "%s_%s_%s_%s.nc" % \  
871 - (separator.join(targets), separator.join(params), sta, sto) 904 + input_slug = get_input_slug_from_query(inp=inp)
  905 +
  906 + nc_filename = "%s_%s_%s_%s_%s.nc" % (
  907 + separator.join(targets), separator.join(params), input_slug, sta, sto
  908 + )
872 nc_path = join(CACHE_DIR, nc_filename) 909 nc_path = join(CACHE_DIR, nc_filename)
873 910
874 if not isfile(nc_path): 911 if not isfile(nc_path):
@@ -883,7 +920,10 @@ def download_targets_netcdf(targets, params, started_at, stopped_at): @@ -883,7 +920,10 @@ def download_targets_netcdf(targets, params, started_at, stopped_at):
883 target_slug = target['slug'] 920 target_slug = target['slug']
884 log.debug("Adding group '%s' to the NetCDF..." % target_slug) 921 log.debug("Adding group '%s' to the NetCDF..." % target_slug)
885 nc_group = nc_handle.createGroup(target_slug) 922 nc_group = nc_handle.createGroup(target_slug)
886 - data = get_data_for_target(target, started_at, stopped_at) 923 + data = get_data_for_target(
  924 + target_config=target, input_slug=input_slug,
  925 + started_at=started_at, stopped_at=stopped_at
  926 + )
887 dkeys = sorted(data) 927 dkeys = sorted(data)
888 dimension = 'dim_'+target_slug 928 dimension = 'dim_'+target_slug
889 nc_handle.createDimension(dimension, len(dkeys)) 929 nc_handle.createDimension(dimension, len(dkeys))
@@ -946,8 +986,8 @@ def download_targets_netcdf(targets, params, started_at, stopped_at): @@ -946,8 +986,8 @@ def download_targets_netcdf(targets, params, started_at, stopped_at):
946 return send_from_directory(CACHE_DIR, nc_filename) 986 return send_from_directory(CACHE_DIR, nc_filename)
947 987
948 988
949 -@app.route("/<targets>_<started_at>_<stopped_at>.cdf")  
950 -def download_targets_cdf(targets, started_at, stopped_at): 989 +@app.route("/<targets>_<inp>_<started_at>_<stopped_at>.cdf")
  990 +def download_targets_cdf(targets, inp, started_at, stopped_at):
951 """ 991 """
952 Grab data and orbit data for the specified `target`, 992 Grab data and orbit data for the specified `target`,
953 rearrange it and return it as a CDF file. 993 rearrange it and return it as a CDF file.
@@ -986,7 +1026,11 @@ def download_targets_cdf(targets, started_at, stopped_at): @@ -986,7 +1026,11 @@ def download_targets_cdf(targets, started_at, stopped_at):
986 sta = started_at.strftime(FILE_DATE_FMT) 1026 sta = started_at.strftime(FILE_DATE_FMT)
987 sto = stopped_at.strftime(FILE_DATE_FMT) 1027 sto = stopped_at.strftime(FILE_DATE_FMT)
988 1028
989 - cdf_filename = "%s_%s_%s.cdf" % (separator.join(targets), sta, sto) 1029 + input_slug = get_input_slug_from_query(inp=inp)
  1030 +
  1031 + cdf_filename = "%s_%s_%s_%s.cdf" % (
  1032 + separator.join(targets), input_slug, sta, sto
  1033 + )
990 cdf_path = join(CACHE_DIR, cdf_filename) 1034 cdf_path = join(CACHE_DIR, cdf_filename)
991 1035
992 if not isfile(cdf_path): 1036 if not isfile(cdf_path):
@@ -1010,7 +1054,10 @@ def download_targets_cdf(targets, started_at, stopped_at): @@ -1010,7 +1054,10 @@ def download_targets_cdf(targets, started_at, stopped_at):
1010 available_params = list(PROPERTIES) 1054 available_params = list(PROPERTIES)
1011 for target in targets_configs: 1055 for target in targets_configs:
1012 target_slug = target['slug'] 1056 target_slug = target['slug']
1013 - data = get_data_for_target(target, started_at, stopped_at) 1057 + data = get_data_for_target(
  1058 + target_config=target, input_slug=input_slug,
  1059 + started_at=started_at, stopped_at=stopped_at
  1060 + )
1014 dkeys = sorted(data) 1061 dkeys = sorted(data)
1015 1062
1016 values = [] 1063 values = []
@@ -1108,13 +1155,14 @@ def cache_warmup(): @@ -1108,13 +1155,14 @@ def cache_warmup():
1108 stopped_at = today + after 1155 stopped_at = today + after
1109 sta = started_at.strftime(FILE_DATE_FMT) 1156 sta = started_at.strftime(FILE_DATE_FMT)
1110 sto = stopped_at.strftime(FILE_DATE_FMT) 1157 sto = stopped_at.strftime(FILE_DATE_FMT)
  1158 + inp = 'l1' # default input, maybe warm them all up ?
1111 1159
1112 targets = get_active_targets() 1160 targets = get_active_targets()
1113 for target in targets: 1161 for target in targets:
1114 - download_target_csv(target['slug'], sta, sto) 1162 + download_target_csv(target['slug'], inp, sta, sto)
1115 targets_slugs = [target['slug'] for target in targets] 1163 targets_slugs = [target['slug'] for target in targets]
1116 targets_slugs.sort() 1164 targets_slugs.sort()
1117 - download_targets_cdf('-'.join(targets_slugs), sta, sto) 1165 + download_targets_cdf('-'.join(targets_slugs), inp, sta, sto)
1118 1166
1119 return "Done" 1167 return "Done"
1120 1168
web/view/home.html.jinja2
@@ -59,7 +59,9 @@ @@ -59,7 +59,9 @@
59 <div class="mdl-layout mdl-js-layout mdl-layout--fixed-drawer"> 59 <div class="mdl-layout mdl-js-layout mdl-layout--fixed-drawer">
60 60
61 <div class="mdl-layout__drawer"> 61 <div class="mdl-layout__drawer">
  62 +
62 <span class="mdl-layout-title" title="Two years maximum.">{{ icon('calendar') }} Time Interval</span> 63 <span class="mdl-layout-title" title="Two years maximum.">{{ icon('calendar') }} Time Interval</span>
  64 +
63 <form id="form_time_interval" action="#"> 65 <form id="form_time_interval" action="#">
64 <div class="mdl-textfield mdl-js-textfield"> 66 <div class="mdl-textfield mdl-js-textfield">
65 <input type="date" id="started_at" name="started_at" title="The date of the beginning of the interval to observe." class="mdl-textfield__input"> 67 <input type="date" id="started_at" name="started_at" title="The date of the beginning of the interval to observe." class="mdl-textfield__input">
@@ -96,6 +98,22 @@ @@ -96,6 +98,22 @@
96 <br> 98 <br>
97 <hr class="clear"> 99 <hr class="clear">
98 100
  101 +{# <span class="mdl-layout-title">{{ icon('database') }} Inputs</span>#}
  102 +{##}
  103 +{# <section class="section-drawer">#}
  104 +{#{% for input in config.inputs %}#}
  105 +{# <label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-input-{{ input.slug }}" title="{{ input.desc }}">#}
  106 +{# <input type="radio" id="option-input-{{ input.slug }}" class="mdl-radio__button" name="input_slug" value="{{ input.slug }}" {{ 'checked' if input.slug == input_slug }}>#}
  107 +{# <span class="mdl-radio__label">{{ input.name }}</span>#}
  108 +{# </label>#}
  109 +{# <br />#}
  110 +{#{% endfor %}#}
  111 +{# <br />#}
  112 +{# <input type="button" id="apply_new_input" value="Reload for input" title="This may take a while." class="mdl-button mdl-js-button mdl-js-ripple-effect">#}
  113 +{# </section>#}
  114 +{##}
  115 +{# <hr class="clear">#}
  116 +
99 <span class="mdl-layout-title">{{ icon('flask') }} Parameters</span> 117 <span class="mdl-layout-title">{{ icon('flask') }} Parameters</span>
100 118
101 <nav id="parameters" class="mdl-navigation"> 119 <nav id="parameters" class="mdl-navigation">
@@ -315,6 +333,9 @@ @@ -315,6 +333,9 @@
315 #started_at, #stopped_at { 333 #started_at, #stopped_at {
316 width: 85%; 334 width: 85%;
317 } 335 }
  336 + .section-drawer {
  337 + padding-left: 3em;
  338 + }
318 .targets-filters { 339 .targets-filters {
319 padding-left: 17px; 340 padding-left: 17px;
320 } 341 }
@@ -537,9 +558,9 @@ var configuration = { @@ -537,9 +558,9 @@ var configuration = {
537 time_series_container: '#time_series', 558 time_series_container: '#time_series',
538 orbits_container: '#orbits', 559 orbits_container: '#orbits',
539 api: { 560 api: {
540 - 'data_for_interval': "{{ request.url_root }}<target>_<started_at>_<stopped_at>.csv",  
541 - 'download': "{{ request.url_root }}<targets>_<started_at>_<stopped_at>.cdf",  
542 - 'samp': "{{ request.url_root }}<targets>_<started_at>_<stopped_at>.cdf" 561 + 'data_for_interval': "{{ request.url_root }}<target>_{{ input_slug }}_<started_at>_<stopped_at>.csv",
  562 + 'download': "{{ request.url_root }}<targets>_{{ input_slug }}_<started_at>_<stopped_at>.cdf",
  563 + 'samp': "{{ request.url_root }}<targets>_{{ input_slug }}_<started_at>_<stopped_at>.cdf"
543 }, 564 },
544 sun: { 565 sun: {
545 img: '{{ static('img/sun_128.png') }}' 566 img: '{{ static('img/sun_128.png') }}'
@@ -621,6 +642,11 @@ jQuery().ready(function($){ @@ -621,6 +642,11 @@ jQuery().ready(function($){
621 sw.resizeDomain(started_at, stopped_at); 642 sw.resizeDomain(started_at, stopped_at);
622 return false; 643 return false;
623 }); 644 });
  645 + $('#apply_new_input').on("click", function(e){
  646 + var new_input_slug = $("input[name='input_slug']:checked").val();
  647 + window.location = "?input_slug="+new_input_slug;
  648 + return false;
  649 + });
624 $('#download').on("click", function(e){ 650 $('#download').on("click", function(e){
625 var url = sw.buildDownloadUrl(); 651 var url = sw.buildDownloadUrl();
626 console.info("Downloading " + url); 652 console.info("Downloading " + url);