Commit 3477f2b2 authored by Tyler Thatcher's avatar Tyler Thatcher
Browse files

Added covariance matrix and generic paths

parents bebb21e5 dbc1207a
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ install:
  - conda config --add channels conda-forge
  - conda install -q gdal h5py pandas sqlalchemy pyyaml networkx affine protobuf scipy pvl
  # Development installation
  - conda install -q pytest pytest-cov sh
  - conda install -q pytest pytest-cov sh coveralls nbsphinx

script:
  - pytest --cov=plio
@@ -51,7 +51,8 @@ after_success:
  - conda build --token $CONDA_UPLOAD_TOKEN --python $PYTHON_VERSION recipe -q

  # Docs to gh-pages
  - source activate test_env  # Reactivate the env to have all deps installed.
  - 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 --branches=dev

bin/Socetnet2ISIS.py

deleted100644 → 0
+0 −49
Original line number Diff line number Diff line
import os
import numpy as np

# Reads a .atf file and outputs all of the
# .ipf, .gpf, .sup, .prj, and path to locate the
# .apf file (should be the same as all others)
def read_atf(atf_file):
    with open(atf_file) as f:

        files = []
        ipf = []
        sup = []
        files_dict = []

        # Grabs every PRJ, GPF, SUP, and IPF image from the ATF file
        for line in f:
            if line[-4:-1] == 'prj' or line[-4:-1] == 'gpf' or line[-4:-1] == 'sup' or line[-4:-1] == 'ipf' or line[-4:-1] == 'atf':
                files.append(line)

        files = np.array(files)

        # Creates appropriate arrays for certain files in the right format
        for file in files:
            file = file.strip()
            file = file.split(' ')

            # Grabs all the IPF files
            if file[1].endswith('.ipf'):
                ipf.append(file[1])

            # Grabs all the SUP files
            if file[1].endswith('.sup'):
                sup.append(file[1])

            files_dict.append(file)

        # Creates a dict out of file lists for GPF, PRJ, IPF, and ATF
        files_dict = (dict(files_dict))

        # Sets the value of IMAGE_IPF to all IPF images
        files_dict['IMAGE_IPF'] = ipf

        # Sets the value of IMAGE_SUP to all SUP images
        files_dict['IMAGE_SUP'] = sup

        # Sets the value of PATH to the path of the ATF file
        files_dict['PATH'] = os.path.dirname(os.path.abspath(atf_file))

        return files_dict

bin/socet2isis

0 → 100644
+92 −0
Original line number Diff line number Diff line
#!/usr/bin/env python
import argparse
import os
import sys
import warnings
import csv
import numpy as np

from plio.examples import get_path
from plio.io.io_bae import read_atf, read_gpf, read_ipf
from plio.spatial.transformations import *
import plio.io.io_controlnetwork as cn

import pandas as pd

def parse_args():
    parser = argparse.ArgumentParser()

    # Add args here
    parser.add_argument('at_file', help='Path to the .atf file for a project.')
    parser.add_argument('cub_file_path', help='Path to cube files related to ipf files.')
    parser.add_argument('cub_ipf_map', help='Path to map file for all ipfs and cubes.')
    parser.add_argument('--outpath', help='Directory for the control network to be output to.',
                                        required = False)

    return parser.parse_args()


