Skip to content
Snippets Groups Projects
Commit 932c3591 authored by jay's avatar jay
Browse files

Merge remote-tracking branch 'upstream/master' into win32

parents 369d308e 7aac3c31
No related branches found
No related tags found
No related merge requests found
...@@ -4,15 +4,30 @@ branches: ...@@ -4,15 +4,30 @@ branches:
version: '0.1.0.{build}' version: '0.1.0.{build}'
platform:
- x64
- x86
environment: environment:
matrix: matrix:
- PYTHON: "C:\\Miniconda35-x64\\Scripts\\activate.bat" - PYTHON: "C:\\Miniconda35-x64\\Scripts\\activate.bat"
PYTHON_VERSION: 3.5 PYTHON_VERSION: 3.5
- PYTHON: "C:\\Miniconda36-x64\\Scripts\\activate.bat" - PYTHON: "C:\\Miniconda36-x64\\Scripts\\activate.bat"
PYTHON_VERSION: 3.6 PYTHON_VERSION: 3.6
- PYTHON: "C:\\Miniconda35\\Scripts\\activate.bat"
PYTHON_VERSION: 3.5
- PYTHON: "C:\\Miniconda36\\Scripts\\activate.bat"
platform: matrix:
- x64 exclude:
- PYTHON: "C:\\Miniconda35-x64\\Scripts\\activate.bat"
platform: x86
- PYTHON: "C:\\Miniconda36-x64\\Scripts\\activate.bat"
platform: x86
- PYTHON: "C:\\Miniconda35\\Scripts\\activate.bat"
platform: x64
- PYTHON: "C:\\Miniconda36\\Scripts\\activate.bat"
platform: x64
configuration: configuration:
- Release - Release
...@@ -26,7 +41,7 @@ install: ...@@ -26,7 +41,7 @@ install:
- cmd: activate test_env - cmd: activate test_env
- cmd: conda config --add channels conda-forge - cmd: conda config --add channels conda-forge
- cmd: conda install -c conda-forge pvl protobuf gdal numpy pandas sqlalchemy pyyaml networkx affine h5py scipy - cmd: conda install -c conda-forge pvl protobuf gdal numpy pandas sqlalchemy pyyaml networkx affine h5py scipy
- cmd: conda install pytest-cov - cmd: conda install -c conda-forge pytest pytest-cov
# https://pythonhosted.org/CodeChat/appveyor.yml.html # https://pythonhosted.org/CodeChat/appveyor.yml.html
- cmd: python -m pip install -U pip - cmd: python -m pip install -U pip
- cmd: python -m easy_install -U setuptools - cmd: python -m easy_install -U setuptools
......
This diff is collapsed.
<<<<<<< HEAD
import math import math
=======
>>>>>>> upstream/master
import numpy as np import numpy as np
import pandas as pd import pandas as pd
...@@ -44,3 +47,49 @@ def read_gpf(input_data): ...@@ -44,3 +47,49 @@ def read_gpf(input_data):
assert int(cnt) == len(df) assert int(cnt) == len(df)
return df return df
<<<<<<< HEAD
=======
def save_gpf(df, output_file):
"""
Write a socet gpf file from a gpf-defined pandas dataframe
Parameters
----------
df : pd.DataFrame
Pandas DataFrame
output_file : str
path to the output data file
Returns
-------
int : success value
0 = success, 1 = errors
"""
# Check that file can be opened
try:
outGPF = open(output_file, 'w', newline='\r\n')
except:
print ('Unable to open output gpf file: {0}'.format(output_file))
return 1
#grab number of rows in pandas dataframe
numpts = len(df)
#Output gpf header
outGPF.write('GROUND POINT FILE\n')
outGPF.write('{0}\n'.format(numpts))
outGPF.write('point_id,stat,known,lat_Y_North,long_X_East,ht,sig(3),res(3)\n')
for index,row in df.iterrows():
#Output coordinates to gpf file
outGPF.write('{0} {1} {2}\n'.format(row['point_id'], row['stat'], row['known']))
outGPF.write('{0} {1} {2}\n'.format(row['lat_y_North'], row['long_X_East'], row['ht']))
outGPF.write('{0} {1} {2}\n'.format(row['sigma0'], row['sigma1'], row['sigma2']))
outGPF.write('{0} {1} {2}\n\n'.format(row['res0'], row['res1'], row['res2']))
outGPF.close()
return 0
>>>>>>> upstream/master
import filecmp
import numpy as np import numpy as np
import pandas as pd import pandas as pd
from pandas.util.testing import assert_frame_equal from pandas.util.testing import assert_frame_equal
from plio.io.io_gpf import read_gpf from plio.io.io_gpf import read_gpf
from plio.io.io_gpf import save_gpf
from plio.examples import get_path from plio.examples import get_path
import pytest import pytest
...@@ -10,6 +13,9 @@ import pytest ...@@ -10,6 +13,9 @@ import pytest
@pytest.fixture @pytest.fixture
def insight_gpf(): def insight_gpf():
return get_path('InSightE08_XW.gpf') return get_path('InSightE08_XW.gpf')
@pytest.fixture
def out_insight_gpf():
return get_path('out_InSightE08_XW.gpf')
@pytest.fixture() @pytest.fixture()
def insight_expected(): def insight_expected():
...@@ -19,3 +25,9 @@ def insight_expected(): ...@@ -19,3 +25,9 @@ def insight_expected():
def test_read_gfp(gpf, expected): def test_read_gfp(gpf, expected):
df = read_gpf(gpf) df = read_gpf(gpf)
assert_frame_equal(df, expected) assert_frame_equal(df, expected)
@pytest.mark.parametrize('gpf, out_gpf', [(insight_gpf(),out_insight_gpf())])
def test_write_gfp(gpf, out_gpf):
df = read_gpf(gpf)
val = save_gpf(df, out_gpf)
assertTrue(filecmp.cmp(gpf, out_gpf, shallow=True), "save_gpf does not create an equal file.")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment