コード例 #1
0
 def read(self, json_data, hdf5_data):
     super().read(json_data, hdf5_data)
     self._fields = json_data[self.name]["fields"]
     scale = json_data[self.name].get("scale", "tai")  # TODO: 'tai' used earlier, `get` for backwards compatibility
     #       should be `json_data[self.name]['scale']` but will
     #       cause old datasets to become unreadable
     time_values = hdf5_data[self.name][...]
     self._data = time.Time(val=time_values[:, 0], val2=time_values[:, 1], format="jd", scale=scale)
コード例 #2
0
    def header_line(self):
        """Mandatory header line
        """
        now = time.Time(datetime.now(), scale="utc").yydddsssss
        start = min(self.dset.time).yydddsssss
        end = max(self.dset.time).yydddsssss

        file_agency = config.tech.sinex.file_agency.str.upper()
        data_agency = config.tech.sinex.data_agency.str.upper()

        num_params = self.dset.meta["statistics"]["number of unknowns"]
        constraint = "2"
        self.fid.write(
            f"%=SNX 2.02 {file_agency:<3} {now} {data_agency:<3} {start} {end} R {num_params:>5} {constraint} S E C \n"
        )
コード例 #3
0
    def extend(self, other_table):
        """Add observations from another time table at the end of this table

        Fields in only one of the tables are handled by filling with empty strings.

        TODO: Make sure time scale is handled correctly

        Args:
            other_table (TimeTable):   The other table.
        """
        self._data = time.Time(
            np.hstack((self._data.utc.jd1, other_table.data.utc.jd1)),
            np.hstack((self._data.utc.jd2, other_table.data.utc.jd2)),
            format="jd",
            scale="utc",
        )
        self._num_obs += other_table.num_obs
コード例 #4
0
def calculate_initial_values(eph):
    """Computing initial values for position and velocity in GCRS system

    This is for later use in orbit integration, from tables in the prediction files.  Use a lagrange polynomial in
    order to interpolate in the tables.

    Args:
        eph:  Dict containing ephemeris information

    Returns:
        eph:  Dict where the initial position and velocity is added
    """
    pos_gcrs = np.empty((3, 0))
    times = np.empty((0))
    table_of_positions = sorted(eph.data["positions"].items())
    mjd1, mjd2 = zip(*[t for t, d in table_of_positions])

    for pos_time, (_, data) in zip(
            time.Time(val=mjd1, val2=mjd2, format="mjd", scale="utc"),
            table_of_positions):
        diffsec = (pos_time.utc.datetime - eph.rundate).total_seconds()
        # Only look at points close to rundate (start of integration)
        # if abs(diffsec) > 4000:
        #    continue
        # Table given in ITRF coordinate system. Convert to GCRS, where the integration of the satellite orbit will
        # be done
        pos_gcrs = np.hstack(
            (pos_gcrs, np.transpose([pos_time.itrs2gcrs @ data["pos"]])))
        times = np.hstack((times, diffsec))

    log.info(
        "Interpolating data from prediction file in order to get initial pos/vel"
    )
    pos_gcrs_ip, vel_gcrs_ip = interpolation.interpolate_with_derivative(
        times,
        np.transpose(pos_gcrs),
        np.array([0.0]),
        kind="lagrange",
        window=10,
        bounds_error=False)
    eph["initial_pos"] = pos_gcrs_ip[0]
    eph["initial_vel"] = vel_gcrs_ip[0]
    return eph
コード例 #5
0
 def add(self, fieldname, val, scale, write_level=None, **kwargs):
     super().add(fieldname, write_level)
     self._data = time.Time(val, scale=scale, **kwargs)
     self._fields = [fieldname]
     self._units[fieldname] = scale  # Use time scale as unit, mainly for visualizing time scale