def main(args):
    # Setup the at_file, path to cubes, and control network out path
    at_file = args.at_file
    cnet_out = os.path.split(os.path.splitext(at_file)[0])[1]
    cub_path = args.cub_file_path

    if(args.outpath):
        outpath = args.outpath
    else:
        outpath = os.path.split(at_file)[0]

    with open(args.cub_ipf_map) as cub_ipf_map:
        reader = csv.reader(cub_ipf_map, delimiter = ',')
        image_dict = dict([(row[0], row[1]) for row in reader])

    # Read in and setup the atf dict of information
    atf_dict = read_atf(at_file)

    # Get the gpf and ipf files using atf dict
    gpf_file = os.path.join(atf_dict['PATH'], atf_dict['GP_FILE']);
    ipf_list = [os.path.join(atf_dict['PATH'], i) for i in atf_dict['IMAGE_IPF']]

    # Read in the gpf file and ipf file(s) into seperate dataframes
    gpf_df = read_gpf(gpf_file)
    ipf_df = read_ipf(ipf_list)

    # Check for differences between point ids using each dataframes
    # point ids as a reference
    gpf_pt_idx = pd.Index(pd.unique(gpf_df['point_id']))
    ipf_pt_idx = pd.Index(pd.unique(ipf_df['pt_id']))

    point_diff = ipf_pt_idx.difference(gpf_pt_idx)

    if len(point_diff) != 0:
        warnings.warn("The following points found in ipf files missing from gpf file: " +
        "\n\n{}\n\n".format("\n".join(point_diff)) +
        "Continuing, but these points will be missing from the control " +
        "network.", stacklevel=3)

    # Merge the two dataframes on their point id columns
    socet_df = ipf_df.merge(gpf_df, left_on='pt_id', right_on='point_id')

    # Apply the transformations
    apply_transformations(atf_dict, socet_df)

    # Define column remap for socet dataframe
    column_remap = {'l.': 'y', 's.': 'x',
                    'res_l': 'LineResidual', 'res_s': 'SampleResidual', 'known': 'Type',
                    'lat_Y_North': 'AprioriY', 'long_X_East': 'AprioriX', 'ht': 'AprioriZ',
                    'sig0': 'AprioriLatitudeSigma', 'sig1': 'AprioriLongitudeSigma',
                    'sig2': 'AprioriRadiusSigma'}

    # Rename the columns using the column remap above
    socet_df.rename(columns = column_remap, inplace=True)

    images = pd.unique(socet_df['ipf_file'])

    serial_dict = serial_numbers(image_dict, cub_path)

    # creates the control network
    cn.to_isis(os.path.join(outpath, cnet_out + '.net'), socet_df, serial_dict)

if __name__ == '__main__':
    main(parse_args())
(56 KiB)

File changed.

No diff preview for this file type.

+72 −0
Original line number Diff line number Diff line
Object = IsisCube
  Object = Core
    StartByte   = 65537
    Format      = Tile
    TileSamples = 1000
    TileLines   = 1024

    Group = Dimensions
      Samples = 5000
      Lines   = 7168
      Bands   = 1
    End_Group

    Group = Pixels
      Type       = SignedWord
      ByteOrder  = Lsb
      Base       = 0.0
      Multiplier = 1.0
    End_Group
  End_Object

  Group = Instrument
    SpacecraftName        = Mars_Reconnaissance_Orbiter
    InstrumentId          = CTX
    TargetName            = Mars
    MissionPhaseName      = PSP
    StartTime             = 2008-09-17T05:08:10.820
    SpacecraftClockCount  = 0906095311:038
    OffsetModeId          = 196/190/181
    LineExposureDuration  = 1.877 <MSEC>
    FocalPlaneTemperature = 293.4 <K>
    SampleBitModeId       = SQROOT
    SpatialSumming        = 1
    SampleFirstPixel      = 0
  End_Group

  Group = Archive
    DataSetId           = MRO-M-CTX-2-EDR-L0-V1.0
    ProductId           = B01_010045_1878_XN_07N205W
    ProducerId          = MRO_CTX_TEAM
    ProductCreationTime = 2009-04-13T19:24:46
    OrbitNumber         = 10045
  End_Group

  Group = BandBin
    FilterName = BroadBand
    Center     = 0.65 <micrometers>
    Width      = 0.15 <micrometers>
  End_Group

  Group = Kernels
    NaifFrameCode             = -74021
    LeapSecond                = $base/kernels/lsk/naif0012.tls
    TargetAttitudeShape       = $base/kernels/pck/pck00009.tpc
    TargetPosition            = (Table, $base/kernels/spk/de405.bsp)
    InstrumentPointing        = (Table,
                                 $mro/kernels/ck/mro_sc_psp_080916_080922.bc,
                                 $mro/kernels/fk/mro_v15.tf)
    Instrument                = Null
    SpacecraftClock           = $mro/kernels/sclk/MRO_SCLKSCET.00064.65536.tsc
    InstrumentPosition        = (Table, $mro/kernels/spk/mro_psp8.bsp)
    InstrumentAddendum        = $mro/kernels/iak/mroctxAddendum005.ti
    ShapeModel                = $base/dems/molaMarsPlanetaryRadius0005.cub
    InstrumentPositionQuality = Reconstructed
    InstrumentPointingQuality = Reconstructed
    CameraVersion             = 1
  End_Group
End_Object

Object = Label
  Bytes = 65536
End_Object
Loading