Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial implementation of multispectral isds #632

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ set(CMAKE_CXX_STANDARD 11)
option(ALE_BUILD_LOAD "If the C++ Python load interface should be built." ON)
option(ALE_USE_EXTERNAL_JSON "If an external nlohmann JSON library should be used" ON)
option(ALE_USE_EXTERNAL_EIGEN "If an external EIGEN library should be used" ON)
option(ALE_USE_EXTERNAL_HIGHFIVE "If an external HIGHFIVE library should be used" ON)

# Third Party Dependencies
if(ALE_USE_EXTERNAL_JSON)
Expand All @@ -39,6 +40,12 @@ else()
${CMAKE_CURRENT_SOURCE_DIR}/eigen)
endif()

if(ALE_USE_EXTERNAL_HIGHFIVE)
find_package(HDF5 COMPONENTS C CXX)
find_package(highfive REQUIRED)
endif()


if(ALE_BUILD_LOAD)
# If there is an Anaconda environment activated, search that for Python first
if(EXISTS $ENV{CONDA_PREFIX})
Expand Down Expand Up @@ -141,4 +148,4 @@ if(ALE_BUILD_DOCS)
add_subdirectory ("docs")
else()
message(STATUS "Skipping Docs")
endif()
endif()
4 changes: 3 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: ale
channels:
- conda-forge
- default

dependencies:
- cmake>=3.15
- pytest
- eigen
- gdal
- highfive
- jupyter
- nlohmann_json
- numpy
Expand All @@ -23,3 +23,5 @@ dependencies:
- networkx
- breathe
- brotli
- h5py
- pip
58 changes: 58 additions & 0 deletions include/ale/Isd.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <vector>
#include <map>

#include <highfive/highfive.hpp>
#include <nlohmann/json.hpp>

#include "ale/Distortion.h"
Expand Down Expand Up @@ -68,6 +69,63 @@ namespace ale {
Orientations inst_pointing;
Orientations body_rotation;
};


class MultiSpectralIsd {
public:

MultiSpectralIsd(HighFive::File);

std::vector<std::string> usgscsm_name_model;
std::vector<std::string> name_platform;
std::vector<std::string> image_id;
std::vector<std::string> name_sensor;

std::vector<double> semi_major;
std::vector<double> semi_minor;

std::vector<double> detector_sample_summing;
std::vector<double> detector_line_summing;

std::vector<double> focal_length;
std::vector<double> focal_uncertainty;

std::vector<double> detector_center_line;
std::vector<double> detector_center_sample;

// should probably be ints
std::vector<double> starting_detector_line;
std::vector<double> starting_detector_sample;

std::vector<std::vector<double>> focal2pixel_line;
std::vector<std::vector<double>> focal2pixel_sample;

// maybe change
std::vector<DistortionType> distortion_model;
std::vector<std::vector<double>> distortion_coefficients;

std::vector<unsigned int> image_lines;
std::vector<unsigned int> image_samples;

std::vector<double> max_reference_height;
std::vector<double> min_reference_height;

std::vector<std::vector<std::vector<double>>> line_scan_rate;

std::vector<double> starting_ephemeris_time;
std::vector<double> center_ephemeris_time;

std::vector<nlohmann::json> naif_keywords;

std::vector<PositionInterpolation> interpMethod;

std::vector<States> inst_pos;
std::vector<States> sun_pos;

std::vector<Orientations> inst_pointing;
std::vector<Orientations> body_rotation;
};
}


#endif
48 changes: 47 additions & 1 deletion include/ale/Util.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef ALE_UTIL_H
#define ALE_UTIL_H

#include <highfive/highfive.hpp>
#include <string>
#include <nlohmann/json.hpp>

Expand All @@ -25,6 +26,17 @@ namespace ale {
return positions;
}

template<typename T>
std::vector<std::vector<T>> getMultiSpectralArray(HighFive::DataSet ds){
std::vector<std::vector<T>> data;
try {
ds.read(data);
} catch (...) {
throw std::runtime_error("Could not parse the hdf5 dataset");
}
return data;
}


PositionInterpolation getInterpolationMethod(nlohmann::json isd);
double getMinHeight(nlohmann::json isd);
Expand Down Expand Up @@ -65,9 +77,43 @@ namespace ale {

States getInstrumentPosition(nlohmann::json isd);
States getSunPosition(nlohmann::json isd);

Orientations getBodyRotation(nlohmann::json isd);
Orientations getInstrumentPointing(nlohmann::json isd);


std::vector<std::string> getSensorModelName(HighFive::File hdf5);
std::vector<std::string> getImageId(HighFive::File hdf5);
std::vector<std::string> getPlatformName(HighFive::File hdf5);
std::vector<std::string> getSensorName(HighFive::File hdf5);
std::vector<unsigned int> getTotalLines(HighFive::File hdf5);
std::vector<unsigned int> getTotalSamples(HighFive::File hdf5);
std::vector<double> getStartingTime(HighFive::File hdf5);
std::vector<double> getCenterTime(HighFive::File hdf5);
std::vector<std::vector<std::vector<double>>> getLineScanRate(HighFive::File hdf5);
std::vector<double> getSampleSumming(HighFive::File hdf5);
std::vector<double> getLineSumming(HighFive::File hdf5);
std::vector<double> getFocalLength(HighFive::File hdf5);
std::vector<double> getFocalLengthUncertainty(HighFive::File hdf5);
std::vector<std::vector<double>> getFocal2PixelLines(HighFive::File hdf5);
std::vector<std::vector<double>> getFocal2PixelSamples(HighFive::File hdf5);
std::vector<double> getDetectorCenterLine(HighFive::File hdf5);
std::vector<double> getDetectorCenterSample(HighFive::File hdf5);
std::vector<double> getDetectorStartingLine(HighFive::File hdf5);
std::vector<double> getDetectorStartingSample(HighFive::File hdf5);
std::vector<double> getMinHeight(HighFive::File hdf5);
std::vector<double> getMaxHeight(HighFive::File hdf5);
std::vector<double> getSemiMajorRadius(HighFive::File hdf5);
std::vector<double> getSemiMinorRadius(HighFive::File hdf5);
std::vector<DistortionType> getDistortionModel(HighFive::File hdf5);
std::vector<std::vector<double>> getDistortionCoeffs(HighFive::File hdf5);
std::vector<PositionInterpolation> getInterpolationMethod(HighFive::File hdf5);
std::vector<Orientations> getBodyRotation(HighFive::File hdf5);
std::vector<std::vector<Vec3d>> getVec3dArray(HighFive::DataSet ds);
std::vector<std::vector<Rotation>> getQuatArray(HighFive::DataSet ds);

std::vector<States> getInstrumentPosition(HighFive::File hdf5);
std::vector<States> getSunPosition(HighFive::File hdf5);
std::vector<Orientations> getInstrumentPointing(HighFive::File hdf5);
}

#endif
Loading
Loading