Commit 9b97b286b3674749d69c6b4c4c09cb2cf0dec244
1 parent
fe6e8f9b
Exists in
rhitier-dev
and in
1 other branch
Move 2 funcs upwards in scope
Showing
1 changed file
with
24 additions
and
22 deletions
Show diff stats
web/run.py
@@ -334,6 +334,30 @@ def datetime_from_list(time_list): | @@ -334,6 +334,30 @@ def datetime_from_list(time_list): | ||
334 | ) | 334 | ) |
335 | 335 | ||
336 | 336 | ||
337 | +def _sta_sto(_cnf, _sta, _sto): | ||
338 | + if 'started_at' in _cnf: | ||
339 | + _s0 = datetime.datetime.strptime(_cnf['started_at'], FILE_DATE_FMT) | ||
340 | + _s0 = max(_s0, _sta) | ||
341 | + else: | ||
342 | + _s0 = _sta | ||
343 | + if 'stopped_at' in _cnf: | ||
344 | + _s1 = datetime.datetime.strptime(_cnf['stopped_at'], FILE_DATE_FMT) | ||
345 | + _s1 = min(_s1, _sto) | ||
346 | + else: | ||
347 | + _s1 = _sto | ||
348 | + return _s0, _s1 | ||
349 | + | ||
350 | + | ||
351 | +def _read_var(_nc, _keys, _key, mandatory=False): | ||
352 | + try: | ||
353 | + return _nc.variables[_keys[_key]] | ||
354 | + except KeyError: | ||
355 | + pass | ||
356 | + if mandatory: | ||
357 | + raise Exception("No variable '%s' found in NetCDF." % _keys[_key]) | ||
358 | + return [None] * len(_nc.variables['Time']) # slow -- use numpy! | ||
359 | + | ||
360 | + | ||
337 | def get_local_filename(url): | 361 | def get_local_filename(url): |
338 | """ | 362 | """ |
339 | Build the local cache filename for the distant file | 363 | Build the local cache filename for the distant file |
@@ -654,28 +678,6 @@ def get_data_for_target(target_config, input_slug, | @@ -654,28 +678,6 @@ def get_data_for_target(target_config, input_slug, | ||
654 | # abort(500, "Invalid orbit configuration for '%s' : %s" | 678 | # abort(500, "Invalid orbit configuration for '%s' : %s" |
655 | # % (target_config['slug'], str(e))) | 679 | # % (target_config['slug'], str(e))) |
656 | 680 | ||
657 | - def _sta_sto(_cnf, _sta, _sto): | ||
658 | - if 'started_at' in _cnf: | ||
659 | - _s0 = datetime.datetime.strptime(_cnf['started_at'], FILE_DATE_FMT) | ||
660 | - _s0 = max(_s0, _sta) | ||
661 | - else: | ||
662 | - _s0 = _sta | ||
663 | - if 'stopped_at' in _cnf: | ||
664 | - _s1 = datetime.datetime.strptime(_cnf['stopped_at'], FILE_DATE_FMT) | ||
665 | - _s1 = min(_s1, _sto) | ||
666 | - else: | ||
667 | - _s1 = _sto | ||
668 | - return _s0, _s1 | ||
669 | - | ||
670 | - def _read_var(_nc, _keys, _key, mandatory=False): | ||
671 | - try: | ||
672 | - return _nc.variables[_keys[_key]] | ||
673 | - except KeyError: | ||
674 | - pass | ||
675 | - if mandatory: | ||
676 | - raise Exception("No variable '%s' found in NetCDF." % _keys[_key]) | ||
677 | - return [None] * len(_nc.variables['Time']) # slow -- use numpy! | ||
678 | - | ||
679 | # Override these using the model configuration in config.yml | 681 | # Override these using the model configuration in config.yml |
680 | default_nc_keys = { | 682 | default_nc_keys = { |
681 | 'hee': 'HEE', | 683 | 'hee': 'HEE', |