Exemplo n.º 1
0
    def test_vcv_cart2local_and_vcv_local2cart2_2X3(self):
        lat = 0.0
        lon = 0.0
        v_cart = np.array([
            [0.0, 0.0, 0.0],
            [0.0, 0.0, 0.0],
        ])

        with self.assertRaises(SystemExit):
            statistics.vcv_cart2local(v_cart, lat, lon)

        with self.assertRaises(SystemExit):
            statistics.vcv_local2cart(v_cart, lat, lon)
Exemplo n.º 2
0
def mga2020_to_mga94(zone, east, north, ell_ht=False, vcv=None):
    """
    Performs conformal transformation of Map Grid of Australia 2020 to Map Grid of Australia 1994 Coordinates
    using the reverse form of the GDA2020 Tech Manual v1.2 7 parameter similarity transformation parameters
    :param zone: Zone Number - 1 to 60
    :param east: Easting (m, within 3330km of Central Meridian)
    :param north: Northing (m, 0 to 10,000,000m)
    :param ell_ht: Ellipsoid Height (m) (optional)
    :param vcv: Optional 3*3 numpy array in local enu units to propagate tf uncertainty
    :return: MGA1994 Zone, Easting, Northing, Ellipsoid Height (if none provided, returns 0), and vcv matrix
    """
    lat, lon, psf, gridconv = grid2geo(zone, east, north)
    if ell_ht is False:
        ell_ht_in = 0
    else:
        ell_ht_in = ell_ht
    if vcv is not None:
        vcv = vcv_local2cart(vcv, lat, lon)
    x94, y94, z94 = llh2xyz(lat, lon, ell_ht_in)
    x20, y20, z20, vcv94 = conform7(x94, y94, z94, -gda94_to_gda2020, vcv=vcv)
    lat, lon, ell_ht_out = xyz2llh(x20, y20, z20)
    if vcv94 is not None:
        vcv94 = vcv_cart2local(vcv94, lat, lon)
    if ell_ht is False:
        ell_ht_out = 0
    hemisphere, zone20, east20, north20, psf, gridconv = geo2grid(lat, lon)
    return zone20, east20, north20, round(ell_ht_out, 4), vcv94
Exemplo n.º 3
0
    def test_vcv_local2cart_3X3(self):
        expected_result = np.array([[0.44517136, -1.15507667, 0.44844663],
                                    [-1.15507667, 2.95156126, -1.15249271],
                                    [0.44844663, -1.15249271, 0.46326737]])

        result = statistics.vcv_local2cart(vcv, lat, lon)

        np.testing.assert_almost_equal(expected_result, result)
        self.assertEqual(type(expected_result), type(result))
Exemplo n.º 4
0
    def test_vcv_cart2local_and_vcv_local2cart2_1X3(self):
        lat = 0.0
        lon = 0.0
        v_cart = np.array([
            [0.0],
            [0.0],
            [0.0],
        ])
        expected_result = np.array([
            [0.0, 0.0, 0.0],
            [0.0, 0.0, 0.0],
            [0.0, 0.0, 0.0],
        ])

        result_cart2local = statistics.vcv_cart2local(v_cart, lat, lon)
        result_local2cart = statistics.vcv_local2cart(v_cart, lat, lon)

        np.testing.assert_array_equal(expected_result, result_cart2local)
        np.testing.assert_array_equal(expected_result, result_local2cart)
        self.assertEqual(type(expected_result), type(result_cart2local))
        self.assertEqual(type(expected_result), type(result_local2cart))
