def pick_data(eop_data, time, window, sources): """Pick out subset of eop_data relevant for the given time epochs and interpolation window Args: eop_data (Dict): Dictionary of EOP data indexed by MJD dates. time (Time): Time epochs for which to calculate EOPs. window (Int): Interpolation window [days]. Returns: Dict: EOP data subset to the time period needed. """ if time.size == 1: start_time = np.floor(time.utc.mjd) - window // 2 end_time = np.ceil(time.utc.mjd) + window // 2 else: start_time = np.floor(time.utc.mjd.min()) - window // 2 end_time = np.ceil(time.utc.mjd.max()) + window // 2 sources = sources if sources else config.tech.eop_sources.list for source in sources: try: picked_data = {d: eop_data[source][d].copy() for d in np.arange(start_time, end_time + 1)} eop_path = config.files.path(f"eop_{source}") log.debug(f"Using a priori EOP values from {eop_path} ") return picked_data except KeyError: pass # No data found if we reached this point paths = [str(config.files.path(f"eop_{k}")) for k in sources] raise exceptions.MissingDataError( "Not all days in the time period {:.0f} - {:.0f} MJD were found in EOP-files {}" "".format(start_time, end_time, ", ".join(paths)) )
def write_to_dataset(dset, rundate=None, session=None, obs_format=None, **obs_args): obs_format = config.tech.get("obs_format", section=TECH, value=obs_format).str log.info(f"Reading observation file in {obs_format} format") file_vars = config.create_file_vars(rundate, TECH, session=session, **obs_args) parser = parsers.parse_key(f"vlbi_obs_{obs_format}", file_vars) if parser.data_available: _write_to_dataset(parser, dset, rundate, session) else: raise exceptions.MissingDataError( f"No observation file in {obs_format} format found for {rundate}")