Commit 596da00d20ebbf1fb795576ebddbeeff7827a48f
1 parent
284f4688
Exists in
master
and in
2 other branches
Add more exceptions for Earth.
Showing
5 changed files
with
84 additions
and
13 deletions
Show diff stats
CHANGELOG.md
@@ -41,8 +41,8 @@ et prendre aussi | @@ -41,8 +41,8 @@ et prendre aussi | ||
41 | 41 | ||
42 | ## 1.3 | 42 | ## 1.3 |
43 | 43 | ||
44 | -- [ ] Earth pdyn = pv² | ||
45 | -- [ ] Earth omnihour B is a Vector3 | 44 | +- [x] Earth pdyn = pv² (TBD) |
45 | +- [x] Earth omnihour B is a Vector3, use the first scalar | ||
46 | - [ ] Layers | 46 | - [ ] Layers |
47 | - SW Catalogs | 47 | - SW Catalogs |
48 | - Auroral Emissions | 48 | - Auroral Emissions |
config.yml
@@ -172,15 +172,17 @@ targets: | @@ -172,15 +172,17 @@ targets: | ||
172 | - slug: 'omni_hour_all' | 172 | - slug: 'omni_hour_all' |
173 | parameters: | 173 | parameters: |
174 | pdyn: 'RamP' | 174 | pdyn: 'RamP' |
175 | -# btan: '' | ||
176 | - slug: 'ace_swepam_real' | 175 | - slug: 'ace_swepam_real' |
176 | + # [u'Time', u'Dens', u'Vel', u'Temp', u'flag', u'StartTime', u'StopTime'] | ||
177 | parameters: | 177 | parameters: |
178 | dens: 'Dens' | 178 | dens: 'Dens' |
179 | vtot: 'Vel' | 179 | vtot: 'Vel' |
180 | temp: 'Temp' | 180 | temp: 'Temp' |
181 | - btan: 'Bgsm' # /!. VECTOR2 | 181 | + #btan: 'Bgsm' # /!. VECTOR2 (actually, does not exist) |
182 | sa: | 182 | sa: |
183 | - slug: 'omni_hour_all' | 183 | - slug: 'omni_hour_all' |
184 | + parameters: | ||
185 | + pdyn: 'RamP' | ||
184 | - slug: 'ace_swepam_real' | 186 | - slug: 'ace_swepam_real' |
185 | parameters: | 187 | parameters: |
186 | dens: 'Dens' | 188 | dens: 'Dens' |
@@ -188,6 +190,8 @@ targets: | @@ -188,6 +190,8 @@ targets: | ||
188 | temp: 'Temp' | 190 | temp: 'Temp' |
189 | sb: | 191 | sb: |
190 | - slug: 'omni_hour_all' | 192 | - slug: 'omni_hour_all' |
193 | + parameters: | ||
194 | + pdyn: 'RamP' | ||
191 | - slug: 'ace_swepam_real' | 195 | - slug: 'ace_swepam_real' |
192 | parameters: | 196 | parameters: |
193 | dens: 'Dens' | 197 | dens: 'Dens' |
web/run.py
@@ -10,7 +10,7 @@ import tarfile | @@ -10,7 +10,7 @@ import tarfile | ||
10 | import time | 10 | import time |
11 | import urllib | 11 | import urllib |
12 | from csv import writer as csv_writer | 12 | from csv import writer as csv_writer |
13 | -from math import sqrt | 13 | +from math import sqrt, isnan |
14 | from os import environ, remove as removefile | 14 | from os import environ, remove as removefile |
15 | from os.path import isfile, join, abspath, dirname | 15 | from os.path import isfile, join, abspath, dirname |
16 | 16 | ||
@@ -419,6 +419,51 @@ def retrieve_amda_netcdf(orbiter, what, started_at, stopped_at): | @@ -419,6 +419,51 @@ 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 | +# class DataParser: | ||
423 | +# """ | ||
424 | +# Default data parser | ||
425 | +# A wip to try to handle code exeptions sanely. | ||
426 | +# """ | ||
427 | +# | ||
428 | +# # Override these using the model configuration | ||
429 | +# default_nc_keys = { | ||
430 | +# 'hee': 'HEE', | ||
431 | +# 'vtot': 'V', | ||
432 | +# 'magn': 'B', | ||
433 | +# 'temp': 'T', | ||
434 | +# 'dens': 'N', | ||
435 | +# 'pdyn': 'P_dyn', | ||
436 | +# 'atse': 'Delta_angle', | ||
437 | +# } | ||
438 | +# | ||
439 | +# def __init__(self, target, model): | ||
440 | +# self.target = target | ||
441 | +# self.model = model | ||
442 | +# pass | ||
443 | +# | ||
444 | +# def _read_var(self, nc, _keys, _key, mandatory=False): | ||
445 | +# try: | ||
446 | +# return nc.variables[_keys[_key]] | ||
447 | +# except KeyError: | ||
448 | +# pass | ||
449 | +# if mandatory: | ||
450 | +# raise Exception("No variable '%s' found in NetCDF." % _keys[_key]) | ||
451 | +# return [None] * len(nc.variables['Time']) # slow -- use numpy? | ||
452 | +# | ||
453 | +# def parse(self, cdf_handle): | ||
454 | +# nc_keys = self.default_nc_keys.copy() | ||
455 | +# | ||
456 | +# times = cdf_handle.variables['Time'] # YYYY DOY HH MM SS .ms | ||
457 | +# data_v = self._read_var(cdf_handle, nc_keys, 'vtot') | ||
458 | +# data_b = self._read_var(cdf_handle, nc_keys, 'magn') | ||
459 | +# data_t = self._read_var(cdf_handle, nc_keys, 'temp') | ||
460 | +# data_n = self._read_var(cdf_handle, nc_keys, 'dens') | ||
461 | +# data_p = self._read_var(cdf_handle, nc_keys, 'pdyn') | ||
462 | +# data_a = self._read_var(cdf_handle, nc_keys, 'atse') | ||
463 | +# | ||
464 | +# return zip() | ||
465 | + | ||
466 | + | ||
422 | def get_data_for_target(target_config, input_slug, | 467 | def get_data_for_target(target_config, input_slug, |
423 | started_at, stopped_at): | 468 | started_at, stopped_at): |
424 | """ | 469 | """ |
@@ -518,7 +563,9 @@ def get_data_for_target(target_config, input_slug, | @@ -518,7 +563,9 @@ def get_data_for_target(target_config, input_slug, | ||
518 | log.debug("%s: opening model NETCDF4 '%s'..." % | 563 | log.debug("%s: opening model NETCDF4 '%s'..." % |
519 | (target_config['name'], model_file)) | 564 | (target_config['name'], model_file)) |
520 | cdf_handle = Dataset(model_file, "r", format="NETCDF4") | 565 | cdf_handle = Dataset(model_file, "r", format="NETCDF4") |
566 | + | ||
521 | # log.debug(cdf_handle.variables.keys()) | 567 | # log.debug(cdf_handle.variables.keys()) |
568 | + | ||
522 | times = cdf_handle.variables['Time'] # YYYY DOY HH MM SS .ms | 569 | times = cdf_handle.variables['Time'] # YYYY DOY HH MM SS .ms |
523 | data_v = _read_var(cdf_handle, nc_keys, 'vtot') | 570 | data_v = _read_var(cdf_handle, nc_keys, 'vtot') |
524 | data_b = _read_var(cdf_handle, nc_keys, 'magn') | 571 | data_b = _read_var(cdf_handle, nc_keys, 'magn') |
@@ -546,9 +593,17 @@ def get_data_for_target(target_config, input_slug, | @@ -546,9 +593,17 @@ def get_data_for_target(target_config, input_slug, | ||
546 | except Exception: | 593 | except Exception: |
547 | log.error("Failed to parse time from %s." % ltime) | 594 | log.error("Failed to parse time from %s." % ltime) |
548 | raise | 595 | raise |
596 | + | ||
549 | if s0 <= dtime <= s1: | 597 | if s0 <= dtime <= s1: |
550 | dkey = round_time(dtime, 60*60).strftime(precision) | 598 | dkey = round_time(dtime, 60*60).strftime(precision) |
551 | 599 | ||
600 | + x_hee = None | ||
601 | + y_hee = None | ||
602 | + if dkey in orbit_data: | ||
603 | + x_hee = orbit_data[dkey][0] | ||
604 | + y_hee = orbit_data[dkey][1] | ||
605 | + | ||
606 | + # First exception: V may be a vector instead of a scalar | ||
552 | if hasattr(datum_v, '__len__'): | 607 | if hasattr(datum_v, '__len__'): |
553 | vrad = datum_v[0] | 608 | vrad = datum_v[0] |
554 | vtan = datum_v[1] | 609 | vtan = datum_v[1] |
@@ -558,14 +613,26 @@ def get_data_for_target(target_config, input_slug, | @@ -558,14 +613,26 @@ def get_data_for_target(target_config, input_slug, | ||
558 | vtan = None | 613 | vtan = None |
559 | vtot = datum_v | 614 | vtot = datum_v |
560 | 615 | ||
561 | - x_hee = None | ||
562 | - y_hee = None | 616 | + # Second exception: Earth is always at (1, 0) |
563 | if target_config['slug'] == 'earth': | 617 | if target_config['slug'] == 'earth': |
564 | x_hee = 1 | 618 | x_hee = 1 |
565 | y_hee = 0 | 619 | y_hee = 0 |
566 | - if dkey in orbit_data: | ||
567 | - x_hee = orbit_data[dkey][0] | ||
568 | - y_hee = orbit_data[dkey][1] | 620 | + |
621 | + # Third exception: B is a Vector3 or a Vector2 for Earth | ||
622 | + if target_config['slug'] == 'earth': | ||
623 | + if model['slug'] == 'omni_hour_all': # Vector3 | ||
624 | + datum_b = datum_b[0] | ||
625 | + # if model['slug'] == 'ace_swepam_real': # Vector2 | ||
626 | + # datum_b = datum_b[0] | ||
627 | + if model['slug'] == 'omni_hour_all': | ||
628 | + datum_p = datum_n * vtot * vtot | ||
629 | + if model['slug'] == 'ace_swepam_real': | ||
630 | + datum_p = datum_n * vtot * vtot | ||
631 | + if vtot is None or isnan(vtot): | ||
632 | + continue | ||
633 | + | ||
634 | + # Keep adding exceptions here until you can't or become mad | ||
635 | + | ||
569 | # /!\ MUST be in the same order as PROPERTIES | 636 | # /!\ MUST be in the same order as PROPERTIES |
570 | all_data[dkey] = ( | 637 | all_data[dkey] = ( |
571 | dtime.strftime("%Y-%m-%dT%H:%M:%S+00:00"), | 638 | dtime.strftime("%Y-%m-%dT%H:%M:%S+00:00"), |
@@ -781,7 +848,6 @@ def get_catalog_layers(input_slug, target_slug): | @@ -781,7 +848,6 @@ def get_catalog_layers(input_slug, target_slug): | ||
781 | 'start': start_time, | 848 | 'start': start_time, |
782 | 'stop': stop_time, | 849 | 'stop': stop_time, |
783 | }) | 850 | }) |
784 | - #log.debug('Inspect C') | ||
785 | 851 | ||
786 | return catalog_layers | 852 | return catalog_layers |
787 | 853 | ||
@@ -1299,6 +1365,7 @@ def cache_warmup(): | @@ -1299,6 +1365,7 @@ def cache_warmup(): | ||
1299 | 1365 | ||
1300 | 1366 | ||
1301 | @app.route("/log") | 1367 | @app.route("/log") |
1368 | +@app.route("/log.html") | ||
1302 | def log_show(): | 1369 | def log_show(): |
1303 | with open(LOG_FILE, 'r') as f: | 1370 | with open(LOG_FILE, 'r') as f: |
1304 | contents = f.read() | 1371 | contents = f.read() |
web/static/js/swapp.js
@@ -748,7 +748,7 @@ | @@ -748,7 +748,7 @@ | ||
748 | }; | 748 | }; |
749 | TimeSeries.prototype.createCatalogLayer = function(started_at, stopped_at){ | 749 | TimeSeries.prototype.createCatalogLayer = function(started_at, stopped_at){ |
750 | var layer_rect; | 750 | var layer_rect; |
751 | - layer_rect = this.plotWrapper.append("rect").attr('y', 0).attr('height', this.plotHeight).attr('fill', '#FFFD6492'); | 751 | + layer_rect = this.plotWrapper.append("rect").attr('y', 0).attr('height', this.plotHeight).attr('fill', '#FFFD64C2'); |
752 | return layer_rect; | 752 | return layer_rect; |
753 | }; | 753 | }; |
754 | TimeSeries.prototype.resizeCatalogLayers = function(){ | 754 | TimeSeries.prototype.resizeCatalogLayers = function(){ |
web/static/js/swapp.ls
@@ -673,7 +673,7 @@ export class TimeSeries | @@ -673,7 +673,7 @@ export class TimeSeries | ||
673 | layer_rect = @plotWrapper.append("rect") | 673 | layer_rect = @plotWrapper.append("rect") |
674 | .attr('y', 0) | 674 | .attr('y', 0) |
675 | .attr('height', @plotHeight) | 675 | .attr('height', @plotHeight) |
676 | - .attr('fill', '#FFFD6492') | 676 | + .attr('fill', '#FFFD64C2') |
677 | # Not triggered, mouse events are captured before they reach this rect | 677 | # Not triggered, mouse events are captured before they reach this rect |
678 | #layer_rect.append('svg:title').text("I AM TEXT") | 678 | #layer_rect.append('svg:title').text("I AM TEXT") |
679 | layer_rect | 679 | layer_rect |