Exemplo n.º 5
0
                    if 'IncreaseReduce' in s:
                        if (s['IncreaseOrReduce'] == 'Increase'
                                and enu[0, 0] > orig_enu[0, 0]
                                and enu[1, 1] > orig_enu[1, 1]
                                and enu[2, 2] > orig_enu[2, 2]):
                            cal_enu = enu + at_sd + to_sd
                        elif (s['IncreaseOrReduce'] == 'Reduce'
                              and enu[0, 0] < orig_enu[0, 0]
                              and enu[1, 1] < orig_enu[1, 1]
                              and enu[2, 2] < orig_enu[2, 2]):
                            cal_enu = enu + at_sd + to_sd

                if cal_enu.any != orig_enu.any:
                    #transform and apply to output file
                    vcv = vcv_local2cart(cal_enu, at_lat, at_lng)
                    new_vcv = ('\t\t\t<SigmaXX>' + str(vcv[0, 0]) +
                               '</SigmaXX>\n' + '\t\t\t<SigmaXY>' +
                               str(vcv[0, 1]) + '</SigmaXY>\n' +
                               '\t\t\t<SigmaXZ>' + str(vcv[0, 2]) +
                               '</SigmaXZ>\n' + '\t\t\t<SigmaYY>' +
                               str(vcv[1, 1]) + '</SigmaYY>\n' +
                               '\t\t\t<SigmaYZ>' + str(vcv[1, 2]) +
                               '</SigmaYZ>\n' + '\t\t\t<SigmaZZ>' +
                               str(vcv[2, 2]) + '</SigmaZZ>\n')

                    msr_out = (
                        msr_out.replace('<Sigma', '<!--Sigma').replace(
                            '</SigmaXX>', '</SigmaXX-->').replace(
                                '</SigmaXY>', '</SigmaXY-->').replace(
                                    '</SigmaXZ>', '</SigmaXZ-->').replace(
Exemplo n.º 6
0
    def test_vcv_local2cart_3X2(self):
        v_cart = np.zeros((3, 2))

        with self.assertRaises(ValueError):
            statistics.vcv_local2cart(v_cart, lat, lon)
Exemplo n.º 7
0
        def read_apu(apu_file, stns, read_metadata):
            """
            Function to consume DynAdjust *.apu file and read contents into a DynaApu object
            note: Variance matrix components are stored in XYZ rotation ONLY.
                      - ENU Variance matrix components are rotated back to XYZ.
                      - ENU Covariance block matrix components are rotated back to XYZ, at the position of the 'first' station.
            :param apu_file: input *.apu file
            :param stns: either None, or dictionary of station objects from earlier adj/xyz read
            :param read_metadata: True/False switch to read metadata from file, or carry across from earlier xyz/adj read
            :return: DynaApu object fields (dictionary of stations) apu options, metadata
            """

            with open(apu_file) as apu_fh:
                switches = Switches()
                switches.header = True
                rotate_vcv = False
                pu_line = None
                cov_count = 0

                version = None
                file_name = None
                file_date = None
                confidence_interval = None
                vcv_blocks = False
                variance_matrix_units = None
                full_covariance_matrix = None
                metadata = None

                # set xyz_stns switch true to add apu info to existing stns dictionary from earlier xyz/adj read
                if stns:
                    xyz_stns = True
                else:
                    xyz_stns = False
                    stns = {}

                for line_count, line in enumerate(apu_fh):

                    if switches.header:
                        version = pcommon.read_metadata(
                            line, 'Version:', version)
                        file_name = pcommon.read_metadata(
                            line, 'File name:', file_name)
                        file_date = pcommon.read_file_date(line, file_date)
                        confidence_interval = pcommon.read_metadata(
                            line, 'PU confidence interval',
                            confidence_interval)
                        variance_matrix_units = pcommon.read_metadata(
                            line, 'Variance matrix units ',
                            variance_matrix_units)
                        vcv_blocks = pcommon.read_metadata_tf(
                            line, 'Stations printed in blocks', vcv_blocks)
                        full_covariance_matrix = pcommon.read_metadata_tf(
                            line, 'Full covariance matrix',
                            full_covariance_matrix)

                        if "Positional uncertainty of adjusted station coordinates" in line:
                            pu_line = line_count + 5
                            switches.reset()
                            if variance_matrix_units == 'ENU':
                                rotate_vcv = True
                            if read_metadata:
                                metadata = DynaMetadata(epoch=None,
                                                        reference_frame=None,
                                                        geoid_model=None,
                                                        version=version)
                            apu_options = DynaApu.ApuOptions(
                                confidence_interval=confidence_interval,
                                variance_matrix_units=variance_matrix_units,
                                vcv_blocks=vcv_blocks,
                                full_covariance_matrix=full_covariance_matrix)

                    if pu_line:
                        if line_count == pu_line:
                            switches.stns = True

                    if switches.stns:
                        if line == '\n':
                            continue

                        if 'Block ' in line:
                            if len(line) < 30:
                                continue

                        if '-' * 30 in line:
                            continue

                        cols = line.split()
                        num_cols = len(cols)

                        # account for station names with spaces.
                        temp = line[0:20]
                        if temp != (' ' * 20):
                            num_cols = len(line[21:].split()) + 1

                        # Station variance line 1
                        if num_cols == 11:
                            stn = line[:20].strip()
                            lat = gc.hp2dms(float(line[23:36]))
                            lon = gc.hp2dms(float(line[38:51]))
                            hpu = float(line[51:62].strip())
                            vpu = float(line[62:73].strip())
                            smaj = float(line[73:86].strip())
                            smin = float(line[86:99].strip())
                            brg = float(line[99:112].strip())
                            vcv_11 = float(line[112:131].strip())
                            vcv_12 = float(line[131:150].strip())
                            vcv_13 = float(line[150:].strip())
                            continue

                        # Station variance line 2
                        elif num_cols == 2:
                            vcv_22 = float(line[131:150].strip())
                            vcv_23 = float(line[150:].strip())
                            continue

                        #  Station variance line 3
                        elif num_cols == 1:
                            vcv_33 = float(line[150:].strip())

                            vcv = np.array([
                                [vcv_11, vcv_12, vcv_13],
                                [vcv_12, vcv_22, vcv_23],
                                [vcv_13, vcv_23, vcv_33],
                            ])

                            if rotate_vcv:
                                vcv = gstat.vcv_local2cart(
                                    vcv, lat.dec(), lon.dec())

                            # update existing or create new station object
                            if xyz_stns:
                                stns[stn].hpu = hpu
                                stns[stn].vpu = vpu
                                stns[stn].vpu = vpu
                                stns[stn].smaj = smaj
                                stns[stn].smin = smin
                                stns[stn].brg = brg
                                stns[stn].vcv = vcv
                            else:
                                apu_stn = Station(name=stn,
                                                  con=None,
                                                  lat=lat,
                                                  lon=lon,
                                                  ehgt=None,
                                                  ohgt=None,
                                                  sd_e=None,
                                                  sd_n=None,
                                                  sd_u=None,
                                                  description=None,
                                                  hpu=hpu,
                                                  vpu=vpu,
                                                  smaj=smaj,
                                                  smin=smin,
                                                  brg=brg,
                                                  vcv=vcv,
                                                  covariances={})

                                stns[stn] = apu_stn

                        # covariance block information
                        if full_covariance_matrix:
                            if num_cols == 4:
                                cov_stn = line[:20].strip()
                                cov_11 = float(line[113:131].strip())
                                cov_12 = float(line[132:150].strip())
                                cov_13 = float(line[151:169].strip())
                                cov_count = 1

                            elif num_cols == 3:
                                cov_count += 1
                                if cov_count == 2:
                                    cov_21 = float(line[113:131].strip())
                                    cov_22 = float(line[132:150].strip())
                                    cov_23 = float(line[151:169].strip())
                                elif cov_count == 3:
                                    cov_31 = float(line[113:131].strip())
                                    cov_32 = float(line[132:150].strip())
                                    cov_33 = float(line[151:169].strip())

                                    cov = np.array([
                                        [cov_11, cov_12, cov_13],
                                        [cov_21, cov_22, cov_23],
                                        [cov_31, cov_32, cov_33],
                                    ])

                                    if rotate_vcv:
                                        cov = gstat.vcv_local2cart(
                                            cov, stns[stn].lat.dec(),
                                            stns[stn].lon.dec())

                                    if cov_stn not in stns[stn].covariances:
                                        stns[stn].covariances[cov_stn] = cov

            return stns, metadata, file_name, file_date, apu_options