diff --git a/web/run.py b/web/run.py index 64be76d..8c3dc3e 100644 --- a/web/run.py +++ b/web/run.py @@ -334,6 +334,30 @@ def datetime_from_list(time_list): ) +def _sta_sto(_cnf, _sta, _sto): + if 'started_at' in _cnf: + _s0 = datetime.datetime.strptime(_cnf['started_at'], FILE_DATE_FMT) + _s0 = max(_s0, _sta) + else: + _s0 = _sta + if 'stopped_at' in _cnf: + _s1 = datetime.datetime.strptime(_cnf['stopped_at'], FILE_DATE_FMT) + _s1 = min(_s1, _sto) + else: + _s1 = _sto + return _s0, _s1 + + +def _read_var(_nc, _keys, _key, mandatory=False): + try: + return _nc.variables[_keys[_key]] + except KeyError: + pass + if mandatory: + raise Exception("No variable '%s' found in NetCDF." % _keys[_key]) + return [None] * len(_nc.variables['Time']) # slow -- use numpy! + + def get_local_filename(url): """ Build the local cache filename for the distant file @@ -654,28 +678,6 @@ def get_data_for_target(target_config, input_slug, # abort(500, "Invalid orbit configuration for '%s' : %s" # % (target_config['slug'], str(e))) - def _sta_sto(_cnf, _sta, _sto): - if 'started_at' in _cnf: - _s0 = datetime.datetime.strptime(_cnf['started_at'], FILE_DATE_FMT) - _s0 = max(_s0, _sta) - else: - _s0 = _sta - if 'stopped_at' in _cnf: - _s1 = datetime.datetime.strptime(_cnf['stopped_at'], FILE_DATE_FMT) - _s1 = min(_s1, _sto) - else: - _s1 = _sto - return _s0, _s1 - - def _read_var(_nc, _keys, _key, mandatory=False): - try: - return _nc.variables[_keys[_key]] - except KeyError: - pass - if mandatory: - raise Exception("No variable '%s' found in NetCDF." % _keys[_key]) - return [None] * len(_nc.variables['Time']) # slow -- use numpy! - # Override these using the model configuration in config.yml default_nc_keys = { 'hee': 'HEE', -- libgit2 0.21.2