Exemplo n.º 1
0
def build_pointmass_normals(groops_bin,
                            mjd_start,
                            mjd_end,
                            grid_file,
                            output_path,
                            leo=False,
                            compute_goce=False,
                            goce_only=False):
    year, month, day = date_functions.mjd2ymd(mjd_start)
    gridi = np.genfromtxt(grid_file, skip_header=2)
    gridi = np.array(gridi, ndmin=2)
    point_count = gridi.shape[0]
    xml_file = pkg_resources.resource_filename(
        'picasso.data', 'GROOPS/build_pointmass_normals_grace_only.xml')
    if compute_goce and goce_only:
        xml_file = pkg_resources.resource_filename(
            'picasso.data', 'GROOPS/build_pointmass_normals_goce_only.xml')
    elif compute_goce:
        xml_file = pkg_resources.resource_filename(
            'picasso.data', 'GROOPS/build_pointmass_normals_grace_goce.xml')
    # system string template
    sys_str = ""
    sys_str += "xxx_grops_bin"
    sys_str += " -g timeStart=xxx_mjd_time_start"
    sys_str += " -g timeEnd=xxx_mjd_time_end"
    sys_str += " -g numberOfPoints=xxx_number_of_points"
    sys_str += " -g inputfileGrid=xxx_grid_file"
    sys_str += " -g outputfileNormalequationGraceDat=xxx_output_path_grace_xxxx-xx-normals.dat"
    sys_str += " -g outputfileNormalequationGoceDat=xxx_output_path_goce_xxxx-xx-normals.dat"
    sys_str += " -g groopsPath=xxx_groops_path"
    sys_str += " xxx_xml_file 2>/dev/null"
    # replace placeholder
    sys_str_i = sys_str
    sys_str_i = sys_str_i.replace('xxx_grops_bin', groops_bin)
    sys_str_i = sys_str_i.replace('xxx_mjd_time_start', '%08.2f' % mjd_start)
    sys_str_i = sys_str_i.replace('xxx_mjd_time_end', '%08.2f' % mjd_end)
    sys_str_i = sys_str_i.replace('xxxx-xx', ('%4d-%02d' % (year, month)))
    sys_str_i = sys_str_i.replace('xxx_number_of_points', '%d' % point_count)
    sys_str_i = sys_str_i.replace('xxx_grid_file', grid_file)
    sys_str_i = sys_str_i.replace('xxx_output_path_', output_path + '/')
    sys_str_i = sys_str_i.replace('xxx_xml_file', xml_file)
    sys_str_i = sys_str_i.replace('xxx_groops_path', cg.data_path)
    # execute command if local, otherwise (if leo) return command string
    if not leo:
        ret = os.system(sys_str_i)
    else:
        ret = sys_str_i
    return ret
Exemplo n.º 2
0
def test_mjd2ymd():
    """
	Test if the function `mjd2ymd` correctly converts Modified Julian 
	dates into date (years, months, days) or not.        
	
	Reference: Meeus 1991 (ISBN:0943396352)
	"""
    years_true = [1858, 1980, 2006]
    months_true = [11, 1, 12]
    days_true = [17.0, 30.0, 19.0]
    mjd = [0.0, 44268.0, 54088.0]
    years_test, months_test, days_test = date_functions.mjd2ymd(mjd)
    assert years_test[0] == years_true[0]
    assert years_test[1] == years_true[1]
    assert years_test[2] == years_true[2]

    assert months_test[0] == months_true[0]
    assert months_test[1] == months_true[1]
    assert months_test[2] == months_true[2]

    assert days_test[0] == pytest.approx(days_true[0], 1e-5)
    assert days_test[1] == pytest.approx(days_true[1], 1e-5)
    assert days_test[2] == pytest.approx(days_true[2], 1e-5)