diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index bda5551e57fa11e8cf1cfd53fdaa95f498cccd0a..0000000000000000000000000000000000000000 --- a/.travis.yml +++ /dev/null @@ -1,80 +0,0 @@ -language: generic -sudo: false - -branches: - only: - - master - -os: - - linux - - osx - -env: - - PYTHON_VERSION=3.6 HAS_GDAL=true - - PYTHON_VERSION=3.6 HAS_GDAL=false - - PYTHON_VERSION=3.7 HAS_GDAL=true - - PYTHON_VERSION=3.7 HAS_GDAL=false - - PYTHON_VERSION=3.8 HAS_GDAL=true - - PYTHON_VERSION=3.8 HAS_GDAL=false -before_install: - # We do this conditionally because it saves us some downloading if the - # version is the same. - - if [ "$TRAVIS_OS_NAME" == "linux" ]; then - wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; - else - curl -o miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh; - fi - - bash miniconda.sh -b -p $HOME/miniconda - - export PATH="$HOME/miniconda/bin:$PATH" - - hash -r - - conda config --set always_yes yes --set changeps1 no - - conda update -q conda - # Useful for debugging any issues with conda - - conda info -a - # Create the env - - conda create -q -n test python=$PYTHON_VERSION - - source activate test - # https://github.com/travis-ci/travis-ci/issues/8982 - - python -c "import fcntl; fcntl.fcntl(1, fcntl.F_SETFL, 0)" - -install: - - conda config --add channels usgs-astrogeology - - conda config --add channels conda-forge - - if $HAS_GDAL; then - conda env update -n test -f environment.yml; - else - conda env update -n test -f environment_noGDAL.yml; - fi - -script: - - pytest --cov=plio - -after_success: - - coveralls - # Need to do the build in the root - - source deactivate - - conda install -q conda-build anaconda-client - - conda config --set anaconda_upload no - - travis_wait conda build recipe -q - - travis_wait builddir=(`conda build recipe --output`) - - | - if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then - anaconda -t="$CONDA_UPLOAD_TOKEN" upload -l dev --force $builddir; - fi - - # Docs to gh-pages - - source activate test # Reactivate the env to have all deps installed. - - pip install travis-sphinx - - travis-sphinx build --source=docs --nowarn # The sphinx build script - - travis-sphinx deploy - -notifications: - webhooks: - on_success: always - on_failure: always - on_start: never - email: - recipients: - - jlaura@usgs.gov - on_success: always - on_failure: always diff --git a/environment.yml b/environment.yml index ffffa37145d7a0fd6c76cf4b93059e54f3feab6f..f0394f47df2c28e7ae5aef73c14cf47f4568945d 100644 --- a/environment.yml +++ b/environment.yml @@ -8,7 +8,7 @@ dependencies: - numpy - pyproj - h5py - - pvl + - pvl >= 1.0 - scipy - protobuf - affine diff --git a/plio/io/io_controlnetwork.py b/plio/io/io_controlnetwork.py index a10652e2cda82c6c6fed226ab2983187f16c844b..75196b5040c0062903115a93e2500fb0d5b4d60c 100644 --- a/plio/io/io_controlnetwork.py +++ b/plio/io/io_controlnetwork.py @@ -335,6 +335,11 @@ class IsisStore(object): #point_spec.id = _set_pid(i) point_spec.id = _set_pid(i) point_spec.type = g.iloc[0].pointType + try: + point_spec.referenceIndex = g.iloc[0].referenceIndex + except: + warnings.warn(f'Unable to identify referenceIndex for point {point_spec.id}. Defaulting to index 0.') + point_spec.referenceIndex = 0 for attr, attrtype in self.point_attrs: # Un-mangle common attribute names between points and measures df_attr = self.point_field_map.get(attr, attr) @@ -356,8 +361,6 @@ class IsisStore(object): else: setattr(point_spec, attr, attrtype(g.iloc[0][df_attr])) - # The reference index should always be the image with the lowest index - point_spec.referenceIndex = 0 # A single extend call is cheaper than many add calls to pack points measure_iterable = [] for node_id, m in g.iterrows(): diff --git a/plio/io/tests/test_io_controlnetwork.py b/plio/io/tests/test_io_controlnetwork.py index 7c4f23c5313bdc76b6e24bde0eb987cbbd2ce5d0..134206ae14aaec2b93c10045a78995cebcb6113c 100644 --- a/plio/io/tests/test_io_controlnetwork.py +++ b/plio/io/tests/test_io_controlnetwork.py @@ -72,15 +72,16 @@ def cnet_dataframe(tmpdir): serials = {i:'APOLLO15/METRIC/{}'.format(j) for i, j in enumerate(serial_times.values())} columns = ['id', 'pointType', 'serialnumber', 'measureType', 'sample', 'line', 'image_index', 'pointLog', 'measureLog', - 'aprioriCovar'] + 'aprioriCovar', 'referenceIndex'] data = [] for i in range(npts): aprioriCovar = None if i == npts - 1: aprioriCovar = np.ones((2,3)) - data.append((i, 2, serials[0], 2, 0, 0, 0, [], [], aprioriCovar)) - data.append((i, 2, serials[1], 2, 0, 0, 1, [], [io_controlnetwork.MeasureLog(2, 0.5)],aprioriCovar)) + reference_idx = i % 2 + data.append((i, 2, serials[0], 2, 0, 0, 0, [], [], aprioriCovar,reference_idx)) + data.append((i, 2, serials[1], 2, 0, 0, 1, [], [io_controlnetwork.MeasureLog(2, 0.5)],aprioriCovar, reference_idx)) df = pd.DataFrame(data, columns=columns) @@ -121,6 +122,9 @@ def test_create_point(cnet_dataframe, tmpdir): point_protocol.ParseFromString(raw_point) assert str(i) == point_protocol.id assert 2 == point_protocol.type + + assert i % 2 == point_protocol.referenceIndex + if i == cnet_dataframe.npts - 1: assert point_protocol.aprioriCovar == [1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for j, m in enumerate(point_protocol.measures): @@ -128,6 +132,21 @@ def test_create_point(cnet_dataframe, tmpdir): assert 2 == m.type assert len(m.log) == j # Only the second measure has a message +def test_create_point_wo_reference_index(cnet_dataframe, tmpdir): + # cnet_dataframe has 5 points. Set the reference on one of those to be + # the second measure. + reference_idx = [0,0,0,0,0,0,0,0,0,0] + new_cnet_dataframe = cnet_dataframe.drop(columns='referenceIndex') + cnet_file = tmpdir.join('test_w_reference.net') + + # Check that the warn is raised properly + with pytest.warns(UserWarning, match='Unable to identify referenceIndex (.*)'): + io_controlnetwork.to_isis(new_cnet_dataframe, cnet_file, mode='wb', targetname='Moon') + + # Check that nothing in == zeros out + test_cnet = io_controlnetwork.from_isis(cnet_file) + assert (test_cnet.referenceIndex == reference_idx).all() + def test_create_pvl_header(cnet_dataframe, tmpdir): with open(tmpdir.join('test.net'), 'rb') as f: pvl_header = pvl.load(f) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 2d2d3df4952e2c56865ab672e3f50a13d51305d1..f4e22459812c3d5e2cbbfc06b4ea16f81c37b0e1 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -36,7 +36,7 @@ requirements: - python - setuptools - numpy - - pvl + - pvl >= 1.0 - protobuf - gdal - icu diff --git a/setup.py b/setup.py index 38dc5f64145b77bddb2c32b08f8c4e6dcf86711d..c0ba904784d96b854db48b83dad1c12e6f3891ec 100644 --- a/setup.py +++ b/setup.py @@ -8,8 +8,8 @@ with open('README.md', 'r') as f: def setup_package(): setup( name = "plio", - version = '1.2.4', - author = "Jay Laura", + version = '1.3.0', + author = "USGS Astrogeology", author_email = "jlaura@usgs.gov", description = ("I/O API to support planetary data formats."), long_description = long_description,