Esempio n. 1
0
 def test_first_vel_corrn(self):
     params = first_vel_params(0.85)
     raw_obs_distance = 1117.8517
     obs_temperature = 6.8
     obs_pressure = 960.8
     obs_relative_humidity = 58.6
     correction = first_vel_corrn(raw_obs_distance, params, obs_temperature,
                                  obs_pressure, obs_relative_humidity)
     corrected_obs_distance = raw_obs_distance + correction
     self.assertEqual(round(corrected_obs_distance, 4), 1117.8618)
Esempio n. 2
0
 def test_first_vel_params(self):
     temperature = 12
     pressure = 1013.25
     relative_humidity = 60
     edm_wavelength = 0.850
     param_c = 281.781
     param_d = 79.393
     params_new = first_vel_params(edm_wavelength, temperature, pressure,
                                   relative_humidity)
     self.assertEqual(round(params_new[0], 3), param_c)
     self.assertEqual(round(params_new[1], 3), param_d)
Esempio n. 3
0
def gsi2msr(path, cfg_path=None):
    """
    Converts .gsi format survey observations to DNA v3 .msr for use with DynAdjust
    :param path: .gsi file path
    :param cfg_path: .gpy conversion configuration file
    :return: DNA v3 .msr file (same directory as source .fbk file)
    """
    gsi_project = gsi2class(readgsi(path))
    # Read config file
    if cfg_path is not None:
        cfg = readconfig(cfg_path)
        # Rename obs as per config file
        gsi_project = renameobs(cfg, gsi_project)
        # Remove obs as per config file
        gsi_project = removeobs(cfg, gsi_project)
        # Get First Velocity Correction Observations
        first_vel_obs = first_vel_cfg(cfg)
    else:
        first_vel_obs = None
    # Reduce observations in setups
    for setup in gsi_project:
        reduced_obs = reducesetup(setup.observation, strict=False, zerodist=False)
        setup.observation = reduced_obs
    # Perform First Velocity Correction
    if first_vel_obs is not None:
        # Use wavelength and standard atmospheric parameters to get Parameters C and D
        params = first_vel_params(first_vel_obs[0])
        for setup in gsi_project:
            corrected_obs = first_vel_observations(setup.observation,
                                                   params,
                                                   first_vel_obs[1],  # Observed Temperature
                                                   first_vel_obs[2],  # Observed Pressure
                                                   first_vel_obs[3])  # Observed Relative Humidity
            setup.observation = corrected_obs
    # Produce Measurement format data from setups
    msr_raw = []
    for setup in gsi_project:
        dna_dirset = dnaout_dirset(setup.observation, same_stdev=False)
        dna_va = dnaout_va(setup.observation, same_stdev=False)
        dna_sd = dnaout_sd(setup.observation)
        msr_raw.append(dna_dirset + dna_va + dna_sd)
    # Build msr header
    dircount = 0
    vacount = 0
    sdcount = 0
    for group in msr_raw:
        for line in group:
            if line.startswith('D'):
                dircount = 1
            elif line.startswith('V'):
                vacount += 1
            elif line.startswith('S'):
                sdcount += 1
    obscount = dircount + vacount + sdcount
    now = datetime(2020, 1, 1)
    date = (str(now.day).rjust(2, '0') + '.'
            + str(now.month).rjust(2, '0') + '.'
            + str(now.year))
    header = ('!#=DNA 3.01 MSR'.ljust(19)
              + date.ljust(19)
              + 'GDA94'.ljust(9)
              + date.ljust(18)
              + str(obscount))
    msr = [line for sublist in msr_raw for line in sublist]
    msr = [header] + msr
    # Output MSR File
    fn, ext = os.path.splitext(path)
    msr_fn = fn + '.msr'
    with open(msr_fn, 'w+') as msr_file:
        for line in msr:
            msr_file.write(line + '\n')
    # output will be dna msr file
    return msr
Esempio n. 4
0
def fbk2msr(path, cfg_path, strict=False, zerodist=False, same_stdev=False):
    """
    Converts .fbk format survey observations to DNA v3 .msr for use with DynAdjust
    :param path: .fbk file path
    :param cfg_path: .gpy DNA conversion config file
    :param strict: If True, all single-face Obs are ignored. If False, all
    single-face Obs are included and converted to Face Left
    :param zerodist: If True, Obs with Slope Distance of Zero are included.
    If False, these are ignored
    :param same_stdev:
    :return: DNA v3 .msr file (same directory as source .fbk file)
    """
    fbk_project = fbk2class(readfbk(path))
    # Read config file
    cfg = readconfig(cfg_path)
    # Rename obs as per config file
    fbk_project = renameobs(cfg, fbk_project)
    # Remove obs as per config file
    fbk_project = removeobs(cfg, fbk_project)
    # Get First Velocity Correction Observations
    first_vel_obs = first_vel_cfg(cfg)
    # Reduce observations in setups
    for setup in fbk_project:
        reduced_obs = reducesetup(setup.observation, strict, zerodist)
        setup.observation = reduced_obs
    # Perform First Velocity Correction
    if first_vel_obs is not None:
        # Use wavelength and standard atmospheric parameters to get Parameters C and D
        params = first_vel_params(first_vel_obs[0])
        for setup in fbk_project:
            corrected_obs = first_vel_observations(
                setup.observation,
                params,
                first_vel_obs[1],  # Observed Temperature
                first_vel_obs[2],  # Observed Pressure
                first_vel_obs[3])  # Observed Relative Humidity
            setup.observation = corrected_obs
    # Produce Measurement format data from setups
    msr_raw = []
    for setup in fbk_project:
        dna_dirset = dnaout_dirset(setup.observation, same_stdev)
        dna_va = dnaout_va(setup.observation, same_stdev)
        dna_sd = dnaout_sd(setup.observation)
        msr_raw.append(dna_dirset + dna_va + dna_sd)
    # Build msr header
    dircount = 0
    vacount = 0
    sdcount = 0
    for group in msr_raw:
        for line in group:
            if line.startswith('D'):
                dircount = 1
            elif line.startswith('V'):
                vacount += 1
            elif line.startswith('S'):
                sdcount += 1
    obscount = dircount + vacount + sdcount
    day, month, year = fbkdate(path)
    date = day + '.' + month + '.' + year
    header = ('!#=DNA 3.01 MSR'.ljust(19) + date.ljust(19) + 'GDA94'.ljust(9) +
              date.ljust(18) + str(obscount))
    msr = [line for sublist in msr_raw for line in sublist]
    msr = [header] + msr
    # Output MSR File
    fn, ext = os.path.splitext(path)
    msr_fn = fn + '.msr'
    with open(msr_fn, 'w+') as msr_file:
        for line in msr:
            msr_file.write(line + '\n')
    # output will be dna msr file
    return msr