repo
stringlengths
1
152
file
stringlengths
15
205
code
stringlengths
0
41.6M
file_length
int64
0
41.6M
avg_line_length
float64
0
1.81M
max_line_length
int64
0
12.7M
extension_type
stringclasses
90 values
null
AICP-main/veins/src/veins/modules/world/traci/trafficLight/TraCITrafficLightProgram.cc
// // Copyright (C) 2015-2018 Dominik Buse <[email protected]> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #include "veins/modules/world/traci/trafficLight/TraCITrafficLightProgram.h" using veins::TraCITrafficLightProgram; bool TraCITrafficLightProgram::Phase::isGreenPhase() const { // implementation taken from SUMO MSPhaseDefinition.cc if (state.find_first_of("gG") == std::string::npos) { return false; } if (state.find_first_of("yY") != std::string::npos) { return false; } return true; } TraCITrafficLightProgram::TraCITrafficLightProgram(std::string id) : id(id) , logics() { } void TraCITrafficLightProgram::addLogic(const Logic& logic) { logics[logic.id] = logic; } TraCITrafficLightProgram::Logic TraCITrafficLightProgram::getLogic(const std::string& lid) const { return logics.at(lid); } bool TraCITrafficLightProgram::hasLogic(const std::string& lid) const { return logics.find(lid) != logics.end(); }
1,782
29.220339
96
cc
null
AICP-main/veins/src/veins/modules/world/traci/trafficLight/TraCITrafficLightProgram.h
// // Copyright (C) 2015-2018 Dominik Buse <[email protected]> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include <string> #include <vector> #include <map> #include "veins/veins.h" using omnetpp::simtime_t; namespace veins { class VEINS_API TraCITrafficLightProgram { public: struct Phase { simtime_t duration; std::string state; simtime_t minDuration; simtime_t maxDuration; std::vector<int32_t> next; std::string name; bool isGreenPhase() const; }; struct Logic { std::string id; int32_t currentPhase; std::vector<Phase> phases; int32_t type; // currently unused, just 0 int32_t parameter; // currently unused, just 0 }; TraCITrafficLightProgram(std::string id = ""); void addLogic(const Logic& logic); TraCITrafficLightProgram::Logic getLogic(const std::string& lid) const; bool hasLogic(const std::string& lid) const; private: std::string id; std::map<std::string, TraCITrafficLightProgram::Logic> logics; }; struct VEINS_API TraCITrafficLightLink { std::string incoming; std::string outgoing; std::string internal; }; } // namespace veins
2,019
27.055556
76
h
null
AICP-main/veins/src/veins/modules/world/traci/trafficLight/logics/TraCITrafficLightAbstractLogic.cc
// // Copyright (C) 2015-2018 Dominik Buse <[email protected]> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #include "veins/modules/world/traci/trafficLight/logics/TraCITrafficLightAbstractLogic.h" using veins::TraCITrafficLightAbstractLogic; using namespace omnetpp; TraCITrafficLightAbstractLogic::TraCITrafficLightAbstractLogic() : cSimpleModule() , switchTimer(nullptr) { } TraCITrafficLightAbstractLogic::~TraCITrafficLightAbstractLogic() { cancelAndDelete(switchTimer); } void TraCITrafficLightAbstractLogic::initialize() { switchTimer = new cMessage("trySwitch"); } void TraCITrafficLightAbstractLogic::handleMessage(cMessage* msg) { if (msg->isSelfMessage()) { handleSelfMsg(msg); } else if (msg->arrivedOn("interface$i")) { TraCITrafficLightMessage* tlMsg = check_and_cast<TraCITrafficLightMessage*>(msg); // always check for changed switch time and (re-)schedule switch handler if so if (tlMsg->getChangedAttribute() == TrafficLightAtrributeType::SWITCHTIME) { // schedule handler right before the switch cancelEvent(switchTimer); // make sure the message is not scheduled to the past simtime_t nextTick = std::max(SimTime(std::stoi(tlMsg->getNewValue()), SIMTIME_MS), simTime()); scheduleAt(nextTick, switchTimer); } // defer further handling to subclass implementation handleTlIfMsg(tlMsg); } else if (msg->arrivedOn("applLayer$i")) { handleApplMsg(msg); } else { throw cRuntimeError("Unknown message arrived on %s", msg->getArrivalGate()->getName()); } } void TraCITrafficLightAbstractLogic::handleSelfMsg(cMessage* msg) { if (msg == switchTimer) { handlePossibleSwitch(); } }
2,593
33.131579
107
cc
null
AICP-main/veins/src/veins/modules/world/traci/trafficLight/logics/TraCITrafficLightAbstractLogic.h
// // Copyright (C) 2015-2018 Dominik Buse <[email protected]> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include "veins/veins.h" #include "veins/modules/messages/TraCITrafficLightMessage_m.h" namespace veins { using omnetpp::cMessage; using omnetpp::cSimpleModule; /** * Base class to simplify implementation of traffic light logics * * already provides multiplexing of different message types to message handlers and a * special handler to be executed right before the TraCI server performs a phase switch */ class VEINS_API TraCITrafficLightAbstractLogic : public cSimpleModule { public: TraCITrafficLightAbstractLogic(); ~TraCITrafficLightAbstractLogic() override; protected: cMessage* switchTimer; void initialize() override; void handleMessage(cMessage* msg) override; virtual void handleSelfMsg(cMessage* msg); virtual void handleApplMsg(cMessage* msg) = 0; virtual void handleTlIfMsg(TraCITrafficLightMessage* tlMsg) = 0; virtual void handlePossibleSwitch() = 0; }; } // namespace veins
1,860
32.232143
87
h
null
AICP-main/veins/src/veins/modules/world/traci/trafficLight/logics/TraCITrafficLightSimpleLogic.cc
// // Copyright (C) 2015-2018 Dominik Buse <[email protected]> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #include "veins/modules/world/traci/trafficLight/logics/TraCITrafficLightSimpleLogic.h" using veins::TraCITrafficLightSimpleLogic; Define_Module(veins::TraCITrafficLightSimpleLogic); void TraCITrafficLightSimpleLogic::handleApplMsg(cMessage* msg) { delete msg; // just drop it } void TraCITrafficLightSimpleLogic::handleTlIfMsg(TraCITrafficLightMessage* tlMsg) { delete tlMsg; // just drop it } void TraCITrafficLightSimpleLogic::handlePossibleSwitch() { // do nothing - just let it happen }
1,418
32
87
cc
null
AICP-main/veins/src/veins/modules/world/traci/trafficLight/logics/TraCITrafficLightSimpleLogic.h
// // Copyright (C) 2015-2018 Dominik Buse <[email protected]> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include "veins/veins.h" #include "veins/base/utils/FindModule.h" #include "veins/modules/world/traci/trafficLight/logics/TraCITrafficLightAbstractLogic.h" #include "veins/modules/world/traci/trafficLight/TraCITrafficLightInterface.h" namespace veins { class VEINS_API TraCITrafficLightSimpleLogic : public TraCITrafficLightAbstractLogic { public: using signalScheme = std::string; protected: void handleApplMsg(cMessage* msg) override; void handleTlIfMsg(TraCITrafficLightMessage* tlMsg) override; void handlePossibleSwitch() override; }; class VEINS_API TraCITrafficLightSimpleLogicAccess { public: TraCITrafficLightSimpleLogic* get(cModule* host) { TraCITrafficLightSimpleLogic* traci = FindModule<TraCITrafficLightSimpleLogic*>::findSubModule(host); ASSERT(traci); return traci; }; }; } // namespace veins
1,791
32.185185
109
h
LiDAR2LiDAR
LiDAR2LiDAR-master/geotransformer/experiments/geotransformer.3dmatch.stage4.gse.k3.max.oacl.stage2.sinkhorn/eval copy.sh
# if [ "$3" = "test" ]; then # python test.py --test_epoch=$1 --benchmark=$2 # fi # python eval.py --test_epoch=$1 --benchmark=$2 --method=lgr # for n in 250 500 1000 2500 5000; do # python eval.py --num_corr=$n --benchmark=$1 --method=lgr # done # python test.py --snapshot=../../weights/geotransformer-3dmatch.pth.tar --benchmark=3DLoMatch # python test.py --snapshot=../../weights/geotransformer-3dmatch.pth.tar --benchmark=3DMatch # python eval.py --benchmark=3DLoMatch --method=lgr # for n in 250 500 1000 2500 5000; do # python eval.py --num_corr=$n --benchmark=3DLoMatch --method=lgr # done # python eval.py --benchmark=3DLoMatch --method=ransac # for n in 250 500 1000 2500 5000; do # python eval.py --num_corr=$n --benchmark=3DLoMatch --method=ransac # done # python eval.py --benchmark=3DLoMatch --method=svd # for n in 250 500 1000 2500 5000; do # python eval.py --num_corr=$n --benchmark=3DLoMatch --method=svd # done # python eval.py --benchmark=3DMatch --method=lgr # for n in 250 500 1000 2500 5000; do # python eval.py --num_corr=$n --benchmark=3DMatch --method=lgr # done # python eval.py --benchmark=3DMatch --method=ransac # for n in 250 500 1000 2500 5000; do # python eval.py --num_corr=$n --benchmark=3DMatch --method=ransac # done python eval.py --num_corr=5000 --benchmark=3DMatch --method=ransac python eval.py --benchmark=3DMatch --method=svd for n in 250 500 1000 2500 5000; do python eval.py --num_corr=$n --benchmark=3DMatch --method=svd done
1,533
35.52381
95
sh
LiDAR2LiDAR
LiDAR2LiDAR-master/geotransformer/experiments/geotransformer.3dmatch.stage4.gse.k3.max.oacl.stage2.sinkhorn/eval.sh
# if [ "$3" = "test" ]; then # python test.py --test_epoch=$1 --benchmark=$2 # fi # python eval.py --test_epoch=$1 --benchmark=$2 --method=lgr # # for n in 250 500 1000 2500; do # # python eval.py --test_epoch=$1 --num_corr=$n --run_matching --run_registration --benchmark=$2 # # done python test1.py --test_epoch=50 --benchmark=3DLoMatch python test1.py --test_epoch=50 --benchmark=3DMatch python eval.py --benchmark=3DLoMatch --method=lgr for n in 250 500 1000 2500 5000; do python eval.py --num_corr=$n --benchmark=3DLoMatch --method=lgr done python eval.py --benchmark=3DLoMatch --method=ransac for n in 250 500 1000 2500 5000; do python eval.py --num_corr=$n --benchmark=3DLoMatch --method=ransac done python eval.py --benchmark=3DLoMatch --method=svd for n in 250 500 1000 2500 5000; do python eval.py --num_corr=$n --benchmark=3DLoMatch --method=svd done python eval.py --benchmark=3DMatch --method=lgr for n in 250 500 1000 2500 5000; do python eval.py --num_corr=$n --benchmark=3DMatch --method=lgr done python eval.py --benchmark=3DMatch --method=ransac for n in 250 500 1000 2500 5000; do python eval.py --num_corr=$n --benchmark=3DMatch --method=ransac done python eval.py --benchmark=3DMatch --method=svd for n in 250 500 1000 2500 5000; do python eval.py --num_corr=$n --benchmark=3DMatch --method=svd done
1,380
32.682927
101
sh
LiDAR2LiDAR
LiDAR2LiDAR-master/geotransformer/experiments/geotransformer.3dmatch.stage4.gse.k3.max.oacl.stage2.sinkhorn/eval_all.sh
for n in $(seq 20 40); do python test.py --test_epoch=$n --benchmark=$1 --verbose python eval.py --test_epoch=$n --benchmark=$1 --method=lgr done # for n in 250 500 1000 2500; do # python eval.py --test_epoch=$1 --num_corr=$n --run_matching --run_registration --benchmark=$2 # done
294
35.875
99
sh
LiDAR2LiDAR
LiDAR2LiDAR-master/geotransformer/experiments/geotransformer.CROON.stage5.gse.k3.max.oacl.stage2.sinkhorn/eval.sh
if [ "$2" = "test" ]; then python test.py --test_epoch=$1 fi python eval.py --test_epoch=$1 --method=lgr
109
21
43
sh
LiDAR2LiDAR
LiDAR2LiDAR-master/geotransformer/experiments/geotransformer.kitti.stage5.gse.k3.max.oacl.stage2.sinkhorn/eval.sh
if [ "$2" = "test" ]; then python test.py --test_epoch=$1 fi python eval.py --test_epoch=$1 --method=lgr
109
21
43
sh
LiDAR2LiDAR
LiDAR2LiDAR-master/geotransformer/geotransformer/extensions/pybind.cpp
#include <torch/extension.h> #include "cpu/radius_neighbors/radius_neighbors.h" #include "cpu/grid_subsampling/grid_subsampling.h" PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { // CPU extensions m.def( "radius_neighbors", &radius_neighbors, "Radius neighbors (CPU)" ); m.def( "grid_subsampling", &grid_subsampling, "Grid subsampling (CPU)" ); }
378
18.947368
50
cpp
LiDAR2LiDAR
LiDAR2LiDAR-master/geotransformer/geotransformer/extensions/common/torch_helper.h
#pragma once #include <ATen/cuda/CUDAContext.h> #include <torch/extension.h> #define CHECK_CUDA(x) \ TORCH_CHECK(x.device().is_cuda(), #x " must be a CUDA tensor") #define CHECK_CPU(x) \ TORCH_CHECK(!x.device().is_cuda(), #x " must be a CPU tensor") #define CHECK_CONTIGUOUS(x) \ TORCH_CHECK(x.is_contiguous(), #x " must be contiguous") #define CHECK_INPUT(x) \ CHECK_CUDA(x); \ CHECK_CONTIGUOUS(x) #define CHECK_IS_INT(x) \ do { \ TORCH_CHECK(x.scalar_type() == at::ScalarType::Int, \ #x " must be an int tensor"); \ } while (0) #define CHECK_IS_LONG(x) \ do { \ TORCH_CHECK(x.scalar_type() == at::ScalarType::Long, \ #x " must be an long tensor"); \ } while (0) #define CHECK_IS_FLOAT(x) \ do { \ TORCH_CHECK(x.scalar_type() == at::ScalarType::Float, \ #x " must be a float tensor"); \ } while (0)
1,698
46.194444
79
h
LiDAR2LiDAR
LiDAR2LiDAR-master/geotransformer/geotransformer/extensions/cpu/grid_subsampling/grid_subsampling.cpp
#include <cstring> #include "grid_subsampling.h" #include "grid_subsampling_cpu.h" std::vector<at::Tensor> grid_subsampling( at::Tensor points, at::Tensor lengths, float voxel_size ) { CHECK_CPU(points); CHECK_CPU(lengths); CHECK_IS_FLOAT(points); CHECK_IS_LONG(lengths); CHECK_CONTIGUOUS(points); CHECK_CONTIGUOUS(lengths); std::size_t batch_size = lengths.size(0); std::size_t total_points = points.size(0); std::vector<PointXYZ> vec_points = std::vector<PointXYZ>( reinterpret_cast<PointXYZ*>(points.data_ptr<float>()), reinterpret_cast<PointXYZ*>(points.data_ptr<float>()) + total_points ); std::vector<PointXYZ> vec_s_points; std::vector<long> vec_lengths = std::vector<long>( lengths.data_ptr<long>(), lengths.data_ptr<long>() + batch_size ); std::vector<long> vec_s_lengths; grid_subsampling_cpu( vec_points, vec_s_points, vec_lengths, vec_s_lengths, voxel_size ); std::size_t total_s_points = vec_s_points.size(); at::Tensor s_points = torch::zeros( {total_s_points, 3}, at::device(points.device()).dtype(at::ScalarType::Float) ); at::Tensor s_lengths = torch::zeros( {batch_size}, at::device(lengths.device()).dtype(at::ScalarType::Long) ); std::memcpy( s_points.data_ptr<float>(), reinterpret_cast<float*>(vec_s_points.data()), sizeof(float) * total_s_points * 3 ); std::memcpy( s_lengths.data_ptr<long>(), vec_s_lengths.data(), sizeof(long) * batch_size ); return {s_points, s_lengths}; }
1,542
23.492063
72
cpp
LiDAR2LiDAR
LiDAR2LiDAR-master/geotransformer/geotransformer/extensions/cpu/grid_subsampling/grid_subsampling.h
#pragma once #include <vector> #include "../../common/torch_helper.h" std::vector<at::Tensor> grid_subsampling( at::Tensor points, at::Tensor lengths, float voxel_size );
179
15.363636
41
h
LiDAR2LiDAR
LiDAR2LiDAR-master/geotransformer/geotransformer/extensions/cpu/grid_subsampling/grid_subsampling_cpu.cpp
#include "grid_subsampling_cpu.h" void single_grid_subsampling_cpu( std::vector<PointXYZ>& points, std::vector<PointXYZ>& s_points, float voxel_size ) { // float sub_scale = 1. / voxel_size; PointXYZ minCorner = min_point(points); PointXYZ maxCorner = max_point(points); PointXYZ originCorner = floor(minCorner * (1. / voxel_size)) * voxel_size; std::size_t sampleNX = static_cast<std::size_t>( // floor((maxCorner.x - originCorner.x) * sub_scale) + 1 floor((maxCorner.x - originCorner.x) / voxel_size) + 1 ); std::size_t sampleNY = static_cast<std::size_t>( // floor((maxCorner.y - originCorner.y) * sub_scale) + 1 floor((maxCorner.y - originCorner.y) / voxel_size) + 1 ); std::size_t iX = 0; std::size_t iY = 0; std::size_t iZ = 0; std::size_t mapIdx = 0; std::unordered_map<std::size_t, SampledData> data; for (auto& p : points) { // iX = static_cast<std::size_t>(floor((p.x - originCorner.x) * sub_scale)); // iY = static_cast<std::size_t>(floor((p.y - originCorner.y) * sub_scale)); // iZ = static_cast<std::size_t>(floor((p.z - originCorner.z) * sub_scale)); iX = static_cast<std::size_t>(floor((p.x - originCorner.x) / voxel_size)); iY = static_cast<std::size_t>(floor((p.y - originCorner.y) / voxel_size)); iZ = static_cast<std::size_t>(floor((p.z - originCorner.z) / voxel_size)); mapIdx = iX + sampleNX * iY + sampleNX * sampleNY * iZ; if (!data.count(mapIdx)) { data.emplace(mapIdx, SampledData()); } data[mapIdx].update(p); } s_points.reserve(data.size()); for (auto& v : data) { s_points.push_back(v.second.point * (1.0 / v.second.count)); } } void grid_subsampling_cpu( std::vector<PointXYZ>& points, std::vector<PointXYZ>& s_points, std::vector<long>& lengths, std::vector<long>& s_lengths, float voxel_size ) { std::size_t start_index = 0; std::size_t batch_size = lengths.size(); for (std::size_t b = 0; b < batch_size; b++) { std::vector<PointXYZ> cur_points = std::vector<PointXYZ>( points.begin() + start_index, points.begin() + start_index + lengths[b] ); std::vector<PointXYZ> cur_s_points; single_grid_subsampling_cpu(cur_points, cur_s_points, voxel_size); s_points.insert(s_points.end(), cur_s_points.begin(), cur_s_points.end()); s_lengths.push_back(cur_s_points.size()); start_index += lengths[b]; } return; }
2,410
30.723684
79
cpp
LiDAR2LiDAR
LiDAR2LiDAR-master/geotransformer/geotransformer/extensions/cpu/grid_subsampling/grid_subsampling_cpu.h
#pragma once #include <vector> #include <unordered_map> #include "../../extra/cloud/cloud.h" class SampledData { public: int count; PointXYZ point; SampledData() { count = 0; point = PointXYZ(); } void update(const PointXYZ& p) { count += 1; point += p; } }; void single_grid_subsampling_cpu( std::vector<PointXYZ>& o_points, std::vector<PointXYZ>& s_points, float voxel_size ); void grid_subsampling_cpu( std::vector<PointXYZ>& o_points, std::vector<PointXYZ>& s_points, std::vector<long>& o_lengths, std::vector<long>& s_lengths, float voxel_size );
603
15.324324
36
h
LiDAR2LiDAR
LiDAR2LiDAR-master/geotransformer/geotransformer/extensions/cpu/radius_neighbors/radius_neighbors.cpp
#include <cstring> #include "radius_neighbors.h" #include "radius_neighbors_cpu.h" at::Tensor radius_neighbors( at::Tensor q_points, at::Tensor s_points, at::Tensor q_lengths, at::Tensor s_lengths, float radius ) { CHECK_CPU(q_points); CHECK_CPU(s_points); CHECK_CPU(q_lengths); CHECK_CPU(s_lengths); CHECK_IS_FLOAT(q_points); CHECK_IS_FLOAT(s_points); CHECK_IS_LONG(q_lengths); CHECK_IS_LONG(s_lengths); CHECK_CONTIGUOUS(q_points); CHECK_CONTIGUOUS(s_points); CHECK_CONTIGUOUS(q_lengths); CHECK_CONTIGUOUS(s_lengths); std::size_t total_q_points = q_points.size(0); std::size_t total_s_points = s_points.size(0); std::size_t batch_size = q_lengths.size(0); std::vector<PointXYZ> vec_q_points = std::vector<PointXYZ>( reinterpret_cast<PointXYZ*>(q_points.data_ptr<float>()), reinterpret_cast<PointXYZ*>(q_points.data_ptr<float>()) + total_q_points ); std::vector<PointXYZ> vec_s_points = std::vector<PointXYZ>( reinterpret_cast<PointXYZ*>(s_points.data_ptr<float>()), reinterpret_cast<PointXYZ*>(s_points.data_ptr<float>()) + total_s_points ); std::vector<long> vec_q_lengths = std::vector<long>( q_lengths.data_ptr<long>(), q_lengths.data_ptr<long>() + batch_size ); std::vector<long> vec_s_lengths = std::vector<long>( s_lengths.data_ptr<long>(), s_lengths.data_ptr<long>() + batch_size ); std::vector<long> vec_neighbor_indices; radius_neighbors_cpu( vec_q_points, vec_s_points, vec_q_lengths, vec_s_lengths, vec_neighbor_indices, radius ); std::size_t max_neighbors = vec_neighbor_indices.size() / total_q_points; at::Tensor neighbor_indices = torch::zeros( {total_q_points, max_neighbors}, at::device(q_points.device()).dtype(at::ScalarType::Long) ); std::memcpy( neighbor_indices.data_ptr<long>(), vec_neighbor_indices.data(), sizeof(long) * total_q_points * max_neighbors ); return neighbor_indices; }
1,958
27.391304
76
cpp
LiDAR2LiDAR
LiDAR2LiDAR-master/geotransformer/geotransformer/extensions/cpu/radius_neighbors/radius_neighbors.h
#pragma once #include "../../common/torch_helper.h" at::Tensor radius_neighbors( at::Tensor q_points, at::Tensor s_points, at::Tensor q_lengths, at::Tensor s_lengths, float radius );
195
15.333333
38
h
LiDAR2LiDAR
LiDAR2LiDAR-master/geotransformer/geotransformer/extensions/cpu/radius_neighbors/radius_neighbors_cpu.cpp
#include "radius_neighbors_cpu.h" void radius_neighbors_cpu( std::vector<PointXYZ>& q_points, std::vector<PointXYZ>& s_points, std::vector<long>& q_lengths, std::vector<long>& s_lengths, std::vector<long>& neighbor_indices, float radius ) { std::size_t i0 = 0; float r2 = radius * radius; std::size_t max_count = 0; std::vector<std::vector<std::pair<std::size_t, float>>> all_inds_dists( q_points.size() ); std::size_t b = 0; std::size_t q_start_index = 0; std::size_t s_start_index = 0; PointCloud current_cloud; current_cloud.pts = std::vector<PointXYZ>( s_points.begin() + s_start_index, s_points.begin() + s_start_index + s_lengths[b] ); nanoflann::KDTreeSingleIndexAdaptorParams tree_params(10); my_kd_tree_t* index = new my_kd_tree_t(3, current_cloud, tree_params);; index->buildIndex(); nanoflann::SearchParams search_params; search_params.sorted = true; for (auto& p0 : q_points) { if (i0 == q_start_index + q_lengths[b]) { q_start_index += q_lengths[b]; s_start_index += s_lengths[b]; b++; current_cloud.pts.clear(); current_cloud.pts = std::vector<PointXYZ>( s_points.begin() + s_start_index, s_points.begin() + s_start_index + s_lengths[b] ); delete index; index = new my_kd_tree_t(3, current_cloud, tree_params); index->buildIndex(); } all_inds_dists[i0].reserve(max_count); float query_pt[3] = {p0.x, p0.y, p0.z}; std::size_t nMatches = index->radiusSearch( query_pt, r2, all_inds_dists[i0], search_params ); if (nMatches > max_count) { max_count = nMatches; } i0++; } delete index; neighbor_indices.resize(q_points.size() * max_count); i0 = 0; s_start_index = 0; q_start_index = 0; b = 0; for (auto& inds_dists : all_inds_dists) { if (i0 == q_start_index + q_lengths[b]) { q_start_index += q_lengths[b]; s_start_index += s_lengths[b]; b++; } for (std::size_t j = 0; j < max_count; j++) { std::size_t i = i0 * max_count + j; if (j < inds_dists.size()) { neighbor_indices[i] = inds_dists[j].first + s_start_index; } else { neighbor_indices[i] = s_points.size(); } } i0++; } }
2,276
23.75
73
cpp
LiDAR2LiDAR
LiDAR2LiDAR-master/geotransformer/geotransformer/extensions/cpu/radius_neighbors/radius_neighbors_cpu.h
#include <vector> #include "../../extra/cloud/cloud.h" #include "../../extra/nanoflann/nanoflann.hpp" typedef nanoflann::KDTreeSingleIndexAdaptor< nanoflann::L2_Simple_Adaptor<float, PointCloud>, PointCloud, 3 > my_kd_tree_t; void radius_neighbors_cpu( std::vector<PointXYZ>& q_points, std::vector<PointXYZ>& s_points, std::vector<long>& q_lengths, std::vector<long>& s_lengths, std::vector<long>& neighbor_indices, float radius );
448
25.411765
64
h
LiDAR2LiDAR
LiDAR2LiDAR-master/geotransformer/geotransformer/extensions/extra/cloud/cloud.cpp
// Modified from https://github.com/HuguesTHOMAS/KPConv-PyTorch #include "cloud.h" PointXYZ max_point(std::vector<PointXYZ> points) { PointXYZ maxP(points[0]); for (auto p : points) { if (p.x > maxP.x) { maxP.x = p.x; } if (p.y > maxP.y) { maxP.y = p.y; } if (p.z > maxP.z) { maxP.z = p.z; } } return maxP; } PointXYZ min_point(std::vector<PointXYZ> points) { PointXYZ minP(points[0]); for (auto p : points) { if (p.x < minP.x) { minP.x = p.x; } if (p.y < minP.y) { minP.y = p.y; } if (p.z < minP.z) { minP.z = p.z; } } return minP; }
640
15.868421
63
cpp
LiDAR2LiDAR
LiDAR2LiDAR-master/geotransformer/geotransformer/extensions/extra/cloud/cloud.h
// Modified from https://github.com/HuguesTHOMAS/KPConv-PyTorch #pragma once #include <vector> #include <unordered_map> #include <map> #include <algorithm> #include <numeric> #include <iostream> #include <iomanip> #include <cmath> #include <time.h> class PointXYZ { public: float x, y, z; PointXYZ() { x = 0; y = 0; z = 0; } PointXYZ(float x0, float y0, float z0) { x = x0; y = y0; z = z0; } float operator [] (int i) const { if (i == 0) { return x; } else if (i == 1) { return y; } else { return z; } } float dot(const PointXYZ P) const { return x * P.x + y * P.y + z * P.z; } float sq_norm() { return x * x + y * y + z * z; } PointXYZ cross(const PointXYZ P) const { return PointXYZ(y * P.z - z * P.y, z * P.x - x * P.z, x * P.y - y * P.x); } PointXYZ& operator+=(const PointXYZ& P) { x += P.x; y += P.y; z += P.z; return *this; } PointXYZ& operator-=(const PointXYZ& P) { x -= P.x; y -= P.y; z -= P.z; return *this; } PointXYZ& operator*=(const float& a) { x *= a; y *= a; z *= a; return *this; } }; inline PointXYZ operator + (const PointXYZ A, const PointXYZ B) { return PointXYZ(A.x + B.x, A.y + B.y, A.z + B.z); } inline PointXYZ operator - (const PointXYZ A, const PointXYZ B) { return PointXYZ(A.x - B.x, A.y - B.y, A.z - B.z); } inline PointXYZ operator * (const PointXYZ P, const float a) { return PointXYZ(P.x * a, P.y * a, P.z * a); } inline PointXYZ operator * (const float a, const PointXYZ P) { return PointXYZ(P.x * a, P.y * a, P.z * a); } inline std::ostream& operator << (std::ostream& os, const PointXYZ P) { return os << "[" << P.x << ", " << P.y << ", " << P.z << "]"; } inline bool operator == (const PointXYZ A, const PointXYZ B) { return A.x == B.x && A.y == B.y && A.z == B.z; } inline PointXYZ floor(const PointXYZ P) { return PointXYZ(std::floor(P.x), std::floor(P.y), std::floor(P.z)); } PointXYZ max_point(std::vector<PointXYZ> points); PointXYZ min_point(std::vector<PointXYZ> points); struct PointCloud { std::vector<PointXYZ> pts; inline size_t kdtree_get_point_count() const { return pts.size(); } // Returns the dim'th component of the idx'th point in the class: // Since this is inlined and the "dim" argument is typically an immediate value, the // "if/else's" are actually solved at compile time. inline float kdtree_get_pt(const size_t idx, const size_t dim) const { if (dim == 0) { return pts[idx].x; } else if (dim == 1) { return pts[idx].y; } else { return pts[idx].z; } } // Optional bounding-box computation: return false to default to a standard bbox computation loop. // Return true if the BBOX was already computed by the class and returned in "bb" so it can be avoided to redo it again. // Look at bb.size() to find out the expected dimensionality (e.g. 2 or 3 for point clouds) template <class BBOX> bool kdtree_get_bbox(BBOX& /* bb */) const { return false; } };
3,099
21.463768
124
h
LiDAR2LiDAR
LiDAR2LiDAR-master/geotransformer/geotransformer/extensions/extra/nanoflann/nanoflann.hpp
/*********************************************************************** * Software License Agreement (BSD License) * * Copyright 2008-2009 Marius Muja ([email protected]). All rights reserved. * Copyright 2008-2009 David G. Lowe ([email protected]). All rights reserved. * Copyright 2011-2016 Jose Luis Blanco ([email protected]). * All rights reserved. * * THE BSD LICENSE * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *************************************************************************/ /** \mainpage nanoflann C++ API documentation * nanoflann is a C++ header-only library for building KD-Trees, mostly * optimized for 2D or 3D point clouds. * * nanoflann does not require compiling or installing, just an * #include <nanoflann.hpp> in your code. * * See: * - <a href="modules.html" >C++ API organized by modules</a> * - <a href="https://github.com/jlblancoc/nanoflann" >Online README</a> * - <a href="http://jlblancoc.github.io/nanoflann/" >Doxygen * documentation</a> */ #ifndef NANOFLANN_HPP_ #define NANOFLANN_HPP_ #include <algorithm> #include <array> #include <cassert> #include <cmath> // for abs() #include <cstdio> // for fwrite() #include <cstdlib> // for abs() #include <functional> #include <limits> // std::reference_wrapper #include <stdexcept> #include <vector> /** Library version: 0xMmP (M=Major,m=minor,P=patch) */ #define NANOFLANN_VERSION 0x130 // Avoid conflicting declaration of min/max macros in windows headers #if !defined(NOMINMAX) && \ (defined(_WIN32) || defined(_WIN32_) || defined(WIN32) || defined(_WIN64)) #define NOMINMAX #ifdef max #undef max #undef min #endif #endif namespace nanoflann { /** @addtogroup nanoflann_grp nanoflann C++ library for ANN * @{ */ /** the PI constant (required to avoid MSVC missing symbols) */ template <typename T> T pi_const() { return static_cast<T>(3.14159265358979323846); } /** * Traits if object is resizable and assignable (typically has a resize | assign * method) */ template <typename T, typename = int> struct has_resize : std::false_type {}; template <typename T> struct has_resize<T, decltype((void)std::declval<T>().resize(1), 0)> : std::true_type {}; template <typename T, typename = int> struct has_assign : std::false_type {}; template <typename T> struct has_assign<T, decltype((void)std::declval<T>().assign(1, 0), 0)> : std::true_type {}; /** * Free function to resize a resizable object */ template <typename Container> inline typename std::enable_if<has_resize<Container>::value, void>::type resize(Container &c, const size_t nElements) { c.resize(nElements); } /** * Free function that has no effects on non resizable containers (e.g. * std::array) It raises an exception if the expected size does not match */ template <typename Container> inline typename std::enable_if<!has_resize<Container>::value, void>::type resize(Container &c, const size_t nElements) { if (nElements != c.size()) throw std::logic_error("Try to change the size of a std::array."); } /** * Free function to assign to a container */ template <typename Container, typename T> inline typename std::enable_if<has_assign<Container>::value, void>::type assign(Container &c, const size_t nElements, const T &value) { c.assign(nElements, value); } /** * Free function to assign to a std::array */ template <typename Container, typename T> inline typename std::enable_if<!has_assign<Container>::value, void>::type assign(Container &c, const size_t nElements, const T &value) { for (size_t i = 0; i < nElements; i++) c[i] = value; } /** @addtogroup result_sets_grp Result set classes * @{ */ template <typename _DistanceType, typename _IndexType = size_t, typename _CountType = size_t> class KNNResultSet { public: typedef _DistanceType DistanceType; typedef _IndexType IndexType; typedef _CountType CountType; private: IndexType *indices; DistanceType *dists; CountType capacity; CountType count; public: inline KNNResultSet(CountType capacity_) : indices(0), dists(0), capacity(capacity_), count(0) {} inline void init(IndexType *indices_, DistanceType *dists_) { indices = indices_; dists = dists_; count = 0; if (capacity) dists[capacity - 1] = (std::numeric_limits<DistanceType>::max)(); } inline CountType size() const { return count; } inline bool full() const { return count == capacity; } /** * Called during search to add an element matching the criteria. * @return true if the search should be continued, false if the results are * sufficient */ inline bool addPoint(DistanceType dist, IndexType index) { CountType i; for (i = count; i > 0; --i) { #ifdef NANOFLANN_FIRST_MATCH // If defined and two points have the same // distance, the one with the lowest-index will be // returned first. if ((dists[i - 1] > dist) || ((dist == dists[i - 1]) && (indices[i - 1] > index))) { #else if (dists[i - 1] > dist) { #endif if (i < capacity) { dists[i] = dists[i - 1]; indices[i] = indices[i - 1]; } } else break; } if (i < capacity) { dists[i] = dist; indices[i] = index; } if (count < capacity) count++; // tell caller that the search shall continue return true; } inline DistanceType worstDist() const { return dists[capacity - 1]; } }; /** operator "<" for std::sort() */ struct IndexDist_Sorter { /** PairType will be typically: std::pair<IndexType,DistanceType> */ template <typename PairType> inline bool operator()(const PairType &p1, const PairType &p2) const { return p1.second < p2.second; } }; /** * A result-set class used when performing a radius based search. */ template <typename _DistanceType, typename _IndexType = size_t> class RadiusResultSet { public: typedef _DistanceType DistanceType; typedef _IndexType IndexType; public: const DistanceType radius; std::vector<std::pair<IndexType, DistanceType>> &m_indices_dists; inline RadiusResultSet( DistanceType radius_, std::vector<std::pair<IndexType, DistanceType>> &indices_dists) : radius(radius_), m_indices_dists(indices_dists) { init(); } inline void init() { clear(); } inline void clear() { m_indices_dists.clear(); } inline size_t size() const { return m_indices_dists.size(); } inline bool full() const { return true; } /** * Called during search to add an element matching the criteria. * @return true if the search should be continued, false if the results are * sufficient */ inline bool addPoint(DistanceType dist, IndexType index) { if (dist < radius) m_indices_dists.push_back(std::make_pair(index, dist)); return true; } inline DistanceType worstDist() const { return radius; } /** * Find the worst result (furtherest neighbor) without copying or sorting * Pre-conditions: size() > 0 */ std::pair<IndexType, DistanceType> worst_item() const { if (m_indices_dists.empty()) throw std::runtime_error("Cannot invoke RadiusResultSet::worst_item() on " "an empty list of results."); typedef typename std::vector<std::pair<IndexType, DistanceType>>::const_iterator DistIt; DistIt it = std::max_element(m_indices_dists.begin(), m_indices_dists.end(), IndexDist_Sorter()); return *it; } }; /** @} */ /** @addtogroup loadsave_grp Load/save auxiliary functions * @{ */ template <typename T> void save_value(FILE *stream, const T &value, size_t count = 1) { fwrite(&value, sizeof(value), count, stream); } template <typename T> void save_value(FILE *stream, const std::vector<T> &value) { size_t size = value.size(); fwrite(&size, sizeof(size_t), 1, stream); fwrite(&value[0], sizeof(T), size, stream); } template <typename T> void load_value(FILE *stream, T &value, size_t count = 1) { size_t read_cnt = fread(&value, sizeof(value), count, stream); if (read_cnt != count) { throw std::runtime_error("Cannot read from file"); } } template <typename T> void load_value(FILE *stream, std::vector<T> &value) { size_t size; size_t read_cnt = fread(&size, sizeof(size_t), 1, stream); if (read_cnt != 1) { throw std::runtime_error("Cannot read from file"); } value.resize(size); read_cnt = fread(&value[0], sizeof(T), size, stream); if (read_cnt != size) { throw std::runtime_error("Cannot read from file"); } } /** @} */ /** @addtogroup metric_grp Metric (distance) classes * @{ */ struct Metric {}; /** Manhattan distance functor (generic version, optimized for * high-dimensionality data sets). Corresponding distance traits: * nanoflann::metric_L1 \tparam T Type of the elements (e.g. double, float, * uint8_t) \tparam _DistanceType Type of distance variables (must be signed) * (e.g. float, double, int64_t) */ template <class T, class DataSource, typename _DistanceType = T> struct L1_Adaptor { typedef T ElementType; typedef _DistanceType DistanceType; const DataSource &data_source; L1_Adaptor(const DataSource &_data_source) : data_source(_data_source) {} inline DistanceType evalMetric(const T *a, const size_t b_idx, size_t size, DistanceType worst_dist = -1) const { DistanceType result = DistanceType(); const T *last = a + size; const T *lastgroup = last - 3; size_t d = 0; /* Process 4 items with each loop for efficiency. */ while (a < lastgroup) { const DistanceType diff0 = std::abs(a[0] - data_source.kdtree_get_pt(b_idx, d++)); const DistanceType diff1 = std::abs(a[1] - data_source.kdtree_get_pt(b_idx, d++)); const DistanceType diff2 = std::abs(a[2] - data_source.kdtree_get_pt(b_idx, d++)); const DistanceType diff3 = std::abs(a[3] - data_source.kdtree_get_pt(b_idx, d++)); result += diff0 + diff1 + diff2 + diff3; a += 4; if ((worst_dist > 0) && (result > worst_dist)) { return result; } } /* Process last 0-3 components. Not needed for standard vector lengths. */ while (a < last) { result += std::abs(*a++ - data_source.kdtree_get_pt(b_idx, d++)); } return result; } template <typename U, typename V> inline DistanceType accum_dist(const U a, const V b, const size_t) const { return std::abs(a - b); } }; /** Squared Euclidean distance functor (generic version, optimized for * high-dimensionality data sets). Corresponding distance traits: * nanoflann::metric_L2 \tparam T Type of the elements (e.g. double, float, * uint8_t) \tparam _DistanceType Type of distance variables (must be signed) * (e.g. float, double, int64_t) */ template <class T, class DataSource, typename _DistanceType = T> struct L2_Adaptor { typedef T ElementType; typedef _DistanceType DistanceType; const DataSource &data_source; L2_Adaptor(const DataSource &_data_source) : data_source(_data_source) {} inline DistanceType evalMetric(const T *a, const size_t b_idx, size_t size, DistanceType worst_dist = -1) const { DistanceType result = DistanceType(); const T *last = a + size; const T *lastgroup = last - 3; size_t d = 0; /* Process 4 items with each loop for efficiency. */ while (a < lastgroup) { const DistanceType diff0 = a[0] - data_source.kdtree_get_pt(b_idx, d++); const DistanceType diff1 = a[1] - data_source.kdtree_get_pt(b_idx, d++); const DistanceType diff2 = a[2] - data_source.kdtree_get_pt(b_idx, d++); const DistanceType diff3 = a[3] - data_source.kdtree_get_pt(b_idx, d++); result += diff0 * diff0 + diff1 * diff1 + diff2 * diff2 + diff3 * diff3; a += 4; if ((worst_dist > 0) && (result > worst_dist)) { return result; } } /* Process last 0-3 components. Not needed for standard vector lengths. */ while (a < last) { const DistanceType diff0 = *a++ - data_source.kdtree_get_pt(b_idx, d++); result += diff0 * diff0; } return result; } template <typename U, typename V> inline DistanceType accum_dist(const U a, const V b, const size_t) const { return (a - b) * (a - b); } }; /** Squared Euclidean (L2) distance functor (suitable for low-dimensionality * datasets, like 2D or 3D point clouds) Corresponding distance traits: * nanoflann::metric_L2_Simple \tparam T Type of the elements (e.g. double, * float, uint8_t) \tparam _DistanceType Type of distance variables (must be * signed) (e.g. float, double, int64_t) */ template <class T, class DataSource, typename _DistanceType = T> struct L2_Simple_Adaptor { typedef T ElementType; typedef _DistanceType DistanceType; const DataSource &data_source; L2_Simple_Adaptor(const DataSource &_data_source) : data_source(_data_source) {} inline DistanceType evalMetric(const T *a, const size_t b_idx, size_t size) const { DistanceType result = DistanceType(); for (size_t i = 0; i < size; ++i) { const DistanceType diff = a[i] - data_source.kdtree_get_pt(b_idx, i); result += diff * diff; } return result; } template <typename U, typename V> inline DistanceType accum_dist(const U a, const V b, const size_t) const { return (a - b) * (a - b); } }; /** SO2 distance functor * Corresponding distance traits: nanoflann::metric_SO2 * \tparam T Type of the elements (e.g. double, float) * \tparam _DistanceType Type of distance variables (must be signed) (e.g. * float, double) orientation is constrained to be in [-pi, pi] */ template <class T, class DataSource, typename _DistanceType = T> struct SO2_Adaptor { typedef T ElementType; typedef _DistanceType DistanceType; const DataSource &data_source; SO2_Adaptor(const DataSource &_data_source) : data_source(_data_source) {} inline DistanceType evalMetric(const T *a, const size_t b_idx, size_t size) const { return accum_dist(a[size - 1], data_source.kdtree_get_pt(b_idx, size - 1), size - 1); } /** Note: this assumes that input angles are already in the range [-pi,pi] */ template <typename U, typename V> inline DistanceType accum_dist(const U a, const V b, const size_t) const { DistanceType result = DistanceType(), PI = pi_const<DistanceType>(); result = b - a; if (result > PI) result -= 2 * PI; else if (result < -PI) result += 2 * PI; return result; } }; /** SO3 distance functor (Uses L2_Simple) * Corresponding distance traits: nanoflann::metric_SO3 * \tparam T Type of the elements (e.g. double, float) * \tparam _DistanceType Type of distance variables (must be signed) (e.g. * float, double) */ template <class T, class DataSource, typename _DistanceType = T> struct SO3_Adaptor { typedef T ElementType; typedef _DistanceType DistanceType; L2_Simple_Adaptor<T, DataSource> distance_L2_Simple; SO3_Adaptor(const DataSource &_data_source) : distance_L2_Simple(_data_source) {} inline DistanceType evalMetric(const T *a, const size_t b_idx, size_t size) const { return distance_L2_Simple.evalMetric(a, b_idx, size); } template <typename U, typename V> inline DistanceType accum_dist(const U a, const V b, const size_t idx) const { return distance_L2_Simple.accum_dist(a, b, idx); } }; /** Metaprogramming helper traits class for the L1 (Manhattan) metric */ struct metric_L1 : public Metric { template <class T, class DataSource> struct traits { typedef L1_Adaptor<T, DataSource> distance_t; }; }; /** Metaprogramming helper traits class for the L2 (Euclidean) metric */ struct metric_L2 : public Metric { template <class T, class DataSource> struct traits { typedef L2_Adaptor<T, DataSource> distance_t; }; }; /** Metaprogramming helper traits class for the L2_simple (Euclidean) metric */ struct metric_L2_Simple : public Metric { template <class T, class DataSource> struct traits { typedef L2_Simple_Adaptor<T, DataSource> distance_t; }; }; /** Metaprogramming helper traits class for the SO3_InnerProdQuat metric */ struct metric_SO2 : public Metric { template <class T, class DataSource> struct traits { typedef SO2_Adaptor<T, DataSource> distance_t; }; }; /** Metaprogramming helper traits class for the SO3_InnerProdQuat metric */ struct metric_SO3 : public Metric { template <class T, class DataSource> struct traits { typedef SO3_Adaptor<T, DataSource> distance_t; }; }; /** @} */ /** @addtogroup param_grp Parameter structs * @{ */ /** Parameters (see README.md) */ struct KDTreeSingleIndexAdaptorParams { KDTreeSingleIndexAdaptorParams(size_t _leaf_max_size = 10) : leaf_max_size(_leaf_max_size) {} size_t leaf_max_size; }; /** Search options for KDTreeSingleIndexAdaptor::findNeighbors() */ struct SearchParams { /** Note: The first argument (checks_IGNORED_) is ignored, but kept for * compatibility with the FLANN interface */ SearchParams(int checks_IGNORED_ = 32, float eps_ = 0, bool sorted_ = true) : checks(checks_IGNORED_), eps(eps_), sorted(sorted_) {} int checks; //!< Ignored parameter (Kept for compatibility with the FLANN //!< interface). float eps; //!< search for eps-approximate neighbours (default: 0) bool sorted; //!< only for radius search, require neighbours sorted by //!< distance (default: true) }; /** @} */ /** @addtogroup memalloc_grp Memory allocation * @{ */ /** * Allocates (using C's malloc) a generic type T. * * Params: * count = number of instances to allocate. * Returns: pointer (of type T*) to memory buffer */ template <typename T> inline T *allocate(size_t count = 1) { T *mem = static_cast<T *>(::malloc(sizeof(T) * count)); return mem; } /** * Pooled storage allocator * * The following routines allow for the efficient allocation of storage in * small chunks from a specified pool. Rather than allowing each structure * to be freed individually, an entire pool of storage is freed at once. * This method has two advantages over just using malloc() and free(). First, * it is far more efficient for allocating small objects, as there is * no overhead for remembering all the information needed to free each * object or consolidating fragmented memory. Second, the decision about * how long to keep an object is made at the time of allocation, and there * is no need to track down all the objects to free them. * */ const size_t WORDSIZE = 16; const size_t BLOCKSIZE = 8192; class PooledAllocator { /* We maintain memory alignment to word boundaries by requiring that all allocations be in multiples of the machine wordsize. */ /* Size of machine word in bytes. Must be power of 2. */ /* Minimum number of bytes requested at a time from the system. Must be * multiple of WORDSIZE. */ size_t remaining; /* Number of bytes left in current block of storage. */ void *base; /* Pointer to base of current block of storage. */ void *loc; /* Current location in block to next allocate memory. */ void internal_init() { remaining = 0; base = NULL; usedMemory = 0; wastedMemory = 0; } public: size_t usedMemory; size_t wastedMemory; /** Default constructor. Initializes a new pool. */ PooledAllocator() { internal_init(); } /** * Destructor. Frees all the memory allocated in this pool. */ ~PooledAllocator() { free_all(); } /** Frees all allocated memory chunks */ void free_all() { while (base != NULL) { void *prev = *(static_cast<void **>(base)); /* Get pointer to prev block. */ ::free(base); base = prev; } internal_init(); } /** * Returns a pointer to a piece of new memory of the given size in bytes * allocated from the pool. */ void *malloc(const size_t req_size) { /* Round size up to a multiple of wordsize. The following expression only works for WORDSIZE that is a power of 2, by masking last bits of incremented size to zero. */ const size_t size = (req_size + (WORDSIZE - 1)) & ~(WORDSIZE - 1); /* Check whether a new block must be allocated. Note that the first word of a block is reserved for a pointer to the previous block. */ if (size > remaining) { wastedMemory += remaining; /* Allocate new storage. */ const size_t blocksize = (size + sizeof(void *) + (WORDSIZE - 1) > BLOCKSIZE) ? size + sizeof(void *) + (WORDSIZE - 1) : BLOCKSIZE; // use the standard C malloc to allocate memory void *m = ::malloc(blocksize); if (!m) { fprintf(stderr, "Failed to allocate memory.\n"); return NULL; } /* Fill first word of new block with pointer to previous block. */ static_cast<void **>(m)[0] = base; base = m; size_t shift = 0; // int size_t = (WORDSIZE - ( (((size_t)m) + sizeof(void*)) & // (WORDSIZE-1))) & (WORDSIZE-1); remaining = blocksize - sizeof(void *) - shift; loc = (static_cast<char *>(m) + sizeof(void *) + shift); } void *rloc = loc; loc = static_cast<char *>(loc) + size; remaining -= size; usedMemory += size; return rloc; } /** * Allocates (using this pool) a generic type T. * * Params: * count = number of instances to allocate. * Returns: pointer (of type T*) to memory buffer */ template <typename T> T *allocate(const size_t count = 1) { T *mem = static_cast<T *>(this->malloc(sizeof(T) * count)); return mem; } }; /** @} */ /** @addtogroup nanoflann_metaprog_grp Auxiliary metaprogramming stuff * @{ */ /** Used to declare fixed-size arrays when DIM>0, dynamically-allocated vectors * when DIM=-1. Fixed size version for a generic DIM: */ template <int DIM, typename T> struct array_or_vector_selector { typedef std::array<T, DIM> container_t; }; /** Dynamic size version */ template <typename T> struct array_or_vector_selector<-1, T> { typedef std::vector<T> container_t; }; /** @} */ /** kd-tree base-class * * Contains the member functions common to the classes KDTreeSingleIndexAdaptor * and KDTreeSingleIndexDynamicAdaptor_. * * \tparam Derived The name of the class which inherits this class. * \tparam DatasetAdaptor The user-provided adaptor (see comments above). * \tparam Distance The distance metric to use, these are all classes derived * from nanoflann::Metric \tparam DIM Dimensionality of data points (e.g. 3 for * 3D points) \tparam IndexType Will be typically size_t or int */ template <class Derived, typename Distance, class DatasetAdaptor, int DIM = -1, typename IndexType = size_t> class KDTreeBaseClass { public: /** Frees the previously-built index. Automatically called within * buildIndex(). */ void freeIndex(Derived &obj) { obj.pool.free_all(); obj.root_node = NULL; obj.m_size_at_index_build = 0; } typedef typename Distance::ElementType ElementType; typedef typename Distance::DistanceType DistanceType; /*--------------------- Internal Data Structures --------------------------*/ struct Node { /** Union used because a node can be either a LEAF node or a non-leaf node, * so both data fields are never used simultaneously */ union { struct leaf { IndexType left, right; //!< Indices of points in leaf node } lr; struct nonleaf { int divfeat; //!< Dimension used for subdivision. DistanceType divlow, divhigh; //!< The values used for subdivision. } sub; } node_type; Node *child1, *child2; //!< Child nodes (both=NULL mean its a leaf node) }; typedef Node *NodePtr; struct Interval { ElementType low, high; }; /** * Array of indices to vectors in the dataset. */ std::vector<IndexType> vind; NodePtr root_node; size_t m_leaf_max_size; size_t m_size; //!< Number of current points in the dataset size_t m_size_at_index_build; //!< Number of points in the dataset when the //!< index was built int dim; //!< Dimensionality of each data point /** Define "BoundingBox" as a fixed-size or variable-size container depending * on "DIM" */ typedef typename array_or_vector_selector<DIM, Interval>::container_t BoundingBox; /** Define "distance_vector_t" as a fixed-size or variable-size container * depending on "DIM" */ typedef typename array_or_vector_selector<DIM, DistanceType>::container_t distance_vector_t; /** The KD-tree used to find neighbours */ BoundingBox root_bbox; /** * Pooled memory allocator. * * Using a pooled memory allocator is more efficient * than allocating memory directly when there is a large * number small of memory allocations. */ PooledAllocator pool; /** Returns number of points in dataset */ size_t size(const Derived &obj) const { return obj.m_size; } /** Returns the length of each point in the dataset */ size_t veclen(const Derived &obj) { return static_cast<size_t>(DIM > 0 ? DIM : obj.dim); } /// Helper accessor to the dataset points: inline ElementType dataset_get(const Derived &obj, size_t idx, int component) const { return obj.dataset.kdtree_get_pt(idx, component); } /** * Computes the inde memory usage * Returns: memory used by the index */ size_t usedMemory(Derived &obj) { return obj.pool.usedMemory + obj.pool.wastedMemory + obj.dataset.kdtree_get_point_count() * sizeof(IndexType); // pool memory and vind array memory } void computeMinMax(const Derived &obj, IndexType *ind, IndexType count, int element, ElementType &min_elem, ElementType &max_elem) { min_elem = dataset_get(obj, ind[0], element); max_elem = dataset_get(obj, ind[0], element); for (IndexType i = 1; i < count; ++i) { ElementType val = dataset_get(obj, ind[i], element); if (val < min_elem) min_elem = val; if (val > max_elem) max_elem = val; } } /** * Create a tree node that subdivides the list of vecs from vind[first] * to vind[last]. The routine is called recursively on each sublist. * * @param left index of the first vector * @param right index of the last vector */ NodePtr divideTree(Derived &obj, const IndexType left, const IndexType right, BoundingBox &bbox) { NodePtr node = obj.pool.template allocate<Node>(); // allocate memory /* If too few exemplars remain, then make this a leaf node. */ if ((right - left) <= static_cast<IndexType>(obj.m_leaf_max_size)) { node->child1 = node->child2 = NULL; /* Mark as leaf node. */ node->node_type.lr.left = left; node->node_type.lr.right = right; // compute bounding-box of leaf points for (int i = 0; i < (DIM > 0 ? DIM : obj.dim); ++i) { bbox[i].low = dataset_get(obj, obj.vind[left], i); bbox[i].high = dataset_get(obj, obj.vind[left], i); } for (IndexType k = left + 1; k < right; ++k) { for (int i = 0; i < (DIM > 0 ? DIM : obj.dim); ++i) { if (bbox[i].low > dataset_get(obj, obj.vind[k], i)) bbox[i].low = dataset_get(obj, obj.vind[k], i); if (bbox[i].high < dataset_get(obj, obj.vind[k], i)) bbox[i].high = dataset_get(obj, obj.vind[k], i); } } } else { IndexType idx; int cutfeat; DistanceType cutval; middleSplit_(obj, &obj.vind[0] + left, right - left, idx, cutfeat, cutval, bbox); node->node_type.sub.divfeat = cutfeat; BoundingBox left_bbox(bbox); left_bbox[cutfeat].high = cutval; node->child1 = divideTree(obj, left, left + idx, left_bbox); BoundingBox right_bbox(bbox); right_bbox[cutfeat].low = cutval; node->child2 = divideTree(obj, left + idx, right, right_bbox); node->node_type.sub.divlow = left_bbox[cutfeat].high; node->node_type.sub.divhigh = right_bbox[cutfeat].low; for (int i = 0; i < (DIM > 0 ? DIM : obj.dim); ++i) { bbox[i].low = std::min(left_bbox[i].low, right_bbox[i].low); bbox[i].high = std::max(left_bbox[i].high, right_bbox[i].high); } } return node; } void middleSplit_(Derived &obj, IndexType *ind, IndexType count, IndexType &index, int &cutfeat, DistanceType &cutval, const BoundingBox &bbox) { const DistanceType EPS = static_cast<DistanceType>(0.00001); ElementType max_span = bbox[0].high - bbox[0].low; for (int i = 1; i < (DIM > 0 ? DIM : obj.dim); ++i) { ElementType span = bbox[i].high - bbox[i].low; if (span > max_span) { max_span = span; } } ElementType max_spread = -1; cutfeat = 0; for (int i = 0; i < (DIM > 0 ? DIM : obj.dim); ++i) { ElementType span = bbox[i].high - bbox[i].low; if (span > (1 - EPS) * max_span) { ElementType min_elem, max_elem; computeMinMax(obj, ind, count, i, min_elem, max_elem); ElementType spread = max_elem - min_elem; ; if (spread > max_spread) { cutfeat = i; max_spread = spread; } } } // split in the middle DistanceType split_val = (bbox[cutfeat].low + bbox[cutfeat].high) / 2; ElementType min_elem, max_elem; computeMinMax(obj, ind, count, cutfeat, min_elem, max_elem); if (split_val < min_elem) cutval = min_elem; else if (split_val > max_elem) cutval = max_elem; else cutval = split_val; IndexType lim1, lim2; planeSplit(obj, ind, count, cutfeat, cutval, lim1, lim2); if (lim1 > count / 2) index = lim1; else if (lim2 < count / 2) index = lim2; else index = count / 2; } /** * Subdivide the list of points by a plane perpendicular on axe corresponding * to the 'cutfeat' dimension at 'cutval' position. * * On return: * dataset[ind[0..lim1-1]][cutfeat]<cutval * dataset[ind[lim1..lim2-1]][cutfeat]==cutval * dataset[ind[lim2..count]][cutfeat]>cutval */ void planeSplit(Derived &obj, IndexType *ind, const IndexType count, int cutfeat, DistanceType &cutval, IndexType &lim1, IndexType &lim2) { /* Move vector indices for left subtree to front of list. */ IndexType left = 0; IndexType right = count - 1; for (;;) { while (left <= right && dataset_get(obj, ind[left], cutfeat) < cutval) ++left; while (right && left <= right && dataset_get(obj, ind[right], cutfeat) >= cutval) --right; if (left > right || !right) break; // "!right" was added to support unsigned Index types std::swap(ind[left], ind[right]); ++left; --right; } /* If either list is empty, it means that all remaining features * are identical. Split in the middle to maintain a balanced tree. */ lim1 = left; right = count - 1; for (;;) { while (left <= right && dataset_get(obj, ind[left], cutfeat) <= cutval) ++left; while (right && left <= right && dataset_get(obj, ind[right], cutfeat) > cutval) --right; if (left > right || !right) break; // "!right" was added to support unsigned Index types std::swap(ind[left], ind[right]); ++left; --right; } lim2 = left; } DistanceType computeInitialDistances(const Derived &obj, const ElementType *vec, distance_vector_t &dists) const { assert(vec); DistanceType distsq = DistanceType(); for (int i = 0; i < (DIM > 0 ? DIM : obj.dim); ++i) { if (vec[i] < obj.root_bbox[i].low) { dists[i] = obj.distance.accum_dist(vec[i], obj.root_bbox[i].low, i); distsq += dists[i]; } if (vec[i] > obj.root_bbox[i].high) { dists[i] = obj.distance.accum_dist(vec[i], obj.root_bbox[i].high, i); distsq += dists[i]; } } return distsq; } void save_tree(Derived &obj, FILE *stream, NodePtr tree) { save_value(stream, *tree); if (tree->child1 != NULL) { save_tree(obj, stream, tree->child1); } if (tree->child2 != NULL) { save_tree(obj, stream, tree->child2); } } void load_tree(Derived &obj, FILE *stream, NodePtr &tree) { tree = obj.pool.template allocate<Node>(); load_value(stream, *tree); if (tree->child1 != NULL) { load_tree(obj, stream, tree->child1); } if (tree->child2 != NULL) { load_tree(obj, stream, tree->child2); } } /** Stores the index in a binary file. * IMPORTANT NOTE: The set of data points is NOT stored in the file, so when * loading the index object it must be constructed associated to the same * source of data points used while building it. See the example: * examples/saveload_example.cpp \sa loadIndex */ void saveIndex_(Derived &obj, FILE *stream) { save_value(stream, obj.m_size); save_value(stream, obj.dim); save_value(stream, obj.root_bbox); save_value(stream, obj.m_leaf_max_size); save_value(stream, obj.vind); save_tree(obj, stream, obj.root_node); } /** Loads a previous index from a binary file. * IMPORTANT NOTE: The set of data points is NOT stored in the file, so the * index object must be constructed associated to the same source of data * points used while building the index. See the example: * examples/saveload_example.cpp \sa loadIndex */ void loadIndex_(Derived &obj, FILE *stream) { load_value(stream, obj.m_size); load_value(stream, obj.dim); load_value(stream, obj.root_bbox); load_value(stream, obj.m_leaf_max_size); load_value(stream, obj.vind); load_tree(obj, stream, obj.root_node); } }; /** @addtogroup kdtrees_grp KD-tree classes and adaptors * @{ */ /** kd-tree static index * * Contains the k-d trees and other information for indexing a set of points * for nearest-neighbor matching. * * The class "DatasetAdaptor" must provide the following interface (can be * non-virtual, inlined methods): * * \code * // Must return the number of data poins * inline size_t kdtree_get_point_count() const { ... } * * * // Must return the dim'th component of the idx'th point in the class: * inline T kdtree_get_pt(const size_t idx, const size_t dim) const { ... } * * // Optional bounding-box computation: return false to default to a standard * bbox computation loop. * // Return true if the BBOX was already computed by the class and returned * in "bb" so it can be avoided to redo it again. * // Look at bb.size() to find out the expected dimensionality (e.g. 2 or 3 * for point clouds) template <class BBOX> bool kdtree_get_bbox(BBOX &bb) const * { * bb[0].low = ...; bb[0].high = ...; // 0th dimension limits * bb[1].low = ...; bb[1].high = ...; // 1st dimension limits * ... * return true; * } * * \endcode * * \tparam DatasetAdaptor The user-provided adaptor (see comments above). * \tparam Distance The distance metric to use: nanoflann::metric_L1, * nanoflann::metric_L2, nanoflann::metric_L2_Simple, etc. \tparam DIM * Dimensionality of data points (e.g. 3 for 3D points) \tparam IndexType Will * be typically size_t or int */ template <typename Distance, class DatasetAdaptor, int DIM = -1, typename IndexType = size_t> class KDTreeSingleIndexAdaptor : public KDTreeBaseClass< KDTreeSingleIndexAdaptor<Distance, DatasetAdaptor, DIM, IndexType>, Distance, DatasetAdaptor, DIM, IndexType> { public: /** Deleted copy constructor*/ KDTreeSingleIndexAdaptor( const KDTreeSingleIndexAdaptor<Distance, DatasetAdaptor, DIM, IndexType> &) = delete; /** * The dataset used by this index */ const DatasetAdaptor &dataset; //!< The source of our data const KDTreeSingleIndexAdaptorParams index_params; Distance distance; typedef typename nanoflann::KDTreeBaseClass< nanoflann::KDTreeSingleIndexAdaptor<Distance, DatasetAdaptor, DIM, IndexType>, Distance, DatasetAdaptor, DIM, IndexType> BaseClassRef; typedef typename BaseClassRef::ElementType ElementType; typedef typename BaseClassRef::DistanceType DistanceType; typedef typename BaseClassRef::Node Node; typedef Node *NodePtr; typedef typename BaseClassRef::Interval Interval; /** Define "BoundingBox" as a fixed-size or variable-size container depending * on "DIM" */ typedef typename BaseClassRef::BoundingBox BoundingBox; /** Define "distance_vector_t" as a fixed-size or variable-size container * depending on "DIM" */ typedef typename BaseClassRef::distance_vector_t distance_vector_t; /** * KDTree constructor * * Refer to docs in README.md or online in * https://github.com/jlblancoc/nanoflann * * The KD-Tree point dimension (the length of each point in the datase, e.g. 3 * for 3D points) is determined by means of: * - The \a DIM template parameter if >0 (highest priority) * - Otherwise, the \a dimensionality parameter of this constructor. * * @param inputData Dataset with the input features * @param params Basically, the maximum leaf node size */ KDTreeSingleIndexAdaptor(const int dimensionality, const DatasetAdaptor &inputData, const KDTreeSingleIndexAdaptorParams &params = KDTreeSingleIndexAdaptorParams()) : dataset(inputData), index_params(params), distance(inputData) { BaseClassRef::root_node = NULL; BaseClassRef::m_size = dataset.kdtree_get_point_count(); BaseClassRef::m_size_at_index_build = BaseClassRef::m_size; BaseClassRef::dim = dimensionality; if (DIM > 0) BaseClassRef::dim = DIM; BaseClassRef::m_leaf_max_size = params.leaf_max_size; // Create a permutable array of indices to the input vectors. init_vind(); } /** * Builds the index */ void buildIndex() { BaseClassRef::m_size = dataset.kdtree_get_point_count(); BaseClassRef::m_size_at_index_build = BaseClassRef::m_size; init_vind(); this->freeIndex(*this); BaseClassRef::m_size_at_index_build = BaseClassRef::m_size; if (BaseClassRef::m_size == 0) return; computeBoundingBox(BaseClassRef::root_bbox); BaseClassRef::root_node = this->divideTree(*this, 0, BaseClassRef::m_size, BaseClassRef::root_bbox); // construct the tree } /** \name Query methods * @{ */ /** * Find set of nearest neighbors to vec[0:dim-1]. Their indices are stored * inside the result object. * * Params: * result = the result object in which the indices of the * nearest-neighbors are stored vec = the vector for which to search the * nearest neighbors * * \tparam RESULTSET Should be any ResultSet<DistanceType> * \return True if the requested neighbors could be found. * \sa knnSearch, radiusSearch */ template <typename RESULTSET> bool findNeighbors(RESULTSET &result, const ElementType *vec, const SearchParams &searchParams) const { assert(vec); if (this->size(*this) == 0) return false; if (!BaseClassRef::root_node) throw std::runtime_error( "[nanoflann] findNeighbors() called before building the index."); float epsError = 1 + searchParams.eps; distance_vector_t dists; // fixed or variable-sized container (depending on DIM) auto zero = static_cast<decltype(result.worstDist())>(0); assign(dists, (DIM > 0 ? DIM : BaseClassRef::dim), zero); // Fill it with zeros. DistanceType distsq = this->computeInitialDistances(*this, vec, dists); searchLevel(result, vec, BaseClassRef::root_node, distsq, dists, epsError); // "count_leaf" parameter removed since was neither // used nor returned to the user. return result.full(); } /** * Find the "num_closest" nearest neighbors to the \a query_point[0:dim-1]. * Their indices are stored inside the result object. \sa radiusSearch, * findNeighbors \note nChecks_IGNORED is ignored but kept for compatibility * with the original FLANN interface. \return Number `N` of valid points in * the result set. Only the first `N` entries in `out_indices` and * `out_distances_sq` will be valid. Return may be less than `num_closest` * only if the number of elements in the tree is less than `num_closest`. */ size_t knnSearch(const ElementType *query_point, const size_t num_closest, IndexType *out_indices, DistanceType *out_distances_sq, const int /* nChecks_IGNORED */ = 10) const { nanoflann::KNNResultSet<DistanceType, IndexType> resultSet(num_closest); resultSet.init(out_indices, out_distances_sq); this->findNeighbors(resultSet, query_point, nanoflann::SearchParams()); return resultSet.size(); } /** * Find all the neighbors to \a query_point[0:dim-1] within a maximum radius. * The output is given as a vector of pairs, of which the first element is a * point index and the second the corresponding distance. Previous contents of * \a IndicesDists are cleared. * * If searchParams.sorted==true, the output list is sorted by ascending * distances. * * For a better performance, it is advisable to do a .reserve() on the vector * if you have any wild guess about the number of expected matches. * * \sa knnSearch, findNeighbors, radiusSearchCustomCallback * \return The number of points within the given radius (i.e. indices.size() * or dists.size() ) */ size_t radiusSearch(const ElementType *query_point, const DistanceType &radius, std::vector<std::pair<IndexType, DistanceType>> &IndicesDists, const SearchParams &searchParams) const { RadiusResultSet<DistanceType, IndexType> resultSet(radius, IndicesDists); const size_t nFound = radiusSearchCustomCallback(query_point, resultSet, searchParams); if (searchParams.sorted) std::sort(IndicesDists.begin(), IndicesDists.end(), IndexDist_Sorter()); return nFound; } /** * Just like radiusSearch() but with a custom callback class for each point * found in the radius of the query. See the source of RadiusResultSet<> as a * start point for your own classes. \sa radiusSearch */ template <class SEARCH_CALLBACK> size_t radiusSearchCustomCallback( const ElementType *query_point, SEARCH_CALLBACK &resultSet, const SearchParams &searchParams = SearchParams()) const { this->findNeighbors(resultSet, query_point, searchParams); return resultSet.size(); } /** @} */ public: /** Make sure the auxiliary list \a vind has the same size than the current * dataset, and re-generate if size has changed. */ void init_vind() { // Create a permutable array of indices to the input vectors. BaseClassRef::m_size = dataset.kdtree_get_point_count(); if (BaseClassRef::vind.size() != BaseClassRef::m_size) BaseClassRef::vind.resize(BaseClassRef::m_size); for (size_t i = 0; i < BaseClassRef::m_size; i++) BaseClassRef::vind[i] = i; } void computeBoundingBox(BoundingBox &bbox) { resize(bbox, (DIM > 0 ? DIM : BaseClassRef::dim)); if (dataset.kdtree_get_bbox(bbox)) { // Done! It was implemented in derived class } else { const size_t N = dataset.kdtree_get_point_count(); if (!N) throw std::runtime_error("[nanoflann] computeBoundingBox() called but " "no data points found."); for (int i = 0; i < (DIM > 0 ? DIM : BaseClassRef::dim); ++i) { bbox[i].low = bbox[i].high = this->dataset_get(*this, 0, i); } for (size_t k = 1; k < N; ++k) { for (int i = 0; i < (DIM > 0 ? DIM : BaseClassRef::dim); ++i) { if (this->dataset_get(*this, k, i) < bbox[i].low) bbox[i].low = this->dataset_get(*this, k, i); if (this->dataset_get(*this, k, i) > bbox[i].high) bbox[i].high = this->dataset_get(*this, k, i); } } } } /** * Performs an exact search in the tree starting from a node. * \tparam RESULTSET Should be any ResultSet<DistanceType> * \return true if the search should be continued, false if the results are * sufficient */ template <class RESULTSET> bool searchLevel(RESULTSET &result_set, const ElementType *vec, const NodePtr node, DistanceType mindistsq, distance_vector_t &dists, const float epsError) const { /* If this is a leaf node, then do check and return. */ if ((node->child1 == NULL) && (node->child2 == NULL)) { // count_leaf += (node->lr.right-node->lr.left); // Removed since was // neither used nor returned to the user. DistanceType worst_dist = result_set.worstDist(); for (IndexType i = node->node_type.lr.left; i < node->node_type.lr.right; ++i) { const IndexType index = BaseClassRef::vind[i]; // reorder... : i; DistanceType dist = distance.evalMetric( vec, index, (DIM > 0 ? DIM : BaseClassRef::dim)); if (dist < worst_dist) { if (!result_set.addPoint(dist, BaseClassRef::vind[i])) { // the resultset doesn't want to receive any more points, we're done // searching! return false; } } } return true; } /* Which child branch should be taken first? */ int idx = node->node_type.sub.divfeat; ElementType val = vec[idx]; DistanceType diff1 = val - node->node_type.sub.divlow; DistanceType diff2 = val - node->node_type.sub.divhigh; NodePtr bestChild; NodePtr otherChild; DistanceType cut_dist; if ((diff1 + diff2) < 0) { bestChild = node->child1; otherChild = node->child2; cut_dist = distance.accum_dist(val, node->node_type.sub.divhigh, idx); } else { bestChild = node->child2; otherChild = node->child1; cut_dist = distance.accum_dist(val, node->node_type.sub.divlow, idx); } /* Call recursively to search next level down. */ if (!searchLevel(result_set, vec, bestChild, mindistsq, dists, epsError)) { // the resultset doesn't want to receive any more points, we're done // searching! return false; } DistanceType dst = dists[idx]; mindistsq = mindistsq + cut_dist - dst; dists[idx] = cut_dist; if (mindistsq * epsError <= result_set.worstDist()) { if (!searchLevel(result_set, vec, otherChild, mindistsq, dists, epsError)) { // the resultset doesn't want to receive any more points, we're done // searching! return false; } } dists[idx] = dst; return true; } public: /** Stores the index in a binary file. * IMPORTANT NOTE: The set of data points is NOT stored in the file, so when * loading the index object it must be constructed associated to the same * source of data points used while building it. See the example: * examples/saveload_example.cpp \sa loadIndex */ void saveIndex(FILE *stream) { this->saveIndex_(*this, stream); } /** Loads a previous index from a binary file. * IMPORTANT NOTE: The set of data points is NOT stored in the file, so the * index object must be constructed associated to the same source of data * points used while building the index. See the example: * examples/saveload_example.cpp \sa loadIndex */ void loadIndex(FILE *stream) { this->loadIndex_(*this, stream); } }; // class KDTree /** kd-tree dynamic index * * Contains the k-d trees and other information for indexing a set of points * for nearest-neighbor matching. * * The class "DatasetAdaptor" must provide the following interface (can be * non-virtual, inlined methods): * * \code * // Must return the number of data poins * inline size_t kdtree_get_point_count() const { ... } * * // Must return the dim'th component of the idx'th point in the class: * inline T kdtree_get_pt(const size_t idx, const size_t dim) const { ... } * * // Optional bounding-box computation: return false to default to a standard * bbox computation loop. * // Return true if the BBOX was already computed by the class and returned * in "bb" so it can be avoided to redo it again. * // Look at bb.size() to find out the expected dimensionality (e.g. 2 or 3 * for point clouds) template <class BBOX> bool kdtree_get_bbox(BBOX &bb) const * { * bb[0].low = ...; bb[0].high = ...; // 0th dimension limits * bb[1].low = ...; bb[1].high = ...; // 1st dimension limits * ... * return true; * } * * \endcode * * \tparam DatasetAdaptor The user-provided adaptor (see comments above). * \tparam Distance The distance metric to use: nanoflann::metric_L1, * nanoflann::metric_L2, nanoflann::metric_L2_Simple, etc. \tparam DIM * Dimensionality of data points (e.g. 3 for 3D points) \tparam IndexType Will * be typically size_t or int */ template <typename Distance, class DatasetAdaptor, int DIM = -1, typename IndexType = size_t> class KDTreeSingleIndexDynamicAdaptor_ : public KDTreeBaseClass<KDTreeSingleIndexDynamicAdaptor_< Distance, DatasetAdaptor, DIM, IndexType>, Distance, DatasetAdaptor, DIM, IndexType> { public: /** * The dataset used by this index */ const DatasetAdaptor &dataset; //!< The source of our data KDTreeSingleIndexAdaptorParams index_params; std::vector<int> &treeIndex; Distance distance; typedef typename nanoflann::KDTreeBaseClass< nanoflann::KDTreeSingleIndexDynamicAdaptor_<Distance, DatasetAdaptor, DIM, IndexType>, Distance, DatasetAdaptor, DIM, IndexType> BaseClassRef; typedef typename BaseClassRef::ElementType ElementType; typedef typename BaseClassRef::DistanceType DistanceType; typedef typename BaseClassRef::Node Node; typedef Node *NodePtr; typedef typename BaseClassRef::Interval Interval; /** Define "BoundingBox" as a fixed-size or variable-size container depending * on "DIM" */ typedef typename BaseClassRef::BoundingBox BoundingBox; /** Define "distance_vector_t" as a fixed-size or variable-size container * depending on "DIM" */ typedef typename BaseClassRef::distance_vector_t distance_vector_t; /** * KDTree constructor * * Refer to docs in README.md or online in * https://github.com/jlblancoc/nanoflann * * The KD-Tree point dimension (the length of each point in the datase, e.g. 3 * for 3D points) is determined by means of: * - The \a DIM template parameter if >0 (highest priority) * - Otherwise, the \a dimensionality parameter of this constructor. * * @param inputData Dataset with the input features * @param params Basically, the maximum leaf node size */ KDTreeSingleIndexDynamicAdaptor_( const int dimensionality, const DatasetAdaptor &inputData, std::vector<int> &treeIndex_, const KDTreeSingleIndexAdaptorParams &params = KDTreeSingleIndexAdaptorParams()) : dataset(inputData), index_params(params), treeIndex(treeIndex_), distance(inputData) { BaseClassRef::root_node = NULL; BaseClassRef::m_size = 0; BaseClassRef::m_size_at_index_build = 0; BaseClassRef::dim = dimensionality; if (DIM > 0) BaseClassRef::dim = DIM; BaseClassRef::m_leaf_max_size = params.leaf_max_size; } /** Assignment operator definiton */ KDTreeSingleIndexDynamicAdaptor_ operator=(const KDTreeSingleIndexDynamicAdaptor_ &rhs) { KDTreeSingleIndexDynamicAdaptor_ tmp(rhs); std::swap(BaseClassRef::vind, tmp.BaseClassRef::vind); std::swap(BaseClassRef::m_leaf_max_size, tmp.BaseClassRef::m_leaf_max_size); std::swap(index_params, tmp.index_params); std::swap(treeIndex, tmp.treeIndex); std::swap(BaseClassRef::m_size, tmp.BaseClassRef::m_size); std::swap(BaseClassRef::m_size_at_index_build, tmp.BaseClassRef::m_size_at_index_build); std::swap(BaseClassRef::root_node, tmp.BaseClassRef::root_node); std::swap(BaseClassRef::root_bbox, tmp.BaseClassRef::root_bbox); std::swap(BaseClassRef::pool, tmp.BaseClassRef::pool); return *this; } /** * Builds the index */ void buildIndex() { BaseClassRef::m_size = BaseClassRef::vind.size(); this->freeIndex(*this); BaseClassRef::m_size_at_index_build = BaseClassRef::m_size; if (BaseClassRef::m_size == 0) return; computeBoundingBox(BaseClassRef::root_bbox); BaseClassRef::root_node = this->divideTree(*this, 0, BaseClassRef::m_size, BaseClassRef::root_bbox); // construct the tree } /** \name Query methods * @{ */ /** * Find set of nearest neighbors to vec[0:dim-1]. Their indices are stored * inside the result object. * * Params: * result = the result object in which the indices of the * nearest-neighbors are stored vec = the vector for which to search the * nearest neighbors * * \tparam RESULTSET Should be any ResultSet<DistanceType> * \return True if the requested neighbors could be found. * \sa knnSearch, radiusSearch */ template <typename RESULTSET> bool findNeighbors(RESULTSET &result, const ElementType *vec, const SearchParams &searchParams) const { assert(vec); if (this->size(*this) == 0) return false; if (!BaseClassRef::root_node) return false; float epsError = 1 + searchParams.eps; // fixed or variable-sized container (depending on DIM) distance_vector_t dists; // Fill it with zeros. assign(dists, (DIM > 0 ? DIM : BaseClassRef::dim), static_cast<typename distance_vector_t::value_type>(0)); DistanceType distsq = this->computeInitialDistances(*this, vec, dists); searchLevel(result, vec, BaseClassRef::root_node, distsq, dists, epsError); // "count_leaf" parameter removed since was neither // used nor returned to the user. return result.full(); } /** * Find the "num_closest" nearest neighbors to the \a query_point[0:dim-1]. * Their indices are stored inside the result object. \sa radiusSearch, * findNeighbors \note nChecks_IGNORED is ignored but kept for compatibility * with the original FLANN interface. \return Number `N` of valid points in * the result set. Only the first `N` entries in `out_indices` and * `out_distances_sq` will be valid. Return may be less than `num_closest` * only if the number of elements in the tree is less than `num_closest`. */ size_t knnSearch(const ElementType *query_point, const size_t num_closest, IndexType *out_indices, DistanceType *out_distances_sq, const int /* nChecks_IGNORED */ = 10) const { nanoflann::KNNResultSet<DistanceType, IndexType> resultSet(num_closest); resultSet.init(out_indices, out_distances_sq); this->findNeighbors(resultSet, query_point, nanoflann::SearchParams()); return resultSet.size(); } /** * Find all the neighbors to \a query_point[0:dim-1] within a maximum radius. * The output is given as a vector of pairs, of which the first element is a * point index and the second the corresponding distance. Previous contents of * \a IndicesDists are cleared. * * If searchParams.sorted==true, the output list is sorted by ascending * distances. * * For a better performance, it is advisable to do a .reserve() on the vector * if you have any wild guess about the number of expected matches. * * \sa knnSearch, findNeighbors, radiusSearchCustomCallback * \return The number of points within the given radius (i.e. indices.size() * or dists.size() ) */ size_t radiusSearch(const ElementType *query_point, const DistanceType &radius, std::vector<std::pair<IndexType, DistanceType>> &IndicesDists, const SearchParams &searchParams) const { RadiusResultSet<DistanceType, IndexType> resultSet(radius, IndicesDists); const size_t nFound = radiusSearchCustomCallback(query_point, resultSet, searchParams); if (searchParams.sorted) std::sort(IndicesDists.begin(), IndicesDists.end(), IndexDist_Sorter()); return nFound; } /** * Just like radiusSearch() but with a custom callback class for each point * found in the radius of the query. See the source of RadiusResultSet<> as a * start point for your own classes. \sa radiusSearch */ template <class SEARCH_CALLBACK> size_t radiusSearchCustomCallback( const ElementType *query_point, SEARCH_CALLBACK &resultSet, const SearchParams &searchParams = SearchParams()) const { this->findNeighbors(resultSet, query_point, searchParams); return resultSet.size(); } /** @} */ public: void computeBoundingBox(BoundingBox &bbox) { resize(bbox, (DIM > 0 ? DIM : BaseClassRef::dim)); if (dataset.kdtree_get_bbox(bbox)) { // Done! It was implemented in derived class } else { const size_t N = BaseClassRef::m_size; if (!N) throw std::runtime_error("[nanoflann] computeBoundingBox() called but " "no data points found."); for (int i = 0; i < (DIM > 0 ? DIM : BaseClassRef::dim); ++i) { bbox[i].low = bbox[i].high = this->dataset_get(*this, BaseClassRef::vind[0], i); } for (size_t k = 1; k < N; ++k) { for (int i = 0; i < (DIM > 0 ? DIM : BaseClassRef::dim); ++i) { if (this->dataset_get(*this, BaseClassRef::vind[k], i) < bbox[i].low) bbox[i].low = this->dataset_get(*this, BaseClassRef::vind[k], i); if (this->dataset_get(*this, BaseClassRef::vind[k], i) > bbox[i].high) bbox[i].high = this->dataset_get(*this, BaseClassRef::vind[k], i); } } } } /** * Performs an exact search in the tree starting from a node. * \tparam RESULTSET Should be any ResultSet<DistanceType> */ template <class RESULTSET> void searchLevel(RESULTSET &result_set, const ElementType *vec, const NodePtr node, DistanceType mindistsq, distance_vector_t &dists, const float epsError) const { /* If this is a leaf node, then do check and return. */ if ((node->child1 == NULL) && (node->child2 == NULL)) { // count_leaf += (node->lr.right-node->lr.left); // Removed since was // neither used nor returned to the user. DistanceType worst_dist = result_set.worstDist(); for (IndexType i = node->node_type.lr.left; i < node->node_type.lr.right; ++i) { const IndexType index = BaseClassRef::vind[i]; // reorder... : i; if (treeIndex[index] == -1) continue; DistanceType dist = distance.evalMetric( vec, index, (DIM > 0 ? DIM : BaseClassRef::dim)); if (dist < worst_dist) { if (!result_set.addPoint( static_cast<typename RESULTSET::DistanceType>(dist), static_cast<typename RESULTSET::IndexType>( BaseClassRef::vind[i]))) { // the resultset doesn't want to receive any more points, we're done // searching! return; // false; } } } return; } /* Which child branch should be taken first? */ int idx = node->node_type.sub.divfeat; ElementType val = vec[idx]; DistanceType diff1 = val - node->node_type.sub.divlow; DistanceType diff2 = val - node->node_type.sub.divhigh; NodePtr bestChild; NodePtr otherChild; DistanceType cut_dist; if ((diff1 + diff2) < 0) { bestChild = node->child1; otherChild = node->child2; cut_dist = distance.accum_dist(val, node->node_type.sub.divhigh, idx); } else { bestChild = node->child2; otherChild = node->child1; cut_dist = distance.accum_dist(val, node->node_type.sub.divlow, idx); } /* Call recursively to search next level down. */ searchLevel(result_set, vec, bestChild, mindistsq, dists, epsError); DistanceType dst = dists[idx]; mindistsq = mindistsq + cut_dist - dst; dists[idx] = cut_dist; if (mindistsq * epsError <= result_set.worstDist()) { searchLevel(result_set, vec, otherChild, mindistsq, dists, epsError); } dists[idx] = dst; } public: /** Stores the index in a binary file. * IMPORTANT NOTE: The set of data points is NOT stored in the file, so when * loading the index object it must be constructed associated to the same * source of data points used while building it. See the example: * examples/saveload_example.cpp \sa loadIndex */ void saveIndex(FILE *stream) { this->saveIndex_(*this, stream); } /** Loads a previous index from a binary file. * IMPORTANT NOTE: The set of data points is NOT stored in the file, so the * index object must be constructed associated to the same source of data * points used while building the index. See the example: * examples/saveload_example.cpp \sa loadIndex */ void loadIndex(FILE *stream) { this->loadIndex_(*this, stream); } }; /** kd-tree dynaimic index * * class to create multiple static index and merge their results to behave as * single dynamic index as proposed in Logarithmic Approach. * * Example of usage: * examples/dynamic_pointcloud_example.cpp * * \tparam DatasetAdaptor The user-provided adaptor (see comments above). * \tparam Distance The distance metric to use: nanoflann::metric_L1, * nanoflann::metric_L2, nanoflann::metric_L2_Simple, etc. \tparam DIM * Dimensionality of data points (e.g. 3 for 3D points) \tparam IndexType Will * be typically size_t or int */ template <typename Distance, class DatasetAdaptor, int DIM = -1, typename IndexType = size_t> class KDTreeSingleIndexDynamicAdaptor { public: typedef typename Distance::ElementType ElementType; typedef typename Distance::DistanceType DistanceType; protected: size_t m_leaf_max_size; size_t treeCount; size_t pointCount; /** * The dataset used by this index */ const DatasetAdaptor &dataset; //!< The source of our data std::vector<int> treeIndex; //!< treeIndex[idx] is the index of tree in which //!< point at idx is stored. treeIndex[idx]=-1 //!< means that point has been removed. KDTreeSingleIndexAdaptorParams index_params; int dim; //!< Dimensionality of each data point typedef KDTreeSingleIndexDynamicAdaptor_<Distance, DatasetAdaptor, DIM> index_container_t; std::vector<index_container_t> index; public: /** Get a const ref to the internal list of indices; the number of indices is * adapted dynamically as the dataset grows in size. */ const std::vector<index_container_t> &getAllIndices() const { return index; } private: /** finds position of least significant unset bit */ int First0Bit(IndexType num) { int pos = 0; while (num & 1) { num = num >> 1; pos++; } return pos; } /** Creates multiple empty trees to handle dynamic support */ void init() { typedef KDTreeSingleIndexDynamicAdaptor_<Distance, DatasetAdaptor, DIM> my_kd_tree_t; std::vector<my_kd_tree_t> index_( treeCount, my_kd_tree_t(dim /*dim*/, dataset, treeIndex, index_params)); index = index_; } public: Distance distance; /** * KDTree constructor * * Refer to docs in README.md or online in * https://github.com/jlblancoc/nanoflann * * The KD-Tree point dimension (the length of each point in the datase, e.g. 3 * for 3D points) is determined by means of: * - The \a DIM template parameter if >0 (highest priority) * - Otherwise, the \a dimensionality parameter of this constructor. * * @param inputData Dataset with the input features * @param params Basically, the maximum leaf node size */ KDTreeSingleIndexDynamicAdaptor(const int dimensionality, const DatasetAdaptor &inputData, const KDTreeSingleIndexAdaptorParams &params = KDTreeSingleIndexAdaptorParams(), const size_t maximumPointCount = 1000000000U) : dataset(inputData), index_params(params), distance(inputData) { treeCount = static_cast<size_t>(std::log2(maximumPointCount)); pointCount = 0U; dim = dimensionality; treeIndex.clear(); if (DIM > 0) dim = DIM; m_leaf_max_size = params.leaf_max_size; init(); const size_t num_initial_points = dataset.kdtree_get_point_count(); if (num_initial_points > 0) { addPoints(0, num_initial_points - 1); } } /** Deleted copy constructor*/ KDTreeSingleIndexDynamicAdaptor( const KDTreeSingleIndexDynamicAdaptor<Distance, DatasetAdaptor, DIM, IndexType> &) = delete; /** Add points to the set, Inserts all points from [start, end] */ void addPoints(IndexType start, IndexType end) { size_t count = end - start + 1; treeIndex.resize(treeIndex.size() + count); for (IndexType idx = start; idx <= end; idx++) { int pos = First0Bit(pointCount); index[pos].vind.clear(); treeIndex[pointCount] = pos; for (int i = 0; i < pos; i++) { for (int j = 0; j < static_cast<int>(index[i].vind.size()); j++) { index[pos].vind.push_back(index[i].vind[j]); if (treeIndex[index[i].vind[j]] != -1) treeIndex[index[i].vind[j]] = pos; } index[i].vind.clear(); index[i].freeIndex(index[i]); } index[pos].vind.push_back(idx); index[pos].buildIndex(); pointCount++; } } /** Remove a point from the set (Lazy Deletion) */ void removePoint(size_t idx) { if (idx >= pointCount) return; treeIndex[idx] = -1; } /** * Find set of nearest neighbors to vec[0:dim-1]. Their indices are stored * inside the result object. * * Params: * result = the result object in which the indices of the * nearest-neighbors are stored vec = the vector for which to search the * nearest neighbors * * \tparam RESULTSET Should be any ResultSet<DistanceType> * \return True if the requested neighbors could be found. * \sa knnSearch, radiusSearch */ template <typename RESULTSET> bool findNeighbors(RESULTSET &result, const ElementType *vec, const SearchParams &searchParams) const { for (size_t i = 0; i < treeCount; i++) { index[i].findNeighbors(result, &vec[0], searchParams); } return result.full(); } }; /** An L2-metric KD-tree adaptor for working with data directly stored in an * Eigen Matrix, without duplicating the data storage. Each row in the matrix * represents a point in the state space. * * Example of usage: * \code * Eigen::Matrix<num_t,Dynamic,Dynamic> mat; * // Fill out "mat"... * * typedef KDTreeEigenMatrixAdaptor< Eigen::Matrix<num_t,Dynamic,Dynamic> > * my_kd_tree_t; const int max_leaf = 10; my_kd_tree_t mat_index(mat, max_leaf * ); mat_index.index->buildIndex(); mat_index.index->... \endcode * * \tparam DIM If set to >0, it specifies a compile-time fixed dimensionality * for the points in the data set, allowing more compiler optimizations. \tparam * Distance The distance metric to use: nanoflann::metric_L1, * nanoflann::metric_L2, nanoflann::metric_L2_Simple, etc. */ template <class MatrixType, int DIM = -1, class Distance = nanoflann::metric_L2> struct KDTreeEigenMatrixAdaptor { typedef KDTreeEigenMatrixAdaptor<MatrixType, DIM, Distance> self_t; typedef typename MatrixType::Scalar num_t; typedef typename MatrixType::Index IndexType; typedef typename Distance::template traits<num_t, self_t>::distance_t metric_t; typedef KDTreeSingleIndexAdaptor<metric_t, self_t, MatrixType::ColsAtCompileTime, IndexType> index_t; index_t *index; //! The kd-tree index for the user to call its methods as //! usual with any other FLANN index. /// Constructor: takes a const ref to the matrix object with the data points KDTreeEigenMatrixAdaptor(const size_t dimensionality, const std::reference_wrapper<const MatrixType> &mat, const int leaf_max_size = 10) : m_data_matrix(mat) { const auto dims = mat.get().cols(); if (size_t(dims) != dimensionality) throw std::runtime_error( "Error: 'dimensionality' must match column count in data matrix"); if (DIM > 0 && int(dims) != DIM) throw std::runtime_error( "Data set dimensionality does not match the 'DIM' template argument"); index = new index_t(static_cast<int>(dims), *this /* adaptor */, nanoflann::KDTreeSingleIndexAdaptorParams(leaf_max_size)); index->buildIndex(); } public: /** Deleted copy constructor */ KDTreeEigenMatrixAdaptor(const self_t &) = delete; ~KDTreeEigenMatrixAdaptor() { delete index; } const std::reference_wrapper<const MatrixType> m_data_matrix; /** Query for the \a num_closest closest points to a given point (entered as * query_point[0:dim-1]). Note that this is a short-cut method for * index->findNeighbors(). The user can also call index->... methods as * desired. \note nChecks_IGNORED is ignored but kept for compatibility with * the original FLANN interface. */ inline void query(const num_t *query_point, const size_t num_closest, IndexType *out_indices, num_t *out_distances_sq, const int /* nChecks_IGNORED */ = 10) const { nanoflann::KNNResultSet<num_t, IndexType> resultSet(num_closest); resultSet.init(out_indices, out_distances_sq); index->findNeighbors(resultSet, query_point, nanoflann::SearchParams()); } /** @name Interface expected by KDTreeSingleIndexAdaptor * @{ */ const self_t &derived() const { return *this; } self_t &derived() { return *this; } // Must return the number of data points inline size_t kdtree_get_point_count() const { return m_data_matrix.get().rows(); } // Returns the dim'th component of the idx'th point in the class: inline num_t kdtree_get_pt(const IndexType idx, size_t dim) const { return m_data_matrix.get().coeff(idx, IndexType(dim)); } // Optional bounding-box computation: return false to default to a standard // bbox computation loop. // Return true if the BBOX was already computed by the class and returned in // "bb" so it can be avoided to redo it again. Look at bb.size() to find out // the expected dimensionality (e.g. 2 or 3 for point clouds) template <class BBOX> bool kdtree_get_bbox(BBOX & /*bb*/) const { return false; } /** @} */ }; // end of KDTreeEigenMatrixAdaptor /** @} */ /** @} */ // end of grouping } // namespace nanoflann #endif /* NANOFLANN_HPP_ */
73,133
34.779843
80
hpp
LiDAR2LiDAR
LiDAR2LiDAR-master/octree_optimize/include/calibration.hpp
/* * Copyright (C) 2021 by Autonomous Driving Group, Shanghai AI Laboratory * Limited. All rights reserved. * Yan Guohang <[email protected]> */ #pragma once #include <Eigen/Dense> #include <array> #include <map> #include <memory> #include <pcl/io/pcd_io.h> #include <string> #include <vector> #include "logging.hpp" #include "registration_icp.hpp" struct InitialExtrinsic { Eigen::Vector3d euler_angles; Eigen::Vector3d t_matrix; }; struct PlaneParam { PlaneParam() {} PlaneParam(const Eigen::Vector3d &n, double i) : normal(n), intercept(i) {} Eigen::Vector3d normal; double intercept; }; class Calibrator { public: Calibrator(); void LoadCalibrationData( const std::map<int32_t, pcl::PointCloud<pcl::PointXYZI>> lidar_points, const std::map<int32_t, InitialExtrinsic> extrinsics); Eigen::Matrix3d GetRotation(double roll, double pitch, double yaw); Eigen::Matrix4d GetMatrix(const Eigen::Vector3d &translation, const Eigen::Matrix3d &rotation); void Calibrate(); bool GroundPlaneExtraction(const pcl::PointCloud<pcl::PointXYZI>::Ptr &in_cloud, pcl::PointCloud<pcl::PointXYZI>::Ptr g_cloud, pcl::PointCloud<pcl::PointXYZI>::Ptr ng_cloud, PlaneParam &plane); std::map<int32_t, Eigen::Matrix4d> GetFinalTransformation(); private: std::map<int32_t, pcl::PointCloud<pcl::PointXYZI>> pcs_; std::map<int32_t, Eigen::Matrix4d> init_extrinsics_; std::map<int32_t, Eigen::Matrix4d> refined_extrinsics_; std::unique_ptr<ICPRegistrator> registrator_; };
1,609
28.814815
77
hpp
LiDAR2LiDAR
LiDAR2LiDAR-master/octree_optimize/include/logging.hpp
/* * Copyright (C) 2021 by Autonomous Driving Group, Shanghai AI Laboratory * Limited. All rights reserved. * Yan Guohang <[email protected]> */ #ifndef LOGGING_HPP_ #define LOGGING_HPP_ #define OUTPUT #define __FILENAME__ \ (strrchr(__FILE__, '/') ? (strrchr(__FILE__, '/') + 1) : __FILE__) #ifdef OUTPUT #define LOGI(...) \ (printf("[INFO] [%d@%s] ", __LINE__, __FILENAME__), printf(__VA_ARGS__), \ printf("\n")) #define LOGW(...) \ (printf("\33[33m[WARN] [%d@%s] ", __LINE__, __FILENAME__), \ printf(__VA_ARGS__), printf("\033[0m\n")) #define LOGE(...) \ (printf("\33[31m[ERROR] [%d@%s] ", __LINE__, __FILENAME__), \ printf(__VA_ARGS__), printf("\033[0m\n")) #else #define LOGI(...) ((void)0) #define LOGW(...) ((void)0) #define LOGE(...) ((void)0) #endif #ifdef DEBUG #define LOGDEBUG(...) (printf(__VA_ARGS__), printf("\n")) #else #define LOGDEBUG(...) ((void)0) #endif #endif // LOGGING_HPP_
1,208
33.542857
80
hpp
LiDAR2LiDAR
LiDAR2LiDAR-master/octree_optimize/include/registration_icp.hpp
#pragma once #include "logging.hpp" #include <eigen3/Eigen/Core> #include <eigen3/Eigen/Dense> #include <eigen3/Eigen/Geometry> #include <pcl/features/normal_3d.h> #include <pcl/io/pcd_io.h> #include <pcl/kdtree/kdtree_flann.h> #include <pcl/octree/octree_search.h> #include <pcl/point_cloud.h> #include <pcl/registration/icp.h> class ICPRegistrator { public: ICPRegistrator(); void SetTargetCloud(const pcl::PointCloud<pcl::PointXYZI>::Ptr &gcloud, const pcl::PointCloud<pcl::PointXYZI>::Ptr &ngcloud, const pcl::PointCloud<pcl::PointXYZI>::Ptr &cloud); void SetSourceCloud(const pcl::PointCloud<pcl::PointXYZI>::Ptr &gcloud, const pcl::PointCloud<pcl::PointXYZI>::Ptr &ngcloud, const pcl::PointCloud<pcl::PointXYZI>::Ptr &cloud); bool RegistrationByICP(const Eigen::Matrix4d &init_guess, Eigen::Matrix4d &transform); bool RegistrationByICP2(const Eigen::Matrix4d &init_guess, Eigen::Matrix4d &refined_extrinsic); Eigen::Matrix4d GetFinalTransformation(); double CalculateICPError(const pcl::KdTreeFLANN<pcl::PointXYZI> &kdtree, const Eigen::Matrix4d &init_guess, float cur_yaw); void computeNormals(const pcl::PointCloud<pcl::PointXYZI>::Ptr in_pts, pcl::PointCloud<pcl::PointXYZINormal>::Ptr out_pts); bool RegistrationByVoxelOccupancy(const Eigen::Matrix4d &init_guess, Eigen::Matrix4d &refined_extrinsic); size_t ComputeVoxelOccupancy(const Eigen::Matrix4d &init_guess); private: pcl::PointCloud<pcl::PointXYZI>::Ptr tgt_gcloud_; pcl::PointCloud<pcl::PointXYZI>::Ptr tgt_ngcloud_; pcl::PointCloud<pcl::PointXYZI>::Ptr tgt_cloud_; pcl::PointCloud<pcl::PointXYZI>::Ptr src_gcloud_; pcl::PointCloud<pcl::PointXYZI>::Ptr src_ngcloud_; pcl::PointCloud<pcl::PointXYZI>::Ptr src_cloud_; pcl::PointCloud<pcl::PointXYZI>::Ptr all_cloud_; pcl::octree::OctreePointCloudSearch<pcl::PointXYZI>::Ptr all_octree_; Eigen::Matrix4d final_transformation_; };
2,114
41.3
77
hpp
LiDAR2LiDAR
LiDAR2LiDAR-master/octree_optimize/src/calibration.cpp
/* * Copyright (C) 2021 by Autonomous Driving Group, Shanghai AI Laboratory * Limited. All rights reserved. * Yan Guohang <[email protected]> */ #include "calibration.hpp" #include <pcl/common/transforms.h> #include <pcl/conversions.h> #include <pcl/features/normal_3d.h> #include <pcl/filters/conditional_removal.h> #include <pcl/filters/extract_indices.h> #include <pcl/filters/passthrough.h> #include <pcl/kdtree/kdtree_flann.h> #include <pcl/point_types.h> #include <pcl/registration/gicp.h> #include <pcl/registration/icp.h> #include <pcl/registration/icp_nl.h> #include <pcl/registration/ndt.h> #include <pcl/sample_consensus/method_types.h> #include <pcl/sample_consensus/model_types.h> #include <pcl/segmentation/sac_segmentation.h> const double eps = 1.0e-6; Calibrator::Calibrator() { registrator_.reset(new ICPRegistrator); } void Calibrator::LoadCalibrationData( const std::map<int32_t, pcl::PointCloud<pcl::PointXYZI>> lidar_points, const std::map<int32_t, InitialExtrinsic> extrinsics) { pcs_ = lidar_points; for (auto src : extrinsics) { int32_t device_id = src.first; InitialExtrinsic extrinsic = src.second; Eigen::Matrix3d rotation; Eigen::AngleAxisd Rx( Eigen::AngleAxisd(extrinsic.euler_angles[0], Eigen::Vector3d::UnitX())); Eigen::AngleAxisd Ry( Eigen::AngleAxisd(extrinsic.euler_angles[1], Eigen::Vector3d::UnitY())); Eigen::AngleAxisd Rz( Eigen::AngleAxisd(extrinsic.euler_angles[2], Eigen::Vector3d::UnitZ())); rotation = Rz * Ry * Rx; Eigen::Matrix3d rot = rotation; Eigen::Matrix4d init_ext = Eigen::Matrix4d::Identity(); init_ext.block<3, 1>(0, 3) = extrinsic.t_matrix; init_ext.block<3, 3>(0, 0) = rot; init_extrinsics_.insert(std::make_pair(device_id, init_ext)); } } void Calibrator::Calibrate() { Eigen::Matrix4d transform = Eigen::Matrix4d::Identity(); Eigen::Matrix4d curr_transform = Eigen::Matrix4d::Identity(); int32_t master_id = 0; auto master_iter = pcs_.find(master_id); pcl::PointCloud<pcl::PointXYZI> master_pc = master_iter->second; pcl::PointCloud<pcl::PointXYZI>::Ptr master_pc_ptr = master_pc.makeShared(); PlaneParam master_gplane; pcl::PointCloud<pcl::PointXYZI>::Ptr master_gcloud( new pcl::PointCloud<pcl::PointXYZI>); pcl::PointCloud<pcl::PointXYZI>::Ptr master_ngcloud( new pcl::PointCloud<pcl::PointXYZI>); bool ret = GroundPlaneExtraction(master_pc_ptr, master_gcloud, master_ngcloud, master_gplane); if (!ret) { LOGE("ground plane extraction failed.\n"); return; } registrator_->SetTargetCloud(master_gcloud, master_ngcloud, master_pc_ptr); Eigen::Vector3d t_mp(0, 0, -master_gplane.intercept / master_gplane.normal(2)); for (auto iter = pcs_.begin(); iter != pcs_.end(); iter++) { int32_t slave_id = iter->first; if (slave_id == master_id) continue; pcl::PointCloud<pcl::PointXYZI> slave_pc = iter->second; pcl::PointCloud<pcl::PointXYZI> slave_original_pc = slave_pc; if (init_extrinsics_.find(slave_id) == init_extrinsics_.end()) { LOGE("cannot find the init extrinsic, id: %d\n", slave_id); return; } Eigen::Matrix4d init_ext = init_extrinsics_[slave_id]; pcl::PointCloud<pcl::PointXYZI>::Ptr slave_pc_ptr = slave_pc.makeShared(); pcl::PointCloud<pcl::PointXYZI>::Ptr cloud_after_Condition( new pcl::PointCloud<pcl::PointXYZI>); PlaneParam slave_gplane; pcl::PointCloud<pcl::PointXYZI>::Ptr slave_gcloud( new pcl::PointCloud<pcl::PointXYZI>); pcl::PointCloud<pcl::PointXYZI>::Ptr slave_ngcloud( new pcl::PointCloud<pcl::PointXYZI>); // earse the points close to LiDAR if (slave_id) { pcl::ConditionAnd<pcl::PointXYZI>::Ptr range_condition( new pcl::ConditionAnd<pcl::PointXYZI>()); range_condition->addComparison( pcl::FieldComparison<pcl::PointXYZI>::ConstPtr( new pcl::FieldComparison<pcl::PointXYZI>( "x", pcl::ComparisonOps::GT, -1))); range_condition->addComparison( pcl::FieldComparison<pcl::PointXYZI>::ConstPtr( new pcl::FieldComparison<pcl::PointXYZI>( "x", pcl::ComparisonOps::LT, 1))); // range_condition->addComparison( pcl::FieldComparison<pcl::PointXYZI>::ConstPtr( new pcl::FieldComparison<pcl::PointXYZI>( "y", pcl::ComparisonOps::GT, -1.0))); range_condition->addComparison( pcl::FieldComparison<pcl::PointXYZI>::ConstPtr( new pcl::FieldComparison<pcl::PointXYZI>( "y", pcl::ComparisonOps::LT, 1))); range_condition->addComparison( pcl::FieldComparison<pcl::PointXYZI>::ConstPtr( new pcl::FieldComparison<pcl::PointXYZI>( "z", pcl::ComparisonOps::GT, -1))); range_condition->addComparison( pcl::FieldComparison<pcl::PointXYZI>::ConstPtr( new pcl::FieldComparison<pcl::PointXYZI>( "z", pcl::ComparisonOps::LT, 1))); pcl::ConditionalRemoval<pcl::PointXYZI> condition; condition.setCondition(range_condition); condition.setInputCloud(slave_pc_ptr); condition.setKeepOrganized(false); condition.filter(*cloud_after_Condition); pcl::KdTreeFLANN<pcl::PointXYZI> kdtree; pcl::PointXYZI searchPoint; int K = 1; std::vector<int> pointIdxNKNSearch(K); std::vector<float> pointNKNSquaredDistance(K); std::vector<pcl::PointXYZI> DeleteData; int num = 0; for (auto iter = cloud_after_Condition->begin(); iter != cloud_after_Condition->end(); iter++) { searchPoint.x = iter->x; searchPoint.y = iter->y; searchPoint.z = iter->z; kdtree.setInputCloud(slave_pc_ptr); num = kdtree.nearestKSearch(searchPoint, K, pointIdxNKNSearch, pointNKNSquaredDistance); if (num > 0) { if (sqrt(pointNKNSquaredDistance[0]) < eps) { auto iterB = slave_pc_ptr->begin() + pointIdxNKNSearch[0]; slave_pc_ptr->erase(iterB); DeleteData.push_back(searchPoint); if (slave_pc_ptr->size() == 0) { break; } searchPoint.x = 0; searchPoint.y = 0; searchPoint.z = 0; num = 0; pointIdxNKNSearch.clear(); pointNKNSquaredDistance.clear(); } } } } ret = GroundPlaneExtraction(slave_pc_ptr, slave_gcloud, slave_ngcloud, slave_gplane); if (!ret) { LOGE("ground plane extraction failed.\n"); continue; } pcl::PointCloud<pcl::PointXYZI>::Ptr slave_original_pc_ptr = slave_original_pc.makeShared(); PlaneParam slave_original_gplane; pcl::PointCloud<pcl::PointXYZI>::Ptr slave_original_ngcloud( new pcl::PointCloud<pcl::PointXYZI>); pcl::PointCloud<pcl::PointXYZI>::Ptr slave_original_gcloud( new pcl::PointCloud<pcl::PointXYZI>); ret = GroundPlaneExtraction(slave_original_pc_ptr, slave_original_gcloud, slave_original_ngcloud, slave_original_gplane); registrator_->SetSourceCloud(slave_original_gcloud, slave_original_ngcloud, slave_original_pc_ptr); // ground normal direction Eigen::Vector3f ground_point( 0, 0, (slave_gplane.intercept) / (-slave_gplane.normal(2))); Eigen::Vector3f point2plane_vector; int Ontheground = 0; int Undertheground = 0; for (auto iter = slave_ngcloud->begin(); iter < slave_ngcloud->end() - 100; iter += 100) { Eigen::Vector3f samplePoint(iter->x, iter->y, iter->z); point2plane_vector = samplePoint - ground_point; if ((point2plane_vector(0) * slave_gplane.normal(0) + point2plane_vector(1) * slave_gplane.normal(1) + point2plane_vector(2) * slave_gplane.normal(2)) >= 0) { Ontheground++; } else { Undertheground++; } } // ground plane align Eigen::Vector3d rot_axis2 = slave_gplane.normal.cross(master_gplane.normal); rot_axis2.normalize(); double alpha2 = std::acos(slave_gplane.normal.dot(master_gplane.normal)); Eigen::Matrix3d R_ms; R_ms = Eigen::AngleAxisd(alpha2, rot_axis2); Eigen::Vector3d slave_intcpt_local( 0, 0, -slave_gplane.intercept / slave_gplane.normal(2)); Eigen::Vector3d slave_intcpt_master = R_ms * slave_intcpt_local; Eigen::Vector3d t_ms(0, 0, t_mp(2) - slave_intcpt_master(2)); Eigen::Matrix4d T_ms = Eigen::Matrix4d::Identity(); T_ms.block<3, 1>(0, 3) = t_ms; T_ms.block<3, 3>(0, 0) = R_ms; double z_error = std::fabs(t_ms(2) - init_ext(2, 3)); if (z_error > 0.5) { slave_gplane.normal = -slave_gplane.normal; slave_gplane.intercept = -slave_gplane.intercept; rot_axis2 = slave_gplane.normal.cross(master_gplane.normal); rot_axis2.normalize(); alpha2 = std::acos(slave_gplane.normal.dot(master_gplane.normal)); R_ms = Eigen::AngleAxisd(alpha2, rot_axis2); slave_intcpt_local = Eigen::Vector3d( 0, 0, -slave_gplane.intercept / slave_gplane.normal(2)); slave_intcpt_master = R_ms * slave_intcpt_local; t_ms = Eigen::Vector3d(0, 0, t_mp(2) - slave_intcpt_master(2)); T_ms.block<3, 1>(0, 3) = t_ms; T_ms.block<3, 3>(0, 0) = R_ms; } curr_transform = init_ext * T_ms; registrator_->RegistrationByICP(curr_transform, transform); Eigen::Matrix4d final_opt_result; registrator_->RegistrationByICP2(transform, final_opt_result); refined_extrinsics_.insert(std::make_pair(slave_id, final_opt_result)); } } bool Calibrator::GroundPlaneExtraction( const pcl::PointCloud<pcl::PointXYZI>::Ptr &in_cloud, pcl::PointCloud<pcl::PointXYZI>::Ptr g_cloud, pcl::PointCloud<pcl::PointXYZI>::Ptr ng_cloud, PlaneParam &plane) { pcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients); pcl::PointIndices::Ptr inliers(new pcl::PointIndices); pcl::SACSegmentation<pcl::PointXYZI> seg; seg.setOptimizeCoefficients(true); seg.setModelType(pcl::SACMODEL_PLANE); seg.setMethodType(pcl::SAC_RANSAC); seg.setDistanceThreshold(0.2); seg.setInputCloud(in_cloud); seg.segment(*inliers, *coefficients); if (inliers->indices.size() == 0) { PCL_ERROR("Could not estimate a planar model for the given dataset."); return false; } pcl::ExtractIndices<pcl::PointXYZI> extract; extract.setInputCloud(in_cloud); extract.setIndices(inliers); extract.filter(*g_cloud); extract.setNegative(true); extract.filter(*ng_cloud); plane.normal(0) = coefficients->values[0]; plane.normal(1) = coefficients->values[1]; plane.normal(2) = coefficients->values[2]; plane.intercept = coefficients->values[3]; return true; } std::map<int32_t, Eigen::Matrix4d> Calibrator::GetFinalTransformation() { return refined_extrinsics_; }
11,055
39.498168
80
cpp
LiDAR2LiDAR
LiDAR2LiDAR-master/octree_optimize/src/registration_icp.cpp
#include "registration_icp.hpp" #include <limits> #include <pcl/common/transforms.h> #include <pcl/features/normal_3d.h> #include <pcl/registration/gicp.h> #include <pcl/registration/icp_nl.h> #include <pcl/registration/ndt.h> ICPRegistrator::ICPRegistrator() { all_cloud_.reset(new pcl::PointCloud<pcl::PointXYZI>()); all_octree_.reset( new pcl::octree::OctreePointCloudSearch<pcl::PointXYZI>(0.05)); all_octree_->setInputCloud(all_cloud_); } void ICPRegistrator::SetTargetCloud( const pcl::PointCloud<pcl::PointXYZI>::Ptr &gcloud, const pcl::PointCloud<pcl::PointXYZI>::Ptr &ngcloud, const pcl::PointCloud<pcl::PointXYZI>::Ptr &cloud) { tgt_gcloud_ = gcloud; tgt_ngcloud_ = ngcloud; tgt_cloud_ = cloud; } void ICPRegistrator::SetSourceCloud( const pcl::PointCloud<pcl::PointXYZI>::Ptr &gcloud, const pcl::PointCloud<pcl::PointXYZI>::Ptr &ngcloud, const pcl::PointCloud<pcl::PointXYZI>::Ptr &cloud) { src_gcloud_ = gcloud; src_ngcloud_ = ngcloud; src_cloud_ = cloud; } Eigen::Matrix4d ICPRegistrator::GetFinalTransformation() { return final_transformation_; } Eigen::Matrix4d GetDeltaT(const float yaw) { Eigen::Matrix3d deltaR = Eigen::Matrix3d( Eigen::AngleAxisd(yaw * M_PI / 180.0, Eigen::Vector3d::UnitZ()) * Eigen::AngleAxisd(0, Eigen::Vector3d::UnitY()) * Eigen::AngleAxisd(0, Eigen::Vector3d::UnitX())); Eigen::Matrix4d deltaT = Eigen::Matrix4d::Identity(); deltaT.block<3, 3>(0, 0) = deltaR; return deltaT; } bool ICPRegistrator::RegistrationByICP(const Eigen::Matrix4d &init_guess, Eigen::Matrix4d &transform) { pcl::KdTreeFLANN<pcl::PointXYZI> kdtree; kdtree.setInputCloud(tgt_ngcloud_); double cur_yaw = 0; double min_error = CalculateICPError(kdtree, init_guess, cur_yaw); double best_yaw = cur_yaw; float degree_2_radian = 0.017453293; int iter_cnt = 0; double step = 5; // Resolution is 5° int search_range = 10; while (iter_cnt < 5) { for (int delta = -search_range; delta < search_range; delta++) { double yaw = cur_yaw + delta * step * degree_2_radian; double error = CalculateICPError(kdtree, init_guess, yaw); if (error < min_error) { min_error = error; best_yaw = yaw; } } search_range = static_cast<int>(search_range / 2 + 0.5); step /= 2; cur_yaw = best_yaw; iter_cnt++; } Eigen::Matrix4d T = GetDeltaT(best_yaw); T = T * init_guess; transform = T; return true; } double ICPRegistrator::CalculateICPError( const pcl::KdTreeFLANN<pcl::PointXYZI> &kdtree, const Eigen::Matrix4d &init_guess, float cur_yaw) { Eigen::Matrix4d T = GetDeltaT(cur_yaw) * init_guess; pcl::PointCloud<pcl::PointXYZI> trans_cloud; pcl::transformPointCloud(*src_ngcloud_, trans_cloud, T); double dist_sum = 0; for (size_t j = 0; j < trans_cloud.points.size(); j++) { std::vector<int> indices; std::vector<float> distances; int k = 1; pcl::PointXYZI point = trans_cloud.points[j]; int size = kdtree.nearestKSearch(point, k, indices, distances); if (distances.size() > 0) { dist_sum += distances[0]; } else { LOGI("no nearest neighbors found"); } } return dist_sum; } bool ICPRegistrator::RegistrationByICP2(const Eigen::Matrix4d &init_guess, Eigen::Matrix4d &refined_extrinsic) { pcl::PointCloud<pcl::PointXYZI> trans_cloud; pcl::transformPointCloud(*src_cloud_, trans_cloud, init_guess); LOGI("compute normals of source points cloud."); pcl::PointCloud<pcl::PointXYZINormal>::Ptr cloud_before_normal( new pcl::PointCloud<pcl::PointXYZINormal>); computeNormals(trans_cloud.makeShared(), cloud_before_normal); LOGI("compute normals of target points cloud."); pcl::PointCloud<pcl::PointXYZINormal>::Ptr cloud_tgt_normal( new pcl::PointCloud<pcl::PointXYZINormal>); computeNormals(tgt_cloud_, cloud_tgt_normal); pcl::IterativeClosestPointWithNormals<pcl::PointXYZINormal, pcl::PointXYZINormal> icp; icp.setInputSource(cloud_before_normal); icp.setInputTarget(cloud_tgt_normal); icp.setMaximumIterations(10); // icp.setMaxCorrespondenceDistance(1.0); // 1.5m icp.setMaxCorrespondenceDistance(0.3); // 1.5m pcl::PointCloud<pcl::PointXYZINormal> cloud_out; icp.align(cloud_out); Eigen::Matrix4f transform = icp.getFinalTransformation(); refined_extrinsic = transform.cast<double>() * init_guess; return true; } void ICPRegistrator::computeNormals( const pcl::PointCloud<pcl::PointXYZI>::Ptr in_pts, pcl::PointCloud<pcl::PointXYZINormal>::Ptr out_pts) { pcl::NormalEstimation<pcl::PointXYZI, pcl::PointXYZINormal> norm_est; pcl::search::KdTree<pcl::PointXYZI>::Ptr tree( new pcl::search::KdTree<pcl::PointXYZI>()); norm_est.setSearchMethod(tree); norm_est.setKSearch(40); // norm_est.setRadiusSearch(5); norm_est.setInputCloud(in_pts); norm_est.compute(*out_pts); LOGI("normal point cloud number: %d\n", out_pts->size()); for (int i = 0; i < out_pts->size(); ++i) { (*out_pts)[i].x = (*in_pts)[i].x; (*out_pts)[i].y = (*in_pts)[i].y; (*out_pts)[i].z = (*in_pts)[i].z; } }
5,233
33.20915
77
cpp
LiDAR2LiDAR
LiDAR2LiDAR-master/octree_optimize/src/run_lidar2lidar.cpp
#include <chrono> // NOLINT #include <iostream> #include <pcl/common/transforms.h> #include <thread> // NOLINT #include <time.h> #include "calibration.hpp" unsigned char color_map[10][3] = {{255, 255, 255}, // "white" {255, 0, 0}, // "red" {0, 255, 0}, // "green" {0, 0, 255}, // "blue" {255, 255, 0}, // "yellow" {255, 0, 255}, // "pink" {50, 255, 255}, // "light-blue" {135, 60, 0}, // {150, 240, 80}, // {80, 30, 180}}; // void LoadPointCloud( const std::string &filename, std::map<int32_t, pcl::PointCloud<pcl::PointXYZI>> &lidar_points) { std::ifstream file(filename); if (!file.is_open()) { std::cout << "[ERROR] open file " << filename << " failed." << std::endl; exit(1); } std::string line, tmpStr; while (getline(file, line)) { int32_t device_id; std::string point_cloud_path; pcl::PointCloud<pcl::PointXYZI>::Ptr cloud( new pcl::PointCloud<pcl::PointXYZI>); std::stringstream ss(line); ss >> tmpStr >> device_id; getline(file, line); ss = std::stringstream(line); ss >> tmpStr >> point_cloud_path; if (pcl::io::loadPCDFile(point_cloud_path, *cloud) < 0) { std::cout << "[ERROR] cannot open pcd_file: " << point_cloud_path << "\n"; exit(1); } lidar_points.insert(std::make_pair(device_id, *cloud)); } } void LoadCalibFile(const std::string &filename, std::map<int32_t, InitialExtrinsic> &calib_extrinsic) { std::ifstream file(filename); if (!file.is_open()) { std::cout << "open file " << filename << " failed." << std::endl; exit(1); } float degree_2_radian = 0.017453293; std::string line, tmpStr; while (getline(file, line)) { int32_t device_id; InitialExtrinsic extrinsic; std::stringstream ss(line); ss >> tmpStr >> device_id; getline(file, line); ss = std::stringstream(line); ss >> tmpStr >> extrinsic.euler_angles[0] >> extrinsic.euler_angles[1] >> extrinsic.euler_angles[2] >> extrinsic.t_matrix[0] >> extrinsic.t_matrix[1] >> extrinsic.t_matrix[2]; extrinsic.euler_angles[0] = extrinsic.euler_angles[0] * degree_2_radian; extrinsic.euler_angles[1] = extrinsic.euler_angles[1] * degree_2_radian; extrinsic.euler_angles[2] = extrinsic.euler_angles[2] * degree_2_radian; calib_extrinsic.insert(std::make_pair(device_id, extrinsic)); } } int main(int argc, char *argv[]) { if (argc != 3) { std::cout << "Usage: ./run_lidar2lidar <lidar_file> <calib_file>" "\nexample:\n\t" "./bin/run_lidar2lidar data/0001/lidar_cloud_path.txt " "data/0001/initial_extrinsic.txt" << std::endl; return 0; } auto lidar_file = argv[1]; auto calib_file = argv[2]; std::map<int32_t, pcl::PointCloud<pcl::PointXYZI>> lidar_points; LoadPointCloud(lidar_file, lidar_points); std::map<int32_t, InitialExtrinsic> extrinsics; LoadCalibFile(calib_file, extrinsics); // calibration Calibrator calibrator; calibrator.LoadCalibrationData(lidar_points, extrinsics); auto time_begin = std::chrono::steady_clock::now(); calibrator.Calibrate(); auto time_end = std::chrono::steady_clock::now(); std::cout << "calib cost " << std::chrono::duration<double>(time_end - time_begin).count() << "s" << std::endl; std::map<int32_t, Eigen::Matrix4d> refined_extrinsics = calibrator.GetFinalTransformation(); // stitching pcl::PointCloud<pcl::PointXYZRGB>::Ptr all_cloud( new pcl::PointCloud<pcl::PointXYZRGB>); auto master_iter = lidar_points.find(0); pcl::PointCloud<pcl::PointXYZI> master_pc = master_iter->second; for (auto src : master_pc.points) { int32_t master_id = 0; pcl::PointXYZRGB point; point.x = src.x; point.y = src.y; point.z = src.z; point.r = color_map[master_id % 7][0]; point.g = color_map[master_id % 7][1]; point.b = color_map[master_id % 7][2]; all_cloud->push_back(point); } for (auto iter = refined_extrinsics.begin(); iter != refined_extrinsics.end(); iter++) { int32_t slave_id = iter->first; Eigen::Matrix4d transform = iter->second; auto slave_iter = lidar_points.find(slave_id); pcl::PointCloud<pcl::PointXYZI> slave_pc = slave_iter->second; pcl::PointCloud<pcl::PointXYZI> trans_cloud; pcl::transformPointCloud(slave_pc, trans_cloud, transform); for (auto src : trans_cloud.points) { pcl::PointXYZRGB point; point.x = src.x; point.y = src.y; point.z = src.z; point.r = color_map[slave_id % 7][0]; point.g = color_map[slave_id % 7][1]; point.b = color_map[slave_id % 7][2]; all_cloud->push_back(point); } } all_cloud->height = 1; all_cloud->width = all_cloud->points.size(); std::string path = "stitching.pcd"; pcl::io::savePCDFileBinary(path, *all_cloud); return 0; }
5,193
34.575342
80
cpp
energy_ood
energy_ood-master/CIFAR/run.sh
methods=(pretrained oe_tune) data_models=(cifar10_wrn cifar100_wrn) gpu=0 if [ "$1" = "MSP" ]; then for dm in ${data_models[$2]}; do for method in ${methods[0]}; do # MSP with in-distribution samples as pos echo "-----------"${dm}_${method}" MSP score-----------------" CUDA_VISIBLE_DEVICES=$gpu python test.py --method_name ${dm}_${method} --num_to_avg 10 done done echo "||||||||done with "${dm}_${method}" above |||||||||||||||||||" elif [ "$1" = "energy" ]; then for dm in ${data_models[$2]}; do for method in ${methods[0]}; do echo "-----------"${dm}_${method}" energy score-----------------" CUDA_VISIBLE_DEVICES=$gpu python test.py --method_name ${dm}_${method} --num_to_avg 10 --score energy done done echo "||||||||done with "${dm}_${method}" energy score above |||||||||||||||||||" elif [ "$1" = "M" ]; then for dm in ${data_models[$2]}; do for method in ${methods[0]}; do for noise in 0.0 0.01 0.005 0.002 0.0014 0.001 0.0005; do echo "-----------"${dm}_${method}_M_noise_${noise}"-----------------" CUDA_VISIBLE_DEVICES=$gpu python test.py --method_name ${dm}_${method} --num_to_avg 10 --score M --noise $noise -v done done done echo "||||||||done with "${dm}_${method}_M" noise above|||||||||||||||||||" elif [ "$1" = "Odin" ]; then for T in 1000 100 10 1; do for noise in 0 0.0004 0.0008 0.0014 0.002 0.0024 0.0028 0.0032 0.0038 0.0048; do echo "-------T="${T}_$2" noise="$noise"--------" CUDA_VISIBLE_DEVICES=$gpu python test.py --method_name $2 --score Odin --num_to_avg 10 --T $T --noise $noise -v #--test_bs 50 done echo "||||Odin temperature|||||||||||||||||||||||||||||||||||||||||||" done elif [ "$1" = "oe_tune" ] || [ "$1" = "energy_ft" ]; then # fine-tuning score=OE if [ "$1" = "energy_ft" ]; then # fine-tuning score=energy fi for dm in ${data_models[$2]}; do array=(${dm//_/ }) data=${array[0]} model=${array[1]} for seed in 1; do echo "---Training with dataset: "$data"---model used:"$model"---seed: "$seed"---score used:"$score"---------" if [ "$2" = "0" ]; then m_out=-5 m_in=-23 elif [ "$2" = "1" ]; then m_out=-5 m_in=-27 fi echo "---------------"$m_in"------"$m_out"--------------------" CUDA_VISIBLE_DEVICES=$gpu python train.py $data --model $model --score $score --seed $seed --m_in $m_in --m_out $m_out CUDA_VISIBLE_DEVICES=$gpu python test.py --method_name ${dm}_s${seed}_$1 --num_to_avg 10 --score $score done done echo "||||||||done with training above "$1"|||||||||||||||||||" elif [ "$1" = "T" ]; then for dm in ${data_models[@]}; do for method in ${methods[0]}; do for T in 1 2 5 10 20 50 100 200 500 1000; do echo "-----------"${dm}_${method}_T_${T}"-----------------" CUDA_VISIBLE_DEVICES=$gpu python test.py --method_name ${dm}_${method} --num_to_avg 10 --score energy --T $T done done echo "||||||||done with "${dm}_${method}_T" tempearture above|||||||||||||||||||" done fi
3,282
42.197368
131
sh
pycheops
pycheops-master/docs/_build/html/constants.html
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title>constants &#8212; pycheops 0.0.16 documentation</title> <link rel="stylesheet" href="_static/alabaster.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> <script src="_static/doctools.js"></script> <script src="_static/language_data.js"></script> <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="next" title="funcs" href="funcs.html" /> <link rel="prev" title="Welcome to pycheops’s documentation!" href="index.html" /> <link rel="stylesheet" href="_static/custom.css" type="text/css" /> <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" /> </head><body> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="toctree-wrapper compound"> </div> <span class="target" id="module-pycheops.constants"></span><div class="section" id="constants"> <h1>constants<a class="headerlink" href="#constants" title="Permalink to this headline">¶</a></h1> <p>Nominal values of solar and planetary constants in SI units from IAU Resolution B3 <a class="footnote-reference brackets" href="#id4" id="id1">1</a> plus related constants</p> <p>Masses in SI units are derived using the 2014 CODATA value for the Newtonian constant, <span class="math notranslate nohighlight">\(G=6.67408\times 10^{-11}\,m^3\,kg^{-1}\,s^{-2}\)</span>.</p> <p>The following conversion constants are defined.</p> <div class="section" id="solar-conversion-constants"> <h2>Solar conversion constants<a class="headerlink" href="#solar-conversion-constants" title="Permalink to this headline">¶</a></h2> <ul class="simple"> <li><p>R_SunN - solar radius</p></li> <li><p>S_SunN - total solar irradiance</p></li> <li><p>L_SunN - luminosity</p></li> <li><p>Teff_SunN - solar effective temperature</p></li> <li><p>GM_SunN - solar mass parameter</p></li> <li><p>M_SunN - solar mass derived from GM_SunN and G_2014</p></li> <li><p>V_SunN - solar volume = (4.pi.R_SunN**3/3)</p></li> </ul> </div> <div class="section" id="planetary-conversion-constants"> <h2>Planetary conversion constants<a class="headerlink" href="#planetary-conversion-constants" title="Permalink to this headline">¶</a></h2> <ul class="simple"> <li><p>R_eEarthN - equatorial radius of the Earth</p></li> <li><p>R_pEarthN - polar radius of the Earth</p></li> <li><p>R_eJupN - equatorial radius of Jupiter</p></li> <li><p>R_pJupN - polar radius of Jupiter</p></li> <li><p>GM_EarthN - terrestrial mass parameter</p></li> <li><p>GM_JupN - jovian mass parameter</p></li> <li><p>M_EarthN - mass of the Earth from GM_EarthN and G_2014</p></li> <li><p>M_JupN - mass of Jupiter from GM_JupN and G_2014</p></li> <li><p>V_EarthN - volume of the Earth (4.pi.R_eEarthN^2.R_pEarthN/3)</p></li> <li><p>V_JupN - volume of Jupiter (4.pi.R_eJupN^2.R_pJupN/3)</p></li> <li><p>R_EarthN - volume-average radius of the Earth (3.V_EarthN/4.pi)^(1/3)</p></li> <li><p>R_JupN - volume-average radius of Jupiter (3.V_JupN/4.pi)^(1/3)</p></li> </ul> </div> <div class="section" id="related-constants"> <h2>Related constants<a class="headerlink" href="#related-constants" title="Permalink to this headline">¶</a></h2> <ul class="simple"> <li><p>G_2014 - 2014 CODATA value for the Newtonian constant</p></li> <li><p>mean_solar_day - 86,400.002 seconds <a class="footnote-reference brackets" href="#id5" id="id2">2</a></p></li> <li><p>au - IAU 2009 value for astronomical constant in metres. <a class="footnote-reference brackets" href="#id6" id="id3">3</a></p></li> <li><p>pc - 1 parsec = 3600*au*180/pi</p></li> <li><p>c - speed of light = 299,792,458 m / s</p></li> </ul> </div> <div class="section" id="example"> <h2>Example<a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h2> <p>Calculate the density relative to Jupiter for a planet 1/10 the radius of the Sun with a mass 1/1000 of a solar mass. Note that we use the volume-average radius for Jupiter in this case:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pycheops.constants</span> <span class="kn">import</span> <span class="n">M_SunN</span><span class="p">,</span> <span class="n">R_SunN</span><span class="p">,</span> <span class="n">M_JupN</span><span class="p">,</span> <span class="n">R_JupN</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">M_planet_Jup</span> <span class="o">=</span> <span class="n">M_SunN</span><span class="o">/</span><span class="mi">1000</span> <span class="o">/</span> <span class="n">M_JupN</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">R_planet_Jup</span> <span class="o">=</span> <span class="n">R_SunN</span><span class="o">/</span><span class="mi">10</span> <span class="o">/</span> <span class="n">R_JupN</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">rho_planet_Jup</span> <span class="o">=</span> <span class="n">M_planet_Jup</span> <span class="o">/</span> <span class="p">(</span><span class="n">R_planet_Jup</span><span class="o">**</span><span class="mi">3</span><span class="p">)</span> <span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span> <span class="p">(</span><span class="s2">&quot;Planet mass = </span><span class="si">{:.3f}</span><span class="s2"> M_Jup&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">M_planet_Jup</span><span class="p">))</span> <span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span> <span class="p">(</span><span class="s2">&quot;Planet radius = </span><span class="si">{:.3f}</span><span class="s2"> R_Jup&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">R_planet_Jup</span><span class="p">))</span> <span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span> <span class="p">(</span><span class="s2">&quot;Planet density = </span><span class="si">{:.3f}</span><span class="s2"> rho_Jup&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">rho_planet_Jup</span><span class="p">))</span> <span class="go">Planet mass = 1.048 M_Jup</span> <span class="go">Planet radius = 0.995 R_Jup</span> <span class="go">Planet density = 1.063 rho_Jup</span> </pre></div> </div> <p class="rubric">References</p> <dl class="footnote brackets"> <dt class="label" id="id4"><span class="brackets"><a class="fn-backref" href="#id1">1</a></span></dt> <dd><p><a class="reference external" href="https://www.iau.org/static/resolutions/IAU2015_English.pdf">https://www.iau.org/static/resolutions/IAU2015_English.pdf</a></p> </dd> <dt class="label" id="id5"><span class="brackets"><a class="fn-backref" href="#id2">2</a></span></dt> <dd><p><a class="reference external" href="http://tycho.usno.navy.mil/leapsec.html">http://tycho.usno.navy.mil/leapsec.html</a></p> </dd> <dt class="label" id="id6"><span class="brackets"><a class="fn-backref" href="#id3">3</a></span></dt> <dd><p>Luzum et al., Celest Mech Dyn Astr (2011) 110:293-304</p> </dd> </dl> </div> </div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h1 class="logo"><a href="index.html">pycheops</a></h1> <h3>Navigation</h3> <p class="caption"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1 current"><a class="current reference internal" href="#">constants</a></li> <li class="toctree-l1"><a class="reference internal" href="funcs.html">funcs</a></li> <li class="toctree-l1"><a class="reference internal" href="instrument.html">instrument</a></li> <li class="toctree-l1"><a class="reference internal" href="ld.html">ld</a></li> <li class="toctree-l1"><a class="reference internal" href="models.html">models</a></li> <li class="toctree-l1"><a class="reference internal" href="quantities.html">quantities</a></li> </ul> <div class="relations"> <h3>Related Topics</h3> <ul> <li><a href="index.html">Documentation overview</a><ul> <li>Previous: <a href="index.html" title="previous chapter">Welcome to pycheops’s documentation!</a></li> <li>Next: <a href="funcs.html" title="next chapter">funcs</a></li> </ul></li> </ul> </div> <div id="searchbox" style="display: none" role="search"> <h3 id="searchlabel">Quick search</h3> <div class="searchformwrapper"> <form class="search" action="search.html" method="get"> <input type="text" name="q" aria-labelledby="searchlabel" /> <input type="submit" value="Go" /> </form> </div> </div> <script>$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="footer"> &copy;2018, [email protected]. | Powered by <a href="http://sphinx-doc.org/">Sphinx 2.4.0</a> &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a> | <a href="_sources/constants.rst.txt" rel="nofollow">Page source</a> </div> </body> </html>
9,892
51.068421
415
html
pycheops
pycheops-master/docs/_build/html/funcs.html
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title>funcs &#8212; pycheops 0.0.16 documentation</title> <link rel="stylesheet" href="_static/alabaster.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> <script src="_static/doctools.js"></script> <script src="_static/language_data.js"></script> <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="next" title="instrument" href="instrument.html" /> <link rel="prev" title="constants" href="constants.html" /> <link rel="stylesheet" href="_static/custom.css" type="text/css" /> <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" /> </head><body> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="toctree-wrapper compound"> </div> <span class="target" id="module-pycheops.funcs"></span><div class="section" id="funcs"> <h1>funcs<a class="headerlink" href="#funcs" title="Permalink to this headline">¶</a></h1> <p>Functions relating observable properties of binary stars and exoplanet systems to their fundamental properties, and vice versa. Also functions related to Keplerian orbits.</p> <div class="section" id="parameters"> <h2>Parameters<a class="headerlink" href="#parameters" title="Permalink to this headline">¶</a></h2> <p>Functions are defined in terms of the following parameters. <a class="footnote-reference brackets" href="#id2" id="id1">1</a></p> <ul class="simple"> <li><p>a - orbital semi-major axis in solar radii = a_1 + a_2</p></li> <li><p>P - orbital period in mean solar days</p></li> <li><p>Mass - total system mass in solar masses, Mass = m_1 + m_2</p></li> <li><p>ecc - orbital eccentricity</p></li> <li><p>omdeg - longitude of periastron of star’s orbit, omega, in _degrees_</p></li> <li><p>sini - sine of the orbital inclination</p></li> <li><p>K - 2.pi.a.sini/(P.sqrt(1-e^2)) = K_1 + K_2</p></li> <li><p>K_1, K_2 - orbital semi-amplitudes in km/s</p></li> <li><p>q - mass ratio = m_2/m_1 = K_1/K_2 = a_1/a_2</p></li> <li><dl class="simple"> <dt>f_m - mass function = m_2^3.sini^3/(m_1+m_2)^2 in solar masses </dt><dd><p>= K_1^3.P/(2.pi.G).(1-e^2)^(3/2)</p> </dd> </dl> </li> <li><p>r_1 - radius of star 1 in units of the semi-major axis, r_1 = R_*/a</p></li> <li><p>rhostar - mean stellar density = 3.pi/(GP^2(1+q)r_1^3)</p></li> <li><p>rstar - host star radius/semi-major axis, rstar = R_*/a</p></li> <li><p>k - planet/star radius ratio, k = R_planet/R_star</p></li> <li><p>tzero - time of mid-transit (minimum on-sky star-planet separation).</p></li> <li><p>b - impact parameter, b = a.cos(i)/R_star</p></li> </ul> <dl class="footnote brackets"> <dt class="label" id="id2"><span class="brackets"><a class="fn-backref" href="#id1">1</a></span></dt> <dd><p>Hilditch, R.W., An Introduction to Close Binary Stars, CUP 2001.</p> </dd> </dl> </div> <div class="section" id="functions"> <h2>Functions<a class="headerlink" href="#functions" title="Permalink to this headline">¶</a></h2> <dl class="function"> <dt id="pycheops.funcs.a_rsun"> <code class="sig-prename descclassname">pycheops.funcs.</code><code class="sig-name descname">a_rsun</code><span class="sig-paren">(</span><em class="sig-param">P</em>, <em class="sig-param">Mass</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.funcs.a_rsun" title="Permalink to this definition">¶</a></dt> <dd><p>Semi-major axis in solar radii</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>P</strong> – orbital period in mean solar days</p></li> <li><p><strong>Mass</strong> – total mass in solar masses, M</p></li> </ul> </dd> <dt class="field-even">Returns</dt> <dd class="field-even"><p>a = (G.M.P^2/(4.pi^2))^(1/3) in solar radii</p> </dd> </dl> </dd></dl> <dl class="function"> <dt id="pycheops.funcs.f_m"> <code class="sig-prename descclassname">pycheops.funcs.</code><code class="sig-name descname">f_m</code><span class="sig-paren">(</span><em class="sig-param">P</em>, <em class="sig-param">K</em>, <em class="sig-param">ecc=0</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.funcs.f_m" title="Permalink to this definition">¶</a></dt> <dd><p>Mass function in solar masses</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>P</strong> – orbital period in mean solar days</p></li> <li><p><strong>K</strong> – semi-amplitude of the spectroscopic orbit in km/s</p></li> <li><p><strong>ecc</strong> – orbital eccentricity</p></li> </ul> </dd> <dt class="field-even">Returns</dt> <dd class="field-even"><p>f_m = m_2^3.sini^3/(m_1+m_2)^2 in solar masses</p> </dd> </dl> </dd></dl> <dl class="function"> <dt id="pycheops.funcs.m1sin3i"> <code class="sig-prename descclassname">pycheops.funcs.</code><code class="sig-name descname">m1sin3i</code><span class="sig-paren">(</span><em class="sig-param">P</em>, <em class="sig-param">K_1</em>, <em class="sig-param">K_2</em>, <em class="sig-param">ecc=0</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.funcs.m1sin3i" title="Permalink to this definition">¶</a></dt> <dd><p>Reduced mass of star 1 in solar masses</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>K_1</strong> – semi-amplitude of star 1 in km/s</p></li> <li><p><strong>K_2</strong> – semi-amplitude of star 2 in km/s</p></li> <li><p><strong>P</strong> – orbital period in mean solar days</p></li> <li><p><strong>ecc</strong> – orbital eccentricity</p></li> </ul> </dd> <dt class="field-even">Returns</dt> <dd class="field-even"><p>m_1.sini^3 in solar masses</p> </dd> </dl> </dd></dl> <dl class="function"> <dt id="pycheops.funcs.m2sin3i"> <code class="sig-prename descclassname">pycheops.funcs.</code><code class="sig-name descname">m2sin3i</code><span class="sig-paren">(</span><em class="sig-param">P</em>, <em class="sig-param">K_1</em>, <em class="sig-param">K_2</em>, <em class="sig-param">ecc=0</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.funcs.m2sin3i" title="Permalink to this definition">¶</a></dt> <dd><p>Reduced mass of star 2 in solar masses</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>K_1</strong> – semi-amplitude of star 1 in km/s</p></li> <li><p><strong>K_2</strong> – semi-amplitude of star 2 in km/s</p></li> <li><p><strong>P</strong> – orbital period in mean solar days</p></li> <li><p><strong>ecc</strong> – orbital eccentricity</p></li> </ul> </dd> <dt class="field-even">Returns</dt> <dd class="field-even"><p>m_2.sini^3 in solar masses</p> </dd> </dl> </dd></dl> <dl class="function"> <dt id="pycheops.funcs.asini"> <code class="sig-prename descclassname">pycheops.funcs.</code><code class="sig-name descname">asini</code><span class="sig-paren">(</span><em class="sig-param">K</em>, <em class="sig-param">P</em>, <em class="sig-param">ecc=0</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.funcs.asini" title="Permalink to this definition">¶</a></dt> <dd><p>a.sini in solar radii</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>K</strong> – semi-amplitude of the spectroscopic orbit in km/s</p></li> <li><p><strong>P</strong> – orbital period in mean solar days</p></li> </ul> </dd> <dt class="field-even">Returns</dt> <dd class="field-even"><p>a.sin(i) in solar radii</p> </dd> </dl> </dd></dl> <dl class="function"> <dt id="pycheops.funcs.rhostar"> <code class="sig-prename descclassname">pycheops.funcs.</code><code class="sig-name descname">rhostar</code><span class="sig-paren">(</span><em class="sig-param">r_1</em>, <em class="sig-param">P</em>, <em class="sig-param">q=0</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.funcs.rhostar" title="Permalink to this definition">¶</a></dt> <dd><p>Mean stellar density from scaled stellar radius.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>r_1</strong> – radius of star in units of the semi-major axis, r_1 = R_*/a</p></li> <li><p><strong>P</strong> – orbital period in mean solar days</p></li> <li><p><strong>q</strong> – mass ratio, m_2/m_1</p></li> </ul> </dd> <dt class="field-even">Returns</dt> <dd class="field-even"><p>Mean stellar density in solar units</p> </dd> </dl> </dd></dl> <dl class="function"> <dt id="pycheops.funcs.K_kms"> <code class="sig-prename descclassname">pycheops.funcs.</code><code class="sig-name descname">K_kms</code><span class="sig-paren">(</span><em class="sig-param">m_1</em>, <em class="sig-param">m_2</em>, <em class="sig-param">P</em>, <em class="sig-param">sini</em>, <em class="sig-param">ecc</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.funcs.K_kms" title="Permalink to this definition">¶</a></dt> <dd><dl class="simple"> <dt>Semi-amplitudes of the spectroscopic orbits in km/s</dt><dd><ul class="simple"> <li><p>K = 2.pi.a.sini/(P.sqrt(1-ecc^2))</p></li> <li><p>K_1 = K * m_2/(m_1+m_2)</p></li> <li><p>K_2 = K * m_1/(m_1+m_2)</p></li> </ul> </dd> </dl> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>m_1</strong> – mass of star 1 in solar masses</p></li> <li><p><strong>m_2</strong> – mass of star 2 in solar masses</p></li> <li><p><strong>P</strong> – orbital period in mean solar days</p></li> <li><p><strong>sini</strong> – sine of the orbital inclination</p></li> <li><p><strong>ecc</strong> – orbital eccentrcity</p></li> </ul> </dd> <dt class="field-even">Returns</dt> <dd class="field-even"><p>K_1, K_2 – semi-amplitudes in km/s</p> </dd> </dl> </dd></dl> <dl class="function"> <dt id="pycheops.funcs.m_comp"> <code class="sig-prename descclassname">pycheops.funcs.</code><code class="sig-name descname">m_comp</code><span class="sig-paren">(</span><em class="sig-param">f_m</em>, <em class="sig-param">m_1</em>, <em class="sig-param">sini</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.funcs.m_comp" title="Permalink to this definition">¶</a></dt> <dd><p>Companion mass in solar masses given mass function and stellar mass</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>f_m</strong> – = K_1^3.P/(2.pi.G).(1-ecc^2)^(3/2) in solar masses</p></li> <li><p><strong>m_1</strong> – mass of star 1 in solar masses</p></li> <li><p><strong>sini</strong> – sine of orbital inclination</p></li> </ul> </dd> <dt class="field-even">Returns</dt> <dd class="field-even"><p>m_2 = mass of companion to star 1 in solar masses</p> </dd> </dl> </dd></dl> <dl class="function"> <dt id="pycheops.funcs.transit_width"> <code class="sig-prename descclassname">pycheops.funcs.</code><code class="sig-name descname">transit_width</code><span class="sig-paren">(</span><em class="sig-param">r</em>, <em class="sig-param">k</em>, <em class="sig-param">b</em>, <em class="sig-param">P=1</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.funcs.transit_width" title="Permalink to this definition">¶</a></dt> <dd><p>Total transit duration for a circular orbit.</p> <p>See equation (3) from Seager and Malen-Ornelas, 2003ApJ…585.1038S.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>r</strong> – R_star/a</p></li> <li><p><strong>k</strong> – R_planet/R_star</p></li> <li><p><strong>b</strong> – impact parameter = a.cos(i)/R_star</p></li> <li><p><strong>P</strong> – orbital period (optional, default P=1)</p></li> </ul> </dd> <dt class="field-even">Returns</dt> <dd class="field-even"><p>Total transit duration in the same units as P.</p> </dd> </dl> </dd></dl> <dl class="function"> <dt id="pycheops.funcs.t2z"> <code class="sig-prename descclassname">pycheops.funcs.</code><code class="sig-name descname">t2z</code><span class="sig-paren">(</span><em class="sig-param">t</em>, <em class="sig-param">tzero</em>, <em class="sig-param">P</em>, <em class="sig-param">sini</em>, <em class="sig-param">rstar</em>, <em class="sig-param">ecc=0</em>, <em class="sig-param">omdeg=90</em>, <em class="sig-param">returnMask=False</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.funcs.t2z" title="Permalink to this definition">¶</a></dt> <dd><p>Calculate star-planet separation relative to scaled stellar radius, z</p> <p>Optionally, return a flag/mask to indicate cases where the planet is further from the observer than the star, i.e., whether phases with z&lt;1 are transits (mask==True) or eclipses (mask==False)</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>t</strong> – time of observation (scalar or array)</p></li> <li><p><strong>tzero</strong> – time of inferior conjunction, i.e., mid-transit</p></li> <li><p><strong>P</strong> – orbital period</p></li> <li><p><strong>sini</strong> – sine of orbital inclination</p></li> <li><p><strong>rstar</strong> – scaled stellar radius, R_star/a</p></li> <li><p><strong>ecc</strong> – eccentricity (optional, default=0)</p></li> <li><p><strong>omdeg</strong> – longitude of periastron in degrees (optional, default=90)</p></li> <li><p><strong>returnFlag</strong> – return a flag to distinguish transits from eclipses.</p></li> </ul> </dd> </dl> <p>N.B. omdeg is the longitude of periastron for the star’s orbit</p> <dl class="field-list simple"> <dt class="field-odd">Returns</dt> <dd class="field-odd"><p>z [, mask]</p> </dd> <dt class="field-even">Example</dt> <dd class="field-even"><p></p></dd> </dl> <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pycheops.funcs</span> <span class="kn">import</span> <span class="n">t2z</span> <span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">numpy</span> <span class="kn">import</span> <span class="n">linspace</span> <span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">t</span> <span class="o">=</span> <span class="n">linspace</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1000</span><span class="p">)</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">sini</span> <span class="o">=</span> <span class="mf">0.999</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">rstar</span> <span class="o">=</span> <span class="mf">0.1</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">t2z</span><span class="p">(</span><span class="n">t</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="n">sini</span><span class="p">,</span><span class="n">rstar</span><span class="p">))</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">plt</span><span class="o">.</span><span class="n">xlim</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">12</span><span class="p">)</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">ecc</span> <span class="o">=</span> <span class="mf">0.1</span> <span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">omdeg</span> <span class="ow">in</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">90</span><span class="p">,</span> <span class="mi">180</span><span class="p">,</span> <span class="mi">270</span><span class="p">):</span> <span class="gp">&gt;&gt;&gt; </span> <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">t2z</span><span class="p">(</span><span class="n">t</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="n">sini</span><span class="p">,</span><span class="n">rstar</span><span class="p">,</span><span class="n">ecc</span><span class="p">,</span><span class="n">omdeg</span><span class="p">))</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span> </pre></div> </div> </dd></dl> <dl class="function"> <dt id="pycheops.funcs.tzero2tperi"> <code class="sig-prename descclassname">pycheops.funcs.</code><code class="sig-name descname">tzero2tperi</code><span class="sig-paren">(</span><em class="sig-param">tzero</em>, <em class="sig-param">P</em>, <em class="sig-param">sini</em>, <em class="sig-param">ecc</em>, <em class="sig-param">omdeg</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.funcs.tzero2tperi" title="Permalink to this definition">¶</a></dt> <dd><p>Calculate time of periastron from time of mid-transit</p> <p>Uses the method by Lacy, 1992AJ….104.2213L</p> <dl class="field-list"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>tzero</strong> – times of mid-transit</p></li> <li><p><strong>P</strong> – orbital period</p></li> <li><p><strong>sini</strong> – sine of orbital inclination</p></li> <li><p><strong>ecc</strong> – eccentricity</p></li> <li><p><strong>omdeg</strong> – longitude of periastron in degrees</p></li> </ul> </dd> <dt class="field-even">Returns</dt> <dd class="field-even"><p>time of periastron prior to tzero</p> </dd> <dt class="field-odd">Example</dt> <dd class="field-odd"><div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pycheops.funcs</span> <span class="kn">import</span> <span class="n">tzero2tperi</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">tzero</span> <span class="o">=</span> <span class="mf">54321.6789</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">P</span> <span class="o">=</span> <span class="mf">1.23456</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">sini</span> <span class="o">=</span> <span class="mf">0.987</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">ecc</span> <span class="o">=</span> <span class="mf">0.123</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">omdeg</span> <span class="o">=</span> <span class="mf">89.01</span> <span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">tzero2tperi</span><span class="p">(</span><span class="n">tzero</span><span class="p">,</span><span class="n">P</span><span class="p">,</span><span class="n">sini</span><span class="p">,</span><span class="n">ecc</span><span class="p">,</span><span class="n">omdeg</span><span class="p">))</span> <span class="go">54321.6762764</span> </pre></div> </div> </dd> </dl> </dd></dl> <dl class="function"> <dt id="pycheops.funcs.vrad"> <code class="sig-prename descclassname">pycheops.funcs.</code><code class="sig-name descname">vrad</code><span class="sig-paren">(</span><em class="sig-param">t</em>, <em class="sig-param">tzero</em>, <em class="sig-param">P</em>, <em class="sig-param">K</em>, <em class="sig-param">ecc=0</em>, <em class="sig-param">omdeg=90</em>, <em class="sig-param">sini=1</em>, <em class="sig-param">primary=True</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.funcs.vrad" title="Permalink to this definition">¶</a></dt> <dd><p>Calculate radial velocity, V_r, for body in a Keplerian orbit</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>t</strong> – array of input times</p></li> <li><p><strong>tzero</strong> – time of inferior conjunction, i.e., mid-transit</p></li> <li><p><strong>P</strong> – orbital period</p></li> <li><p><strong>K</strong> – radial velocity semi-amplitude</p></li> <li><p><strong>ecc</strong> – eccentricity (optional, default=0)</p></li> <li><p><strong>omdeg</strong> – longitude of periastron in degrees (optional, default=90)</p></li> <li><p><strong>sini</strong> – sine of orbital inclination (to convert tzero to t_peri)</p></li> <li><p><strong>primary</strong> – if false calculate V_r for companion</p></li> </ul> </dd> <dt class="field-even">Returns</dt> <dd class="field-even"><p>V_r in same units as K relative to the barycentre of the binary</p> </dd> </dl> </dd></dl> <dl class="function"> <dt id="pycheops.funcs.xyz_planet"> <code class="sig-prename descclassname">pycheops.funcs.</code><code class="sig-name descname">xyz_planet</code><span class="sig-paren">(</span><em class="sig-param">t</em>, <em class="sig-param">tzero</em>, <em class="sig-param">P</em>, <em class="sig-param">sini</em>, <em class="sig-param">ecc=0</em>, <em class="sig-param">omdeg=90</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.funcs.xyz_planet" title="Permalink to this definition">¶</a></dt> <dd><p>Position of the planet in Cartesian coordinates.</p> <p>The position of the ascending node is taken to be Omega=0 and the semi-major axis is taken to be a=1.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>t</strong> – time of observation (scalar or array)</p></li> <li><p><strong>tzero</strong> – time of inferior conjunction, i.e., mid-transit</p></li> <li><p><strong>P</strong> – orbital period</p></li> <li><p><strong>sini</strong> – sine of orbital inclination</p></li> <li><p><strong>ecc</strong> – eccentricity (optional, default=0)</p></li> <li><p><strong>omdeg</strong> – longitude of periastron in degrees (optional, default=90)</p></li> </ul> </dd> </dl> <p>N.B. omdeg is the longitude of periastron for the star’s orbit</p> <dl class="field-list simple"> <dt class="field-odd">Returns</dt> <dd class="field-odd"><p>(x, y, z)</p> </dd> <dt class="field-even">Example</dt> <dd class="field-even"><p></p></dd> </dl> <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pycheops.funcs</span> <span class="kn">import</span> <span class="n">phase_angle</span> <span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">numpy</span> <span class="kn">import</span> <span class="n">linspace</span> <span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">t</span> <span class="o">=</span> <span class="n">linspace</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1000</span><span class="p">)</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">sini</span> <span class="o">=</span> <span class="mf">0.9</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">ecc</span> <span class="o">=</span> <span class="mf">0.1</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">omdeg</span> <span class="o">=</span> <span class="mi">90</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span> <span class="o">=</span> <span class="n">xyz_planet</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">sini</span><span class="p">,</span> <span class="n">ecc</span><span class="p">,</span> <span class="n">omdeg</span><span class="p">)</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">z</span><span class="p">)</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span> </pre></div> </div> </dd></dl> </div> </div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h1 class="logo"><a href="index.html">pycheops</a></h1> <h3>Navigation</h3> <p class="caption"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="constants.html">constants</a></li> <li class="toctree-l1 current"><a class="current reference internal" href="#">funcs</a></li> <li class="toctree-l1"><a class="reference internal" href="instrument.html">instrument</a></li> <li class="toctree-l1"><a class="reference internal" href="ld.html">ld</a></li> <li class="toctree-l1"><a class="reference internal" href="models.html">models</a></li> <li class="toctree-l1"><a class="reference internal" href="quantities.html">quantities</a></li> </ul> <div class="relations"> <h3>Related Topics</h3> <ul> <li><a href="index.html">Documentation overview</a><ul> <li>Previous: <a href="constants.html" title="previous chapter">constants</a></li> <li>Next: <a href="instrument.html" title="next chapter">instrument</a></li> </ul></li> </ul> </div> <div id="searchbox" style="display: none" role="search"> <h3 id="searchlabel">Quick search</h3> <div class="searchformwrapper"> <form class="search" action="search.html" method="get"> <input type="text" name="q" aria-labelledby="searchlabel" /> <input type="submit" value="Go" /> </form> </div> </div> <script>$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="footer"> &copy;2018, [email protected]. | Powered by <a href="http://sphinx-doc.org/">Sphinx 2.4.0</a> &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a> | <a href="_sources/funcs.rst.txt" rel="nofollow">Page source</a> </div> </body> </html>
28,032
58.771855
593
html
pycheops
pycheops-master/docs/_build/html/genindex.html
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title>Index &#8212; pycheops 0.0.16 documentation</title> <link rel="stylesheet" href="_static/alabaster.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> <script src="_static/doctools.js"></script> <script src="_static/language_data.js"></script> <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script> <link rel="index" title="Index" href="#" /> <link rel="search" title="Search" href="search.html" /> <link rel="stylesheet" href="_static/custom.css" type="text/css" /> <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" /> </head><body> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <h1 id="index">Index</h1> <div class="genindex-jumpbox"> <a href="#_"><strong>_</strong></a> | <a href="#A"><strong>A</strong></a> | <a href="#C"><strong>C</strong></a> | <a href="#E"><strong>E</strong></a> | <a href="#F"><strong>F</strong></a> | <a href="#G"><strong>G</strong></a> | <a href="#H"><strong>H</strong></a> | <a href="#K"><strong>K</strong></a> | <a href="#L"><strong>L</strong></a> | <a href="#M"><strong>M</strong></a> | <a href="#P"><strong>P</strong></a> | <a href="#Q"><strong>Q</strong></a> | <a href="#R"><strong>R</strong></a> | <a href="#S"><strong>S</strong></a> | <a href="#T"><strong>T</strong></a> | <a href="#U"><strong>U</strong></a> | <a href="#V"><strong>V</strong></a> | <a href="#X"><strong>X</strong></a> </div> <h2 id="_">_</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="ld.html#pycheops.ld.stagger_power2_interpolator.__call__">__call__() (pycheops.ld.stagger_power2_interpolator method)</a> </li> </ul></td> </tr></table> <h2 id="A">A</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="funcs.html#pycheops.funcs.a_rsun">a_rsun() (in module pycheops.funcs)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="funcs.html#pycheops.funcs.asini">asini() (in module pycheops.funcs)</a> </li> </ul></td> </tr></table> <h2 id="C">C</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="ld.html#pycheops.ld.ca_to_h1h2">ca_to_h1h2() (in module pycheops.ld)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="instrument.html#pycheops.instrument.count_rate">count_rate() (in module pycheops.instrument)</a> </li> </ul></td> </tr></table> <h2 id="E">E</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="models.html#pycheops.models.EBLMModel">EBLMModel (class in pycheops.models)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="models.html#pycheops.models.EclipseModel">EclipseModel (class in pycheops.models)</a> </li> <li><a href="instrument.html#pycheops.instrument.exposure_time">exposure_time() (in module pycheops.instrument)</a> </li> </ul></td> </tr></table> <h2 id="F">F</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="funcs.html#pycheops.funcs.f_m">f_m() (in module pycheops.funcs)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="models.html#pycheops.models.FactorModel">FactorModel (class in pycheops.models)</a> </li> </ul></td> </tr></table> <h2 id="G">G</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="models.html#pycheops.models.FactorModel.guess">guess() (pycheops.models.FactorModel method)</a> </li> </ul></td> </tr></table> <h2 id="H">H</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="ld.html#pycheops.ld.h1h2_to_ca">h1h2_to_ca() (in module pycheops.ld)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="ld.html#pycheops.ld.h1h2_to_q1q2">h1h2_to_q1q2() (in module pycheops.ld)</a> </li> </ul></td> </tr></table> <h2 id="K">K</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="funcs.html#pycheops.funcs.K_kms">K_kms() (in module pycheops.funcs)</a> </li> </ul></td> </tr></table> <h2 id="L">L</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="ld.html#pycheops.ld.ld_claret">ld_claret() (in module pycheops.ld)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="ld.html#pycheops.ld.ld_power2">ld_power2() (in module pycheops.ld)</a> </li> </ul></td> </tr></table> <h2 id="M">M</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="funcs.html#pycheops.funcs.m1sin3i">m1sin3i() (in module pycheops.funcs)</a> </li> <li><a href="funcs.html#pycheops.funcs.m2sin3i">m2sin3i() (in module pycheops.funcs)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="funcs.html#pycheops.funcs.m_comp">m_comp() (in module pycheops.funcs)</a> </li> <li><a href="models.html#pycheops.models.minerr_transit_fit">minerr_transit_fit() (in module pycheops.models)</a> </li> </ul></td> </tr></table> <h2 id="P">P</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="models.html#pycheops.models.PlanetModel">PlanetModel (class in pycheops.models)</a> </li> <li><a href="index.html#module-pycheops">pycheops (module)</a> </li> <li><a href="constants.html#module-pycheops.constants">pycheops.constants (module)</a> </li> <li><a href="funcs.html#module-pycheops.funcs">pycheops.funcs (module)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="instrument.html#module-pycheops.instrument">pycheops.instrument (module)</a> </li> <li><a href="ld.html#module-pycheops.ld">pycheops.ld (module)</a> </li> <li><a href="models.html#module-pycheops.models">pycheops.models (module)</a> </li> <li><a href="quantities.html#module-pycheops.quantities">pycheops.quantities (module)</a> </li> </ul></td> </tr></table> <h2 id="Q">Q</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="ld.html#pycheops.ld.q1q2_to_h1h2">q1q2_to_h1h2() (in module pycheops.ld)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="models.html#pycheops.models.qpower2">qpower2 (in module pycheops.models)</a> </li> </ul></td> </tr></table> <h2 id="R">R</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="models.html#pycheops.models.ReflectionModel">ReflectionModel (class in pycheops.models)</a> </li> <li><a href="instrument.html#pycheops.instrument.response">response() (in module pycheops.instrument)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="funcs.html#pycheops.funcs.rhostar">rhostar() (in module pycheops.funcs)</a> </li> <li><a href="models.html#pycheops.models.RVCompanion">RVCompanion (class in pycheops.models)</a> </li> <li><a href="models.html#pycheops.models.RVModel">RVModel (class in pycheops.models)</a> </li> </ul></td> </tr></table> <h2 id="S">S</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="models.html#pycheops.models.scaled_transit_fit">scaled_transit_fit (in module pycheops.models)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="ld.html#pycheops.ld.stagger_power2_interpolator">stagger_power2_interpolator (class in pycheops.ld)</a> </li> </ul></td> </tr></table> <h2 id="T">T</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="funcs.html#pycheops.funcs.t2z">t2z() (in module pycheops.funcs)</a> </li> <li><a href="models.html#pycheops.models.ThermalPhaseModel">ThermalPhaseModel (class in pycheops.models)</a> </li> <li><a href="instrument.html#pycheops.instrument.transit_noise">transit_noise() (in module pycheops.instrument)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="funcs.html#pycheops.funcs.transit_width">transit_width() (in module pycheops.funcs)</a> </li> <li><a href="models.html#pycheops.models.TransitModel">TransitModel (class in pycheops.models)</a> </li> <li><a href="funcs.html#pycheops.funcs.tzero2tperi">tzero2tperi() (in module pycheops.funcs)</a> </li> </ul></td> </tr></table> <h2 id="U">U</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="models.html#pycheops.models.ueclipse">ueclipse (in module pycheops.models)</a> </li> </ul></td> </tr></table> <h2 id="V">V</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="instrument.html#pycheops.instrument.visibility">visibility() (in module pycheops.instrument)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="funcs.html#pycheops.funcs.vrad">vrad() (in module pycheops.funcs)</a> </li> </ul></td> </tr></table> <h2 id="X">X</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="funcs.html#pycheops.funcs.xyz_planet">xyz_planet() (in module pycheops.funcs)</a> </li> </ul></td> </tr></table> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h1 class="logo"><a href="index.html">pycheops</a></h1> <h3>Navigation</h3> <p class="caption"><span class="caption-text">Contents:</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="constants.html">constants</a></li> <li class="toctree-l1"><a class="reference internal" href="funcs.html">funcs</a></li> <li class="toctree-l1"><a class="reference internal" href="instrument.html">instrument</a></li> <li class="toctree-l1"><a class="reference internal" href="ld.html">ld</a></li> <li class="toctree-l1"><a class="reference internal" href="models.html">models</a></li> <li class="toctree-l1"><a class="reference internal" href="quantities.html">quantities</a></li> </ul> <div class="relations"> <h3>Related Topics</h3> <ul> <li><a href="index.html">Documentation overview</a><ul> </ul></li> </ul> </div> <div id="searchbox" style="display: none" role="search"> <h3 id="searchlabel">Quick search</h3> <div class="searchformwrapper"> <form class="search" action="search.html" method="get"> <input type="text" name="q" aria-labelledby="searchlabel" /> <input type="submit" value="Go" /> </form> </div> </div> <script>$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="footer"> &copy;2018, [email protected]. | Powered by <a href="http://sphinx-doc.org/">Sphinx 2.4.0</a> &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a> </div> </body> </html>
12,512
34.05042
140
html
pycheops
pycheops-master/docs/_build/html/index.html
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title>Welcome to pycheops’s documentation! &#8212; pycheops 0.0.16 documentation</title> <link rel="stylesheet" href="_static/alabaster.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> <script src="_static/doctools.js"></script> <script src="_static/language_data.js"></script> <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="next" title="constants" href="constants.html" /> <link rel="stylesheet" href="_static/custom.css" type="text/css" /> <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" /> </head><body> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="section" id="module-pycheops"> <span id="welcome-to-pycheops-s-documentation"></span><h1>Welcome to pycheops’s documentation!<a class="headerlink" href="#module-pycheops" title="Permalink to this headline">¶</a></h1> <div class="section" id="pycheops"> <h2>pycheops<a class="headerlink" href="#pycheops" title="Permalink to this headline">¶</a></h2> <p>This package provides tools for the analysis of light curves from the ESA CHEOPS mission &lt;<a class="reference external" href="http://cheops.unibe.ch/">http://cheops.unibe.ch/</a>&gt;.</p> </div> <div class="toctree-wrapper compound"> <p class="caption"><span class="caption-text">Contents:</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="constants.html">constants</a></li> <li class="toctree-l1"><a class="reference internal" href="funcs.html">funcs</a></li> <li class="toctree-l1"><a class="reference internal" href="instrument.html">instrument</a></li> <li class="toctree-l1"><a class="reference internal" href="ld.html">ld</a></li> <li class="toctree-l1"><a class="reference internal" href="models.html">models</a></li> <li class="toctree-l1"><a class="reference internal" href="quantities.html">quantities</a></li> </ul> </div> </div> <div class="section" id="indices-and-tables"> <h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline">¶</a></h1> <ul class="simple"> <li><p><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></p></li> <li><p><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a></p></li> <li><p><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></p></li> </ul> </div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h1 class="logo"><a href="#">pycheops</a></h1> <h3>Navigation</h3> <p class="caption"><span class="caption-text">Contents:</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="constants.html">constants</a></li> <li class="toctree-l1"><a class="reference internal" href="funcs.html">funcs</a></li> <li class="toctree-l1"><a class="reference internal" href="instrument.html">instrument</a></li> <li class="toctree-l1"><a class="reference internal" href="ld.html">ld</a></li> <li class="toctree-l1"><a class="reference internal" href="models.html">models</a></li> <li class="toctree-l1"><a class="reference internal" href="quantities.html">quantities</a></li> </ul> <div class="relations"> <h3>Related Topics</h3> <ul> <li><a href="#">Documentation overview</a><ul> <li>Next: <a href="constants.html" title="next chapter">constants</a></li> </ul></li> </ul> </div> <div id="searchbox" style="display: none" role="search"> <h3 id="searchlabel">Quick search</h3> <div class="searchformwrapper"> <form class="search" action="search.html" method="get"> <input type="text" name="q" aria-labelledby="searchlabel" /> <input type="submit" value="Go" /> </form> </div> </div> <script>$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="footer"> &copy;2018, [email protected]. | Powered by <a href="http://sphinx-doc.org/">Sphinx 2.4.0</a> &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a> | <a href="_sources/index.rst.txt" rel="nofollow">Page source</a> </div> </body> </html>
5,004
35.801471
185
html
pycheops
pycheops-master/docs/_build/html/instrument.html
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title>instrument &#8212; pycheops 0.0.16 documentation</title> <link rel="stylesheet" href="_static/alabaster.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> <script src="_static/doctools.js"></script> <script src="_static/language_data.js"></script> <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="next" title="ld" href="ld.html" /> <link rel="prev" title="funcs" href="funcs.html" /> <link rel="stylesheet" href="_static/custom.css" type="text/css" /> <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" /> </head><body> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="toctree-wrapper compound"> </div> <span class="target" id="module-pycheops.instrument"></span><div class="section" id="instrument"> <h1>instrument<a class="headerlink" href="#instrument" title="Permalink to this headline">¶</a></h1> <blockquote> <div><p>Constants, functions and data related to the CHEOPS instrument.</p> </div></blockquote> <div class="section" id="functions"> <h2>Functions<a class="headerlink" href="#functions" title="Permalink to this headline">¶</a></h2> <dl class="function"> <dt id="pycheops.instrument.response"> <code class="sig-prename descclassname">pycheops.instrument.</code><code class="sig-name descname">response</code><span class="sig-paren">(</span><em class="sig-param">passband='CHEOPS'</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.instrument.response" title="Permalink to this definition">¶</a></dt> <dd><p>Instrument response functions.</p> <p>The response functions have been digitized from Fig. 2 of <a class="reference external" href="https://www.cosmos.esa.int/web/cheops/cheops-performances">https://www.cosmos.esa.int/web/cheops/cheops-performances</a></p> <p>The available passband names are ‘CHEOPS’, ‘MOST’, ‘Kepler’, ‘CoRoT’, ‘Gaia’, ‘B’, ‘V’, ‘R’, ‘I’, ‘u_’,’g_’,’r_’,’i_’,’z_’, and ‘NGTS’</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><p><strong>passband</strong> – instrument/passband names (case sensitive).</p> </dd> <dt class="field-even">Returns</dt> <dd class="field-even"><p>Instrument response function as an astropy Table object.</p> </dd> </dl> </dd></dl> <dl class="function"> <dt id="pycheops.instrument.visibility"> <code class="sig-prename descclassname">pycheops.instrument.</code><code class="sig-name descname">visibility</code><span class="sig-paren">(</span><em class="sig-param">ra</em>, <em class="sig-param">dec</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.instrument.visibility" title="Permalink to this definition">¶</a></dt> <dd><p>Estimate of target visibility</p> <p>The target visibility estimated with this function is approximate. A more reliable estimate of the observing efficiency can be made with the Feasibility Checker tool.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>ra</strong> – right ascension in degrees (scalar or array)</p></li> <li><p><strong>dec</strong> – declination in degrees (scalar or array)</p></li> </ul> </dd> <dt class="field-even">Returns</dt> <dd class="field-even"><p>target visibility (%)</p> </dd> </dl> </dd></dl> <dl class="function"> <dt id="pycheops.instrument.exposure_time"> <code class="sig-prename descclassname">pycheops.instrument.</code><code class="sig-name descname">exposure_time</code><span class="sig-paren">(</span><em class="sig-param">G</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.instrument.exposure_time" title="Permalink to this definition">¶</a></dt> <dd><p>Recommended minimum/maximum exposure times</p> <p>The function returns the exposure times that are estimated to provide 10% and 98% of the detector full well capacity in the brightest image pixel of the target.</p> <blockquote> <div><dl class="field-list simple"> <dt class="field-odd">param G</dt> <dd class="field-odd"><p>Gaia G-band magnitude</p> </dd> <dt class="field-even">returns</dt> <dd class="field-even"><p>min,max recommended exposure time</p> </dd> </dl> </div></blockquote> </dd></dl> <dl class="function"> <dt id="pycheops.instrument.transit_noise"> <code class="sig-prename descclassname">pycheops.instrument.</code><code class="sig-name descname">transit_noise</code><span class="sig-paren">(</span><em class="sig-param">time</em>, <em class="sig-param">flux</em>, <em class="sig-param">flux_err</em>, <em class="sig-param">T_0=None</em>, <em class="sig-param">width=3</em>, <em class="sig-param">h_1=0.7224</em>, <em class="sig-param">h_2=0.6713</em>, <em class="sig-param">tol=0.1</em>, <em class="sig-param">method='scaled'</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.instrument.transit_noise" title="Permalink to this definition">¶</a></dt> <dd><p>Transit noise estimate</p> <p>The noise is calculated in a window of duration ‘width’ in hours centered at time T_0 by first dividing out the best-fitting transit (even if this has a negative depth), and then finding the depth of an injected transit that gives S/N = 1.</p> <p>Two methods are available to estimate the transit depth and its standard error - ‘scaled’ or ‘minerr’.</p> <p>If method=’scaled’, the transit depth and its standard error are calculated assuming that the true standard errors on the flux measurements are a factor f times the nominal standard error(s) provided in flux_err.</p> <p>If method=’minerr’, the transit depth and its standard error are calculated assuming that standard error(s) provided in flux_err are a lower bound to the true standard errors. This tends to be more conservative than using method=’scaled’.</p> <p>The transit is calculated from an impact parameter b=0 using power-2 limb darkening parameters h_1 and h_2. Default values for h_1 and h_2 are solar values.</p> <p>If T_0 is not specifed that the median value of time is used.</p> <p>If there are insufficient data for the calculation the function returns values returned are np.nan, np.nan</p> <blockquote> <div><dl class="field-list simple"> <dt class="field-odd">param time</dt> <dd class="field-odd"><p>Array of observed times (days)</p> </dd> <dt class="field-even">param flux</dt> <dd class="field-even"><p>Array of normalised flux measurements</p> </dd> <dt class="field-odd">param flux_err</dt> <dd class="field-odd"><p>Standard error estimate(s) for flux - array of scalar</p> </dd> <dt class="field-even">param T_0</dt> <dd class="field-even"><p>Centre of time window for noise estimate</p> </dd> <dt class="field-odd">param width</dt> <dd class="field-odd"><p>Width of time window for noise estimate in hours</p> </dd> <dt class="field-even">param h_1</dt> <dd class="field-even"><p>Limb darkening parameter</p> </dd> <dt class="field-odd">param h_2</dt> <dd class="field-odd"><p>Limb darkening parameter</p> </dd> <dt class="field-even">param tol</dt> <dd class="field-even"><p>Tolerance criterion for convergence (ppm)</p> </dd> <dt class="field-odd">param method</dt> <dd class="field-odd"><p>‘scaled’ or ‘minerr’</p> </dd> <dt class="field-even">returns</dt> <dd class="field-even"><p>noise in ppm and, if method is ‘scaled’, noise scaling factor, f</p> </dd> </dl> </div></blockquote> </dd></dl> <dl class="function"> <dt id="pycheops.instrument.count_rate"> <code class="sig-prename descclassname">pycheops.instrument.</code><code class="sig-name descname">count_rate</code><span class="sig-paren">(</span><em class="sig-param">gmag</em>, <em class="sig-param">bp_rp</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.instrument.count_rate" title="Permalink to this definition">¶</a></dt> <dd><p>Predicted count rate</p> <p>The count rate in e-/s based on the star’s Gaia G magnitude and G_BP-R_BP colour. This value returned is suitable for use in the CHEOPS exposure time calculator using the option “Expected flux in CHEOPS passband”</p> <p>** Currently based on stellar models convolved with throughout and QE curves measured pre-launch.</p> </dd></dl> </div> </div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h1 class="logo"><a href="index.html">pycheops</a></h1> <h3>Navigation</h3> <p class="caption"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="constants.html">constants</a></li> <li class="toctree-l1"><a class="reference internal" href="funcs.html">funcs</a></li> <li class="toctree-l1 current"><a class="current reference internal" href="#">instrument</a></li> <li class="toctree-l1"><a class="reference internal" href="ld.html">ld</a></li> <li class="toctree-l1"><a class="reference internal" href="models.html">models</a></li> <li class="toctree-l1"><a class="reference internal" href="quantities.html">quantities</a></li> </ul> <div class="relations"> <h3>Related Topics</h3> <ul> <li><a href="index.html">Documentation overview</a><ul> <li>Previous: <a href="funcs.html" title="previous chapter">funcs</a></li> <li>Next: <a href="ld.html" title="next chapter">ld</a></li> </ul></li> </ul> </div> <div id="searchbox" style="display: none" role="search"> <h3 id="searchlabel">Quick search</h3> <div class="searchformwrapper"> <form class="search" action="search.html" method="get"> <input type="text" name="q" aria-labelledby="searchlabel" /> <input type="submit" value="Go" /> </form> </div> </div> <script>$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="footer"> &copy;2018, [email protected]. | Powered by <a href="http://sphinx-doc.org/">Sphinx 2.4.0</a> &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a> | <a href="_sources/instrument.rst.txt" rel="nofollow">Page source</a> </div> </body> </html>
10,804
42.22
626
html
pycheops
pycheops-master/docs/_build/html/ld.html
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title>ld &#8212; pycheops 0.0.16 documentation</title> <link rel="stylesheet" href="_static/alabaster.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> <script src="_static/doctools.js"></script> <script src="_static/language_data.js"></script> <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="next" title="models" href="models.html" /> <link rel="prev" title="instrument" href="instrument.html" /> <link rel="stylesheet" href="_static/custom.css" type="text/css" /> <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" /> </head><body> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="toctree-wrapper compound"> </div> <span class="target" id="module-pycheops.ld"></span><div class="section" id="ld"> <h1>ld<a class="headerlink" href="#ld" title="Permalink to this headline">¶</a></h1> <p>Limb darkening functions</p> <p>The available passband names are:</p> <ul class="simple"> <li><p>‘CHEOPS’, ‘MOST’, ‘Kepler’, ‘CoRoT’, ‘Gaia’, ‘TESS’</p></li> <li><p>‘U’, ‘B’, ‘V’, ‘R’, ‘I’ (Bessell/Johnson)</p></li> <li><p>‘u_’, ‘g_’, ‘r_’, ‘i_’, ‘z_’ (SDSS)</p></li> <li><p>‘NGTS’</p></li> </ul> <p>The power-2 limb-darkening law is described in Maxted (2018) <a class="footnote-reference brackets" href="#id3" id="id1">1</a>. Uninformative sampling of the parameter space for the power-2 law is described in Short et al. (2019) <a class="footnote-reference brackets" href="#id4" id="id2">2</a>.</p> <div class="section" id="examples"> <h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h2> <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pycheops.ld</span> <span class="kn">import</span> <span class="o">*</span> <span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span> <span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">T_eff</span> <span class="o">=</span> <span class="mi">5560</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">log_g</span> <span class="o">=</span> <span class="mf">4.3</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">Fe_H</span> <span class="o">=</span> <span class="o">-</span><span class="mf">0.3</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">passband</span> <span class="o">=</span> <span class="s1">&#39;Kepler&#39;</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">p2K</span> <span class="o">=</span> <span class="n">stagger_power2_interpolator</span><span class="p">(</span><span class="n">passband</span><span class="p">)</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">c2</span><span class="p">,</span><span class="n">a2</span><span class="p">,</span><span class="n">h1</span><span class="p">,</span><span class="n">h2</span> <span class="o">=</span> <span class="n">p2K</span><span class="p">(</span><span class="n">T_eff</span><span class="p">,</span> <span class="n">log_g</span><span class="p">,</span> <span class="n">Fe_H</span><span class="p">)</span> <span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="s1">&#39;h_1 = </span><span class="si">{:0.3f}</span><span class="s1">, h_2 = </span><span class="si">{:0.3f}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">h1</span><span class="p">,</span> <span class="n">h2</span><span class="p">))</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">mu</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">linspace</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">mu</span><span class="p">,</span> <span class="n">ld_power2</span><span class="p">(</span><span class="n">mu</span><span class="p">,[</span><span class="n">c2</span><span class="p">,</span> <span class="n">a2</span><span class="p">]),</span><span class="n">label</span><span class="o">=</span><span class="s1">&#39;power-2&#39;</span><span class="p">)</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">plt</span><span class="o">.</span><span class="n">xlim</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s1">&#39;$\mu$&#39;</span><span class="p">)</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s1">&#39;$I_{\lambda}(\mu)$&#39;</span><span class="p">)</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">()</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span> </pre></div> </div> <p class="rubric">References</p> <dl class="footnote brackets"> <dt class="label" id="id3"><span class="brackets"><a class="fn-backref" href="#id1">1</a></span></dt> <dd><p>Maxted, P.F.L., 2018, A&amp;A, submitted</p> </dd> <dt class="label" id="id4"><span class="brackets"><a class="fn-backref" href="#id2">2</a></span></dt> <dd><p>Short, D.R., et al., 2019, RNAAS, …, …</p> </dd> </dl> <dl class="function"> <dt id="pycheops.ld.ld_power2"> <code class="sig-prename descclassname">pycheops.ld.</code><code class="sig-name descname">ld_power2</code><span class="sig-paren">(</span><em class="sig-param">mu</em>, <em class="sig-param">a</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.ld.ld_power2" title="Permalink to this definition">¶</a></dt> <dd><p>Evaluate power-2 limb-darkening law</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>mu</strong> – cos of angle between surface normal and line of sight</p></li> <li><p><strong>a</strong> – array or tuple [c, alpha]</p></li> </ul> </dd> <dt class="field-even">Returns</dt> <dd class="field-even"><p>1 - c * (1-mu**alpha)</p> </dd> </dl> </dd></dl> <dl class="function"> <dt id="pycheops.ld.ld_claret"> <code class="sig-prename descclassname">pycheops.ld.</code><code class="sig-name descname">ld_claret</code><span class="sig-paren">(</span><em class="sig-param">mu</em>, <em class="sig-param">a</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.ld.ld_claret" title="Permalink to this definition">¶</a></dt> <dd><p>Evaluate Claret 4-parameter limb-darkening law</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>mu</strong> – cos of angle between surface normal and line of sight</p></li> <li><p><strong>a</strong> – array or tuple [a_1, a_2, a_3, a_4]</p></li> </ul> </dd> <dt class="field-even">Returns</dt> <dd class="field-even"><p>1 - Sum(i=1,4) a_i*(1-mu**(i/2))</p> </dd> </dl> </dd></dl> <dl class="class"> <dt id="pycheops.ld.stagger_power2_interpolator"> <em class="property">class </em><code class="sig-prename descclassname">pycheops.ld.</code><code class="sig-name descname">stagger_power2_interpolator</code><span class="sig-paren">(</span><em class="sig-param">passband='CHEOPS'</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.ld.stagger_power2_interpolator" title="Permalink to this definition">¶</a></dt> <dd><p>Parameters of a power-2 limb-darkening law interpolated from the Stagger grid.</p> <dl class="simple"> <dt>The power-2 limb darkening law is </dt><dd><p>I_X(mu) = 1 - c * (1-mu**alpha)</p> </dd> </dl> <p>It is often better to use the transformed coefficients</p> <ul class="simple"> <li><p>h1 = 1 - c*(1-0.5**alpha)</p></li> </ul> <p>and</p> <ul class="simple"> <li><p>h2 = c*0.5**alpha</p></li> </ul> <p>as free parameters in a least-squares fit and/or for applying priors.</p> <p>Returns NaN if interpolation outside the grid range is attempted</p> <dl class="method"> <dt id="pycheops.ld.stagger_power2_interpolator.__call__"> <code class="sig-name descname">__call__</code><span class="sig-paren">(</span><em class="sig-param">T_eff</em>, <em class="sig-param">log_g</em>, <em class="sig-param">Fe_H</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.ld.stagger_power2_interpolator.__call__" title="Permalink to this definition">¶</a></dt> <dd><dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>T_eff</strong> – effective temperature in Kelvin</p></li> <li><p><strong>log_g</strong> – log of the surface gravity in cgs units</p></li> <li><p><strong>Fe/H</strong> – [Fe/H] in dex</p></li> </ul> </dd> <dt class="field-even">Returns</dt> <dd class="field-even"><p>c, alpha, h_1, h_2</p> </dd> </dl> </dd></dl> </dd></dl> <dl class="function"> <dt id="pycheops.ld.ca_to_h1h2"> <code class="sig-prename descclassname">pycheops.ld.</code><code class="sig-name descname">ca_to_h1h2</code><span class="sig-paren">(</span><em class="sig-param">c</em>, <em class="sig-param">alpha</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.ld.ca_to_h1h2" title="Permalink to this definition">¶</a></dt> <dd><p>Transform for power-2 law coefficients h1 = 1 - c*(1-0.5**alpha) h2 = c*0.5**alpha</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>c</strong> – power-2 law coefficient, c</p></li> <li><p><strong>alpha</strong> – power-2 law exponent, alpha</p></li> </ul> </dd> </dl> <p>returns: h1, h2</p> </dd></dl> <dl class="function"> <dt id="pycheops.ld.h1h2_to_ca"> <code class="sig-prename descclassname">pycheops.ld.</code><code class="sig-name descname">h1h2_to_ca</code><span class="sig-paren">(</span><em class="sig-param">h1</em>, <em class="sig-param">h2</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.ld.h1h2_to_ca" title="Permalink to this definition">¶</a></dt> <dd><p>Inverse transform for power-2 law coefficients c = 1 - h1 + h2 alpha = log2(c/h2)</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>h1</strong> – 1 - c*(1-0.5**alpha)</p></li> <li><p><strong>h2</strong> – c*0.5**alpha</p></li> </ul> </dd> </dl> <p>returns: c, alpha</p> </dd></dl> <dl class="function"> <dt id="pycheops.ld.q1q2_to_h1h2"> <code class="sig-prename descclassname">pycheops.ld.</code><code class="sig-name descname">q1q2_to_h1h2</code><span class="sig-paren">(</span><em class="sig-param">q1</em>, <em class="sig-param">q2</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.ld.q1q2_to_h1h2" title="Permalink to this definition">¶</a></dt> <dd><p>Inverse transform to h1, h2 from uninformative paramaters q1, q2</p> <p>h1 = 1 - sqrt(q1) + q2*sqrt(q1) h2 = 1 - sqrt(q1)</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>q1</strong> – (1 - h2)**2</p></li> <li><p><strong>q2</strong> – (h1 - h2)/(1-h2)</p></li> </ul> </dd> </dl> <p>returns: q1, q2</p> </dd></dl> <dl class="function"> <dt id="pycheops.ld.h1h2_to_q1q2"> <code class="sig-prename descclassname">pycheops.ld.</code><code class="sig-name descname">h1h2_to_q1q2</code><span class="sig-paren">(</span><em class="sig-param">h1</em>, <em class="sig-param">h2</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.ld.h1h2_to_q1q2" title="Permalink to this definition">¶</a></dt> <dd><p>Transform h1, h2 to uninformative paramaters q1, q2</p> <p>q1 = (1 - h2)**2 q2 = (h1 - h2)/(1-h2)</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>h1</strong> – 1 - c*(1-0.5**alpha)</p></li> <li><p><strong>h2</strong> – c*0.5**alpha</p></li> </ul> </dd> </dl> <p>returns: q1, q2</p> </dd></dl> </div> </div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h1 class="logo"><a href="index.html">pycheops</a></h1> <h3>Navigation</h3> <p class="caption"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="constants.html">constants</a></li> <li class="toctree-l1"><a class="reference internal" href="funcs.html">funcs</a></li> <li class="toctree-l1"><a class="reference internal" href="instrument.html">instrument</a></li> <li class="toctree-l1 current"><a class="current reference internal" href="#">ld</a></li> <li class="toctree-l1"><a class="reference internal" href="models.html">models</a></li> <li class="toctree-l1"><a class="reference internal" href="quantities.html">quantities</a></li> </ul> <div class="relations"> <h3>Related Topics</h3> <ul> <li><a href="index.html">Documentation overview</a><ul> <li>Previous: <a href="instrument.html" title="previous chapter">instrument</a></li> <li>Next: <a href="models.html" title="next chapter">models</a></li> </ul></li> </ul> </div> <div id="searchbox" style="display: none" role="search"> <h3 id="searchlabel">Quick search</h3> <div class="searchformwrapper"> <form class="search" action="search.html" method="get"> <input type="text" name="q" aria-labelledby="searchlabel" /> <input type="submit" value="Go" /> </form> </div> </div> <script>$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="footer"> &copy;2018, [email protected]. | Powered by <a href="http://sphinx-doc.org/">Sphinx 2.4.0</a> &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a> | <a href="_sources/ld.rst.txt" rel="nofollow">Page source</a> </div> </body> </html>
15,572
51.083612
512
html
pycheops
pycheops-master/docs/_build/html/models.html
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title>models &#8212; pycheops 0.0.16 documentation</title> <link rel="stylesheet" href="_static/alabaster.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> <script src="_static/doctools.js"></script> <script src="_static/language_data.js"></script> <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="next" title="quantities" href="quantities.html" /> <link rel="prev" title="ld" href="ld.html" /> <link rel="stylesheet" href="_static/custom.css" type="text/css" /> <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" /> </head><body> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="toctree-wrapper compound"> </div> <span class="target" id="module-pycheops.models"></span><div class="section" id="models"> <h1>models<a class="headerlink" href="#models" title="Permalink to this headline">¶</a></h1> <p>Models and likelihood functions for use with lmfit</p> <dl class="attribute"> <dt id="pycheops.models.qpower2"> <code class="sig-prename descclassname">pycheops.models.</code><code class="sig-name descname">qpower2</code><a class="headerlink" href="#pycheops.models.qpower2" title="Permalink to this definition">¶</a></dt> <dd><p>Fast and accurate transit light curves for the power-2 limb-darkening law</p> <p>The power-2 limb-darkening law is</p> <div class="math notranslate nohighlight"> \[I(\mu) = 1 - c (1 - \mu^\alpha)\]</div> <p>Light curves are calculated using the qpower2 approximation <a class="footnote-reference brackets" href="#id2" id="id1">2</a>. The approximation is accurate to better than 100ppm for radius ratio k &lt; 0.1.</p> <p><strong>N.B.</strong> qpower2 is untested/inaccurate for values of k &gt; 0.2</p> <dl class="footnote brackets"> <dt class="label" id="id2"><span class="brackets"><a class="fn-backref" href="#id1">2</a></span></dt> <dd><p>Maxted, P.F.L. &amp; Gill, S., 2019A&amp;A…622A..33M</p> </dd> </dl> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>z</strong> – star-planet separation on the sky cf. star radius (array)</p></li> <li><p><strong>k</strong> – planet-star radius ratio (scalar, k&lt;1)</p></li> <li><p><strong>c</strong> – power-2 limb darkening coefficient</p></li> <li><p><strong>a</strong> – power-2 limb darkening exponent</p></li> </ul> </dd> <dt class="field-even">Returns</dt> <dd class="field-even"><p>light curve (observed flux)</p> </dd> <dt class="field-odd">Example</dt> <dd class="field-odd"><p></p></dd> </dl> <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pycheops.models</span> <span class="kn">import</span> <span class="n">qpower2</span> <span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pycheops.funcs</span> <span class="kn">import</span> <span class="n">t2z</span> <span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">numpy</span> <span class="kn">import</span> <span class="n">linspace</span> <span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">t</span> <span class="o">=</span> <span class="n">linspace</span><span class="p">(</span><span class="o">-</span><span class="mf">0.025</span><span class="p">,</span><span class="mf">0.025</span><span class="p">,</span><span class="mi">1000</span><span class="p">)</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">sini</span> <span class="o">=</span> <span class="mf">0.999</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">rstar</span> <span class="o">=</span> <span class="mf">0.05</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">ecc</span> <span class="o">=</span> <span class="mf">0.2</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">om</span> <span class="o">=</span> <span class="mi">120</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">tzero</span> <span class="o">=</span> <span class="mf">0.0</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">P</span> <span class="o">=</span> <span class="mf">0.1</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">z</span><span class="o">=</span><span class="n">t2z</span><span class="p">(</span><span class="n">t</span><span class="p">,</span><span class="n">tzero</span><span class="p">,</span><span class="n">P</span><span class="p">,</span><span class="n">sini</span><span class="p">,</span><span class="n">rstar</span><span class="p">,</span><span class="n">ecc</span><span class="p">,</span><span class="n">om</span><span class="p">)</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">c</span> <span class="o">=</span> <span class="mf">0.5</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="mf">0.7</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">k</span> <span class="o">=</span> <span class="mf">0.1</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">qpower2</span><span class="p">(</span><span class="n">z</span><span class="p">,</span><span class="n">k</span><span class="p">,</span><span class="n">c</span><span class="p">,</span><span class="n">a</span><span class="p">)</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">t</span><span class="p">,</span><span class="n">f</span><span class="p">)</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span> </pre></div> </div> </dd></dl> <dl class="attribute"> <dt id="pycheops.models.ueclipse"> <code class="sig-prename descclassname">pycheops.models.</code><code class="sig-name descname">ueclipse</code><a class="headerlink" href="#pycheops.models.ueclipse" title="Permalink to this definition">¶</a></dt> <dd><p>Eclipse light curve for a planet with uniform surface brightness by a star</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>z</strong> – star-planet separation on the sky cf. star radius (array)</p></li> <li><p><strong>k</strong> – planet-star radius ratio (scalar, k&lt;1)</p></li> </ul> </dd> <dt class="field-even">Returns</dt> <dd class="field-even"><p>light curve (observed flux from eclipsed source)</p> </dd> </dl> </dd></dl> <dl class="class"> <dt id="pycheops.models.TransitModel"> <em class="property">class </em><code class="sig-prename descclassname">pycheops.models.</code><code class="sig-name descname">TransitModel</code><span class="sig-paren">(</span><em class="sig-param">independent_vars=['t'], prefix='', nan_policy='raise', **kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.models.TransitModel" title="Permalink to this definition">¶</a></dt> <dd><p>Light curve model for the transit of a spherical star by an opaque spherical body (planet).</p> <p>Limb-darkening is described by the power-2 law:</p> <div class="math notranslate nohighlight"> \[I(\mu) = 1 - c (1 - \mu^\alpha)\]</div> <p>The transit depth, width shape are parameterised by D, W and b. These parameters are defined below in terms of the radius of the star and planet, R_s and R_p, respectively, the semi-major axis, a, and the orbital inclination, i. The eccentricy and longitude of periastron for the star’s orbit are e and omega, respectively.</p> <p>The following parameters are defined for convenience:</p> <ul class="simple"> <li><p>k = R_p/R_s;</p></li> <li><p>aR = a/R_s;</p></li> <li><p>rho = 0.013418*aR**3/(P/d)**2.</p></li> </ul> <p><strong>N.B.</strong> the mean stellar density in solar units is rho, but only if the mass ratio q = M_planet/M_star is q &lt;&lt; 1.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>t</strong> – <ul> <li><p>independent variable (time)</p></li> </ul> </p></li> <li><p><strong>T_0</strong> – <ul> <li><p>time of mid-transit</p></li> </ul> </p></li> <li><p><strong>P</strong> – <ul> <li><p>orbital period</p></li> </ul> </p></li> <li><p><strong>D</strong> – <ul> <li><p>(R_p/R_s)**2 = k**2</p></li> </ul> </p></li> <li><p><strong>W</strong> – <ul> <li><p>(R_s/a)*sqrt((1+k)**2 - b**2)/pi</p></li> </ul> </p></li> <li><p><strong>b</strong> – <ul> <li><p>a*cos(i)/R_s</p></li> </ul> </p></li> <li><p><strong>f_c</strong> – <ul> <li><p>sqrt(ecc)*cos(omega)</p></li> </ul> </p></li> <li><p><strong>f_s</strong> – <ul> <li><p>sqrt(ecc)*sin(omega)</p></li> </ul> </p></li> <li><p><strong>h_1</strong> – <ul> <li><p>I(0.5) = 1 - c*(1-0.5**alpha)</p></li> </ul> </p></li> <li><p><strong>h_2</strong> – <ul> <li><p>I(0.5) - I(0) = c*0.5**alpha</p></li> </ul> </p></li> </ul> </dd> </dl> <p>The flux value outside of transit is 1. The light curve is calculated using the qpower2 algorithm, which is fast but only accurate for k &lt; ~0.3.</p> <p>If the input parameters are invalid or k&gt;0.5 the model is returned as an array of value 1 everywhere.</p> </dd></dl> <dl class="class"> <dt id="pycheops.models.EclipseModel"> <em class="property">class </em><code class="sig-prename descclassname">pycheops.models.</code><code class="sig-name descname">EclipseModel</code><span class="sig-paren">(</span><em class="sig-param">independent_vars=['t'], prefix='', nan_policy='raise', **kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.models.EclipseModel" title="Permalink to this definition">¶</a></dt> <dd><p>Light curve model for the eclipse by a spherical star of a spherical body (planet) with no limb darkening.</p> <p>The transit depth, width shape are parameterised by D, W and b. These parameters are defined below in terms of the radius of the star and planet, R_s and R_p, respectively, the semi-major axis, a, and the orbital inclination, i. The eccentricy and longitude of periastron for the star’s orbit are e and omega, respectively. These are the same parameters used in TransitModel. The flux level outside of eclipse is 1 and inside eclipse is (1-L). The apparent time of mid-eclipse includes the correction a_c for the light travel time across the orbit, i.e., for a circular orbit the time of mid-eclipse is (T_0 + 0.5*P) + a_c.</p> <p><strong>N.B.</strong> a_c must have the same units as P.</p> <p>The following parameters are defined for convenience:</p> <ul class="simple"> <li><p>k = R_p/R_s;</p></li> <li><p>aR = a/R_s;</p></li> <li><p>rho = 0.013418*aR**3/(P/d)**2.</p></li> </ul> <p><strong>N.B.</strong> the mean stellar density in solar units is rho, but only if the mass ratio q = M_planet/M_star is q &lt;&lt; 1.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>t</strong> – <ul> <li><p>independent variable (time)</p></li> </ul> </p></li> <li><p><strong>T_0</strong> – <ul> <li><p>time of mid-transit</p></li> </ul> </p></li> <li><p><strong>P</strong> – <ul> <li><p>orbital period</p></li> </ul> </p></li> <li><p><strong>D</strong> – <ul> <li><p>(R_p/R_s)**2 = k**2</p></li> </ul> </p></li> <li><p><strong>W</strong> – <ul> <li><p>(R_s/a)*sqrt((1+k)**2 - b**2)/pi</p></li> </ul> </p></li> <li><p><strong>b</strong> – <ul> <li><p>a*cos(i)/R_s</p></li> </ul> </p></li> <li><p><strong>L</strong> – <ul> <li><p>Depth of eclipse</p></li> </ul> </p></li> <li><p><strong>f_c</strong> – <ul> <li><p>sqrt(ecc).cos(omega)</p></li> </ul> </p></li> <li><p><strong>f_s</strong> – <ul> <li><p>sqrt(ecc).sin(omega)</p></li> </ul> </p></li> <li><p><strong>a_c</strong> – <ul> <li><p>correction for light travel time across the orbit</p></li> </ul> </p></li> </ul> </dd> </dl> </dd></dl> <dl class="class"> <dt id="pycheops.models.FactorModel"> <em class="property">class </em><code class="sig-prename descclassname">pycheops.models.</code><code class="sig-name descname">FactorModel</code><span class="sig-paren">(</span><em class="sig-param">independent_vars=['t'], prefix='', nan_policy='raise', dx=None, dy=None, sinphi=None, cosphi=None, bg=None, **kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.models.FactorModel" title="Permalink to this definition">¶</a></dt> <dd><p>Flux scaling and trend factor model</p> <dl class="simple"> <dt>f = c*(1 + dfdt*dt + d2fdt2*dt**2 + dfdbg*bg(t) + </dt><dd><p>dfdx*dx(t) + dfdy*dy(t) + d2fdx2*dx(t)**2 + d2f2y2*dy(t)**2 + d2fdxdy*x(t)*dy(t) + dfdsinphi*sin(phi(t)) + dfdcosphi*cos(phi(t)) + dfdsin2phi*sin(2.phi(t)) + dfdcos2phi*cos(2.phi(t)) + dfdsin3phi*sin(3.phi(t)) + dfdcos3phi*cos(3.phi(t)) )</p> </dd> </dl> <p>The detrending coefficients dfdx, etc. are 0 and fixed by default. If any of the coefficients dfdx, d2fdxdy or d2f2x2 is not 0, a function to calculate the x-position offset as a function of time, dx(t), must be passed as a keyword argument, and similarly for the y-position offset, dy(t). For detrending against the spacecraft roll angle, phi(t), the functions to be provided as keywords arguments are sinphi(t) and cosphi(t). The linear trend dfdbg is proportional to the estimated background flux in the aperture, bg(t). The time trend decribed by dfdt and d2fdt2 is calculated using the variable dt = t - median(t).</p> <dl class="method"> <dt id="pycheops.models.FactorModel.guess"> <code class="sig-name descname">guess</code><span class="sig-paren">(</span><em class="sig-param">data</em>, <em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.models.FactorModel.guess" title="Permalink to this definition">¶</a></dt> <dd><p>Estimate initial model parameter values from data.</p> </dd></dl> </dd></dl> <dl class="class"> <dt id="pycheops.models.ThermalPhaseModel"> <em class="property">class </em><code class="sig-prename descclassname">pycheops.models.</code><code class="sig-name descname">ThermalPhaseModel</code><span class="sig-paren">(</span><em class="sig-param">independent_vars=['t'], prefix='', nan_policy='raise', **kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.models.ThermalPhaseModel" title="Permalink to this definition">¶</a></dt> <dd><p>Thermal phase model for a tidally-locked planet</p> <div class="math notranslate nohighlight"> \[a_{th}[1-\cos(\phi))/2 + b_{th}*(1+\sin(\phi)/2 + c_{th},\]</div> <p>where <span class="math notranslate nohighlight">\(\phi = 2\pi(t-T_0)/P\)</span></p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>t</strong> – <ul> <li><p>independent variable (time)</p></li> </ul> </p></li> <li><p><strong>T_0</strong> – <ul> <li><p>time of inferior conjunction (mid-transit)</p></li> </ul> </p></li> <li><p><strong>P</strong> – <ul> <li><p>orbital period</p></li> </ul> </p></li> <li><p><strong>a_th</strong> – <ul> <li><p>coefficient of cosine-like term</p></li> </ul> </p></li> <li><p><strong>b_th</strong> – <ul> <li><p>coefficient of sine-like term</p></li> </ul> </p></li> <li><p><strong>c_th</strong> – <ul> <li><p>constant term (minimum flux)</p></li> </ul> </p></li> </ul> </dd> </dl> <p>The following parameters are defined for convenience.</p> <ul class="simple"> <li><p>A = sqrt(a_th**2 + b_th**2), peak-to-trough amplitude of the phase curve</p></li> <li><p>F = c_th + (a_th + b_th + A)/2, flux at the maximum of the phase curve</p></li> <li><p>ph_max = arctan2(b_th,-a_th)/(2*pi) = phase at maximum flux</p></li> </ul> </dd></dl> <dl class="class"> <dt id="pycheops.models.ReflectionModel"> <em class="property">class </em><code class="sig-prename descclassname">pycheops.models.</code><code class="sig-name descname">ReflectionModel</code><span class="sig-paren">(</span><em class="sig-param">independent_vars=['t'], prefix='', nan_policy='raise', **kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.models.ReflectionModel" title="Permalink to this definition">¶</a></dt> <dd><p>Reflected stellar light from a planet with a Lambertian phase function.</p> <p>The fraction of the stellar flux reflected from the planet of radius <span class="math notranslate nohighlight">\(R_p\)</span> at a distance <span class="math notranslate nohighlight">\(r\)</span> from the star and viewed at phase angle <span class="math notranslate nohighlight">\(\beta\)</span> is</p> <div class="math notranslate nohighlight"> \[A_g(R_p/r)^2 \times [\sin(\beta) + (\pi-\beta)*\cos(\beta) ]/\pi\]</div> <p>The eccentricity and longitude of periastron for the planet’s orbit are ecc and omega, respectively.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>t</strong> – <ul> <li><p>independent variable (time)</p></li> </ul> </p></li> <li><p><strong>T_0</strong> – <ul> <li><p>time of inferior conjunction (mid-transit)</p></li> </ul> </p></li> <li><p><strong>P</strong> – <ul> <li><p>orbital period</p></li> </ul> </p></li> <li><p><strong>A_g</strong> – <ul> <li><p>geometric albedo</p></li> </ul> </p></li> <li><p><strong>r_p</strong> – <ul> <li><p>R_p/a, where a is the semi-major axis.</p></li> </ul> </p></li> <li><p><strong>f_c</strong> – <ul> <li><p>sqrt(ecc).cos(omega)</p></li> </ul> </p></li> <li><p><strong>f_s</strong> – <ul> <li><p>sqrt(ecc).sin(omega)</p></li> </ul> </p></li> <li><p><strong>sini</strong> – <ul> <li><p>sin(inclination)</p></li> </ul> </p></li> </ul> </dd> </dl> </dd></dl> <dl class="class"> <dt id="pycheops.models.RVModel"> <em class="property">class </em><code class="sig-prename descclassname">pycheops.models.</code><code class="sig-name descname">RVModel</code><span class="sig-paren">(</span><em class="sig-param">independent_vars=['t'], prefix='', nan_policy='raise', **kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.models.RVModel" title="Permalink to this definition">¶</a></dt> <dd><p>Radial velocity in a Keplerian orbit</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>t</strong> – <ul> <li><p>independent variable (time)</p></li> </ul> </p></li> <li><p><strong>T_0</strong> – <ul> <li><p>time of inferior conjunction for the companion (mid-transit)</p></li> </ul> </p></li> <li><p><strong>P</strong> – <ul> <li><p>orbital period</p></li> </ul> </p></li> <li><p><strong>V_0</strong> – <ul> <li><p>radial velocity of the centre-of-mass</p></li> </ul> </p></li> <li><p><strong>K</strong> – <ul> <li><p>semi-amplitude of spectroscopic orbit</p></li> </ul> </p></li> <li><p><strong>f_c</strong> – <ul> <li><p>sqrt(ecc).cos(omega)</p></li> </ul> </p></li> <li><p><strong>f_s</strong> – <ul> <li><p>sqrt(ecc).sin(omega)</p></li> </ul> </p></li> <li><p><strong>sini</strong> – <ul> <li><p>sine of the orbital inclination</p></li> </ul> </p></li> </ul> </dd> </dl> </dd></dl> <dl class="class"> <dt id="pycheops.models.RVCompanion"> <em class="property">class </em><code class="sig-prename descclassname">pycheops.models.</code><code class="sig-name descname">RVCompanion</code><span class="sig-paren">(</span><em class="sig-param">independent_vars=['t'], prefix='', nan_policy='raise', **kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.models.RVCompanion" title="Permalink to this definition">¶</a></dt> <dd><p>Radial velocity in a Keplerian orbit for the companion</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>t</strong> – <ul> <li><p>independent variable (time)</p></li> </ul> </p></li> <li><p><strong>T_0</strong> – <ul> <li><p>time of inferior conjunction for the companion (mid-transit)</p></li> </ul> </p></li> <li><p><strong>P</strong> – <ul> <li><p>orbital period</p></li> </ul> </p></li> <li><p><strong>V_0</strong> – <ul> <li><p>radial velocity of the centre-of-mass</p></li> </ul> </p></li> <li><p><strong>K</strong> – <ul> <li><p>semi-amplitude of spectroscopic orbit</p></li> </ul> </p></li> <li><p><strong>f_c</strong> – <ul> <li><p>sqrt(ecc).cos(omega)</p></li> </ul> </p></li> <li><p><strong>f_s</strong> – <ul> <li><p>sqrt(ecc).sin(omega)</p></li> </ul> </p></li> <li><p><strong>sini</strong> – <ul> <li><p>sine of the orbital inclination</p></li> </ul> </p></li> </ul> </dd> </dl> </dd></dl> <dl class="class"> <dt id="pycheops.models.EBLMModel"> <em class="property">class </em><code class="sig-prename descclassname">pycheops.models.</code><code class="sig-name descname">EBLMModel</code><span class="sig-paren">(</span><em class="sig-param">independent_vars=['t'], prefix='', nan_policy='raise', **kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.models.EBLMModel" title="Permalink to this definition">¶</a></dt> <dd><p>Light curve model for the mutual eclipses by spherical stars in an eclipsing binary with one low-mass companion, e.g., F/G-star + M-dwarf.</p> <p>The transit depth, width shape are parameterised by D, W and b. These parameters are defined below in terms of the radii of the stars, R_1 and R_2, the semi-major axis, a, and the orbital inclination, i. This model assumes R_1 &gt;&gt; R_2, i.e., k=R_2/R_1 &lt;~0.2. The eccentricy and longitude of periastron for the star’s orbit are e and omega, respectively. These are the same parameters used in TransitModel. The flux level outside of eclipse is 1 and inside eclipse is (1-L). The apparent time of mid-eclipse includes the correction a_c for the light travel time across the orbit, i.e., for a circular orbit the time of mid-eclipse is (T_0 + 0.5*P) + a_c.</p> <p><strong>N.B.</strong> a_c must have the same units as P. The power-2 law is used to model the limb-darkening of star 1. Limb-darkening on star 2 is ignored.</p> <p>The following parameters are defined for convenience:</p> <ul class="simple"> <li><p>k = R_2/R_1;</p></li> <li><p>aR = a/R_1;</p></li> <li><p>J = L/D (surface brightness ratio).</p></li> </ul> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>t</strong> – <ul> <li><p>independent variable (time)</p></li> </ul> </p></li> <li><p><strong>T_0</strong> – <ul> <li><p>time of mid-transit</p></li> </ul> </p></li> <li><p><strong>P</strong> – <ul> <li><p>orbital period</p></li> </ul> </p></li> <li><p><strong>D</strong> – <ul> <li><p>(R_2/R_1)**2 = k**2</p></li> </ul> </p></li> <li><p><strong>W</strong> – <ul> <li><p>(R_1/a)*sqrt((1+k)**2 - b**2)/pi</p></li> </ul> </p></li> <li><p><strong>b</strong> – <ul> <li><p>a*cos(i)/R_1</p></li> </ul> </p></li> <li><p><strong>L</strong> – <ul> <li><p>Depth of eclipse</p></li> </ul> </p></li> <li><p><strong>f_c</strong> – <ul> <li><p>sqrt(ecc).cos(omega)</p></li> </ul> </p></li> <li><p><strong>f_s</strong> – <ul> <li><p>sqrt(ecc).sin(omega)</p></li> </ul> </p></li> <li><p><strong>h_1</strong> – <ul> <li><p>I(0.5) = 1 - c*(1-0.5**alpha)</p></li> </ul> </p></li> <li><p><strong>h_2</strong> – <ul> <li><p>I(0.5) - I(0) = c*0.5**alpha</p></li> </ul> </p></li> <li><p><strong>a_c</strong> – <ul> <li><p>correction for light travel time across the orbit</p></li> </ul> </p></li> </ul> </dd> </dl> </dd></dl> <dl class="class"> <dt id="pycheops.models.PlanetModel"> <em class="property">class </em><code class="sig-prename descclassname">pycheops.models.</code><code class="sig-name descname">PlanetModel</code><span class="sig-paren">(</span><em class="sig-param">independent_vars=['t'], prefix='', nan_policy='raise', **kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.models.PlanetModel" title="Permalink to this definition">¶</a></dt> <dd><p>Light curve model for a transiting exoplanet including transits, eclipses, and a thermal phase curve for the planet with an offset.</p> <p>The flux level from the star is 1 and is assumed to be constant.</p> <p>The thermal phase curve from the planet is approximated by a cosine function with amplitude A=F_max-F_min plus the minimum flux, F_min, i.e., the maximum flux is F_max = F_min+A, and this occurs at phase (ph_off+0.5) relative to the time of mid-transit, i.e.,</p> <div class="math notranslate nohighlight"> \[f_{\rm th} = F_{\rm min} + A[1-\cos(\phi-\phi_{\rm off})]/2\]</div> <p>where <span class="math notranslate nohighlight">\(\phi = 2\pi(t-T_0)/P\)</span> and <span class="math notranslate nohighlight">\(\phi_{\rm off} = 2\pi\,{\rm ph\_off}\)</span>.</p> <p>The transit depth, width shape are parameterised by D, W and b. These parameters are defined below in terms of the radius of the star, R_1 and R_2, the semi-major axis, a, and the orbital inclination, i. This model assumes R_1 &gt;&gt; R_2, i.e., k=R_2/R_1 &lt;~0.2. The eccentricy and longitude of periastron for the star’s orbit are e and omega, respectively. These are the same parameters used in TransitModel. The eclipse of the planet assumes a uniform flux distribution.</p> <p>The apparent time of mid-eclipse includes the correction a_c for the light travel time across the orbit, i.e., for a circular orbit the time of mid-eclipse is (T_0 + 0.5*P) + a_c.</p> <p><strong>N.B.</strong> a_c must have the same units as P.</p> <p>Stellar limb-darkening is described by the power-2 law:</p> <div class="math notranslate nohighlight"> \[I(\mu) = 1 - c (1 - \mu^\alpha)\]</div> <p>The following parameters are defined for convenience:</p> <ul class="simple"> <li><p>k = R_2/R_1;</p></li> <li><p>aR = a/R_1;</p></li> <li><p>A = F_max - F_min = amplitude of thermal phase effect.</p></li> <li><p>rho = 0.013418*aR**3/(P/d)**2.</p></li> </ul> <p><strong>N.B.</strong> the mean stellar density in solar units is rho, but only if the mass ratio q = M_planet/M_star is q &lt;&lt; 1.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>t</strong> – <ul> <li><p>independent variable (time)</p></li> </ul> </p></li> <li><p><strong>T_0</strong> – <ul> <li><p>time of mid-transit</p></li> </ul> </p></li> <li><p><strong>P</strong> – <ul> <li><p>orbital period</p></li> </ul> </p></li> <li><p><strong>D</strong> – <ul> <li><p>(R_2/R_1)**2 = k**2</p></li> </ul> </p></li> <li><p><strong>W</strong> – <ul> <li><p>(R_1/a)*sqrt((1+k)**2 - b**2)/pi</p></li> </ul> </p></li> <li><p><strong>b</strong> – <ul> <li><p>a*cos(i)/R_1</p></li> </ul> </p></li> <li><p><strong>F_min</strong> – <ul> <li><p>minimum flux in the thermal phase model</p></li> </ul> </p></li> <li><p><strong>F_max</strong> – <ul> <li><p>maximum flux in the thermal phase model</p></li> </ul> </p></li> <li><p><strong>ph_off</strong> – <ul> <li><p>offset phase in the thermal phase model</p></li> </ul> </p></li> <li><p><strong>f_c</strong> – <ul> <li><p>sqrt(ecc).cos(omega)</p></li> </ul> </p></li> <li><p><strong>f_s</strong> – <ul> <li><p>sqrt(ecc).sin(omega)</p></li> </ul> </p></li> <li><p><strong>h_1</strong> – <ul> <li><p>I(0.5) = 1 - c*(1-0.5**alpha)</p></li> </ul> </p></li> <li><p><strong>h_2</strong> – <ul> <li><p>I(0.5) - I(0) = c*0.5**alpha</p></li> </ul> </p></li> <li><p><strong>a_c</strong> – <ul> <li><p>correction for light travel time across the orbit</p></li> </ul> </p></li> </ul> </dd> </dl> </dd></dl> <dl class="attribute"> <dt id="pycheops.models.scaled_transit_fit"> <code class="sig-prename descclassname">pycheops.models.</code><code class="sig-name descname">scaled_transit_fit</code><a class="headerlink" href="#pycheops.models.scaled_transit_fit" title="Permalink to this definition">¶</a></dt> <dd><p>Optimum scaled transit depth for data with scaled errors</p> <p>Find the value of the scaling factor s that provides the best fit of the model m = 1 + s*(model-1) to the normalised input fluxes. It is assumed that the true standard errors on the flux measurements are a factor f times the nominal standard error(s) provided in sigma. Also returns standard error estimates for s and f, sigma_s and sigma_f, respectively.</p> <blockquote> <div><dl class="field-list simple"> <dt class="field-odd">param flux</dt> <dd class="field-odd"><p>Array of normalised flux measurements</p> </dd> <dt class="field-even">param sigma</dt> <dd class="field-even"><p>Standard error estimate(s) for flux - array or scalar</p> </dd> <dt class="field-odd">param model</dt> <dd class="field-odd"><p>Transit model to be scaled</p> </dd> <dt class="field-even">returns</dt> <dd class="field-even"><p>s, b, sigma_s, sigma_b</p> </dd> </dl> </div></blockquote> </dd></dl> <dl class="function"> <dt id="pycheops.models.minerr_transit_fit"> <code class="sig-prename descclassname">pycheops.models.</code><code class="sig-name descname">minerr_transit_fit</code><span class="sig-paren">(</span><em class="sig-param">flux</em>, <em class="sig-param">sigma</em>, <em class="sig-param">model</em><span class="sig-paren">)</span><a class="headerlink" href="#pycheops.models.minerr_transit_fit" title="Permalink to this definition">¶</a></dt> <dd><blockquote> <div><p>Optimum scaled transit depth for data with lower bounds on errors</p> <p>Find the value of the scaling factor s that provides the best fit of the model m = 1 + s*(model-1) to the normalised input fluxes. It is assumed that the nominal standard error(s) provided in sigma are lower bounds to the true standard errors on the flux measurements. <a class="footnote-reference brackets" href="#id4" id="id3">1</a> The probability distribution for the true standard errors is assumed to be</p> <div class="math notranslate nohighlight"> \[P(\sigma_{\rm true} | \sigma) = \sigma/\sigma_{\rm true}^2 \]</div> <dl class="field-list simple"> <dt class="field-odd">param flux</dt> <dd class="field-odd"><p>Array of normalised flux measurements</p> </dd> <dt class="field-even">param sigma</dt> <dd class="field-even"><p>Lower bound(s) on standard error for flux - array or scalar</p> </dd> <dt class="field-odd">param model</dt> <dd class="field-odd"><p>Transit model to be scaled</p> </dd> <dt class="field-even">returns</dt> <dd class="field-even"><p>s, sigma_s</p> </dd> </dl> </div></blockquote> <dl class="footnote brackets"> <dt class="label" id="id4"><span class="brackets"><a class="fn-backref" href="#id3">1</a></span></dt> <dd><p>Sivia, D.S. &amp; Skilling, J., Data Analysis - A Bayesian Tutorial, 2nd ed., section 8.3.1</p> </dd> </dl> </dd></dl> </div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h1 class="logo"><a href="index.html">pycheops</a></h1> <h3>Navigation</h3> <p class="caption"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="constants.html">constants</a></li> <li class="toctree-l1"><a class="reference internal" href="funcs.html">funcs</a></li> <li class="toctree-l1"><a class="reference internal" href="instrument.html">instrument</a></li> <li class="toctree-l1"><a class="reference internal" href="ld.html">ld</a></li> <li class="toctree-l1 current"><a class="current reference internal" href="#">models</a></li> <li class="toctree-l1"><a class="reference internal" href="quantities.html">quantities</a></li> </ul> <div class="relations"> <h3>Related Topics</h3> <ul> <li><a href="index.html">Documentation overview</a><ul> <li>Previous: <a href="ld.html" title="previous chapter">ld</a></li> <li>Next: <a href="quantities.html" title="next chapter">quantities</a></li> </ul></li> </ul> </div> <div id="searchbox" style="display: none" role="search"> <h3 id="searchlabel">Quick search</h3> <div class="searchformwrapper"> <form class="search" action="search.html" method="get"> <input type="text" name="q" aria-labelledby="searchlabel" /> <input type="submit" value="Go" /> </form> </div> </div> <script>$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="footer"> &copy;2018, [email protected]. | Powered by <a href="http://sphinx-doc.org/">Sphinx 2.4.0</a> &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a> | <a href="_sources/models.rst.txt" rel="nofollow">Page source</a> </div> </body> </html>
33,302
41.478316
485
html
pycheops
pycheops-master/docs/_build/html/py-modindex.html
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title>Python Module Index &#8212; pycheops 0.0.16 documentation</title> <link rel="stylesheet" href="_static/alabaster.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> <script src="_static/doctools.js"></script> <script src="_static/language_data.js"></script> <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="stylesheet" href="_static/custom.css" type="text/css" /> <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" /> </head><body> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <h1>Python Module Index</h1> <div class="modindex-jumpbox"> <a href="#cap-p"><strong>p</strong></a> </div> <table class="indextable modindextable"> <tr class="pcap"><td></td><td>&#160;</td><td></td></tr> <tr class="cap" id="cap-p"><td></td><td> <strong>p</strong></td><td></td></tr> <tr> <td><img src="_static/minus.png" class="toggler" id="toggle-1" style="display: none" alt="-" /></td> <td> <a href="index.html#module-pycheops"><code class="xref">pycheops</code></a></td><td> <em></em></td></tr> <tr class="cg-1"> <td></td> <td>&#160;&#160;&#160; <a href="constants.html#module-pycheops.constants"><code class="xref">pycheops.constants</code></a></td><td> <em></em></td></tr> <tr class="cg-1"> <td></td> <td>&#160;&#160;&#160; <a href="funcs.html#module-pycheops.funcs"><code class="xref">pycheops.funcs</code></a></td><td> <em></em></td></tr> <tr class="cg-1"> <td></td> <td>&#160;&#160;&#160; <a href="instrument.html#module-pycheops.instrument"><code class="xref">pycheops.instrument</code></a></td><td> <em></em></td></tr> <tr class="cg-1"> <td></td> <td>&#160;&#160;&#160; <a href="ld.html#module-pycheops.ld"><code class="xref">pycheops.ld</code></a></td><td> <em></em></td></tr> <tr class="cg-1"> <td></td> <td>&#160;&#160;&#160; <a href="models.html#module-pycheops.models"><code class="xref">pycheops.models</code></a></td><td> <em></em></td></tr> <tr class="cg-1"> <td></td> <td>&#160;&#160;&#160; <a href="quantities.html#module-pycheops.quantities"><code class="xref">pycheops.quantities</code></a></td><td> <em></em></td></tr> </table> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h1 class="logo"><a href="index.html">pycheops</a></h1> <h3>Navigation</h3> <p class="caption"><span class="caption-text">Contents:</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="constants.html">constants</a></li> <li class="toctree-l1"><a class="reference internal" href="funcs.html">funcs</a></li> <li class="toctree-l1"><a class="reference internal" href="instrument.html">instrument</a></li> <li class="toctree-l1"><a class="reference internal" href="ld.html">ld</a></li> <li class="toctree-l1"><a class="reference internal" href="models.html">models</a></li> <li class="toctree-l1"><a class="reference internal" href="quantities.html">quantities</a></li> </ul> <div class="relations"> <h3>Related Topics</h3> <ul> <li><a href="index.html">Documentation overview</a><ul> </ul></li> </ul> </div> <div id="searchbox" style="display: none" role="search"> <h3 id="searchlabel">Quick search</h3> <div class="searchformwrapper"> <form class="search" action="search.html" method="get"> <input type="text" name="q" aria-labelledby="searchlabel" /> <input type="submit" value="Go" /> </form> </div> </div> <script>$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="footer"> &copy;2018, [email protected]. | Powered by <a href="http://sphinx-doc.org/">Sphinx 2.4.0</a> &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a> </div> </body> </html>
4,834
30.193548
133
html
pycheops
pycheops-master/docs/_build/html/quantities.html
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title>quantities &#8212; pycheops 0.0.16 documentation</title> <link rel="stylesheet" href="_static/alabaster.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> <script src="_static/doctools.js"></script> <script src="_static/language_data.js"></script> <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="prev" title="models" href="models.html" /> <link rel="stylesheet" href="_static/custom.css" type="text/css" /> <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" /> </head><body> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="toctree-wrapper compound"> </div> <span class="target" id="module-pycheops.quantities"></span><div class="section" id="quantities"> <h1>quantities<a class="headerlink" href="#quantities" title="Permalink to this headline">¶</a></h1> <p>Nominal values of solar and planetary constants from IAU Resolution B3 <a class="footnote-reference brackets" href="#id5" id="id1">1</a> plus related constants as astropy quantities.</p> <p>Masses in SI units are derived using the 2014 CODATA value for the Newtonian constant, G=6.67408E-11 m3.kg-1.s-2.</p> <p>The following conversion constants are defined.</p> <div class="section" id="solar-conversion-constants"> <h2>Solar conversion constants<a class="headerlink" href="#solar-conversion-constants" title="Permalink to this headline">¶</a></h2> <ul class="simple"> <li><p>R_SunN - solar radius</p></li> <li><p>S_SunN - total solar irradiance</p></li> <li><p>L_SunN - solar luminosity</p></li> <li><p>Teff_SunN - solar effective temperature</p></li> <li><p>GM_SunN - solar mass parameter</p></li> <li><p>M_SunN - solar mass derived from GM_SunN and G_2014</p></li> <li><p>V_SunN - solar volume = (4.pi.R_SunN**3/3)</p></li> </ul> </div> <div class="section" id="planetary-conversion-constants"> <h2>Planetary conversion constants<a class="headerlink" href="#planetary-conversion-constants" title="Permalink to this headline">¶</a></h2> <ul class="simple"> <li><p>R_eEarthN - equatorial radius of the Earth</p></li> <li><p>R_pEarthN - polar radius of the Earth</p></li> <li><p>R_eJupN - equatorial radius of Jupiter</p></li> <li><p>R_pJupN - polar radius of Jupiter</p></li> <li><p>GM_EarthN - terrestrial mass parameter</p></li> <li><p>GM_JupN - jovian mass parameter</p></li> <li><p>M_EarthN - mass of the Earth from GM_EarthN and G_2014</p></li> <li><p>M_JupN - mass of Jupiter from GM_JupN and G_2014</p></li> <li><p>V_EarthN - volume of the Earth (4.pi.R_eEarthN^2.R_pEarthN/3)</p></li> <li><p>V_JupN - volume of Jupiter (4.pi.R_eJupN^2.R_pJupN/3)</p></li> <li><p>R_EarthN - volume-average radius of the Earth (3.V_EarthN/4.pi)^(1/3)</p></li> <li><p>R_JupN - volume-average radius of Jupiter (3.V_JupN/4.pi)^(1/3)</p></li> </ul> </div> <div class="section" id="related-constants"> <h2>Related constants<a class="headerlink" href="#related-constants" title="Permalink to this headline">¶</a></h2> <ul class="simple"> <li><p>G_2014 - 2014 CODATA value for the Newtonian constant</p></li> <li><p>mean_solar_day - 86,400.002 seconds <a class="footnote-reference brackets" href="#id6" id="id2">2</a></p></li> <li><p>au - IAU 2009 value for astronomical constant in metres. <a class="footnote-reference brackets" href="#id7" id="id3">3</a></p></li> <li><p>pc - 1 parsec = 3600*au*180/pi</p></li> </ul> </div> <div class="section" id="fundamental-constants"> <h2>Fundamental constants<a class="headerlink" href="#fundamental-constants" title="Permalink to this headline">¶</a></h2> <ul class="simple"> <li><p>c - speed of light in m.s-1 <a class="footnote-reference brackets" href="#id7" id="id4">3</a></p></li> </ul> </div> <div class="section" id="example"> <h2>Example<a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h2> <p>Calculate the density relative to Jupiter for a planet 1/10 the radius of the Sun with a mass 1/1000 of a solar mass. Note that we use the volume-average radius for Jupiter in this case:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pycheops.quantities</span> <span class="kn">import</span> <span class="n">M_SunN</span><span class="p">,</span> <span class="n">R_SunN</span><span class="p">,</span> <span class="n">M_JupN</span><span class="p">,</span> <span class="n">R_JupN</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">M_planet_Jup</span> <span class="o">=</span> <span class="n">M_SunN</span><span class="o">/</span><span class="mi">1000</span> <span class="o">/</span> <span class="n">M_JupN</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">R_planet_Jup</span> <span class="o">=</span> <span class="n">R_SunN</span><span class="o">/</span><span class="mi">10</span> <span class="o">/</span> <span class="n">R_JupN</span> <span class="gp">&gt;&gt;&gt; </span><span class="n">rho_planet_Jup</span> <span class="o">=</span> <span class="n">M_planet_Jup</span> <span class="o">/</span> <span class="p">(</span><span class="n">R_planet_Jup</span><span class="o">**</span><span class="mi">3</span><span class="p">)</span> <span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span> <span class="p">(</span><span class="s2">&quot;Planet mass = </span><span class="si">{:.3f}</span><span class="s2"> M_Jup&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">M_planet_Jup</span><span class="p">))</span> <span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span> <span class="p">(</span><span class="s2">&quot;Planet radius = </span><span class="si">{:.3f}</span><span class="s2"> R_Jup&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">R_planet_Jup</span><span class="p">))</span> <span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span> <span class="p">(</span><span class="s2">&quot;Planet density = </span><span class="si">{:.3f}</span><span class="s2"> rho_Jup&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">rho_planet_Jup</span><span class="p">))</span> <span class="go">Planet mass = 1.048 M_Jup</span> <span class="go">Planet radius = 0.995 R_Jup</span> <span class="go">Planet density = 1.063 rho_Jup</span> </pre></div> </div> <p class="rubric">References</p> <dl class="footnote brackets"> <dt class="label" id="id5"><span class="brackets"><a class="fn-backref" href="#id1">1</a></span></dt> <dd><p><a class="reference external" href="https://www.iau.org/static/resolutions/IAU2015_English.pdf">https://www.iau.org/static/resolutions/IAU2015_English.pdf</a></p> </dd> <dt class="label" id="id6"><span class="brackets"><a class="fn-backref" href="#id2">2</a></span></dt> <dd><p><a class="reference external" href="http://tycho.usno.navy.mil/leapsec.html">http://tycho.usno.navy.mil/leapsec.html</a></p> </dd> <dt class="label" id="id7"><span class="brackets">3</span><span class="fn-backref">(<a href="#id3">1</a>,<a href="#id4">2</a>)</span></dt> <dd><p>Luzum et al., Celest Mech Dyn Astr (2011) 110:293-304</p> </dd> </dl> </div> </div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h1 class="logo"><a href="index.html">pycheops</a></h1> <h3>Navigation</h3> <p class="caption"><span class="caption-text">Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="constants.html">constants</a></li> <li class="toctree-l1"><a class="reference internal" href="funcs.html">funcs</a></li> <li class="toctree-l1"><a class="reference internal" href="instrument.html">instrument</a></li> <li class="toctree-l1"><a class="reference internal" href="ld.html">ld</a></li> <li class="toctree-l1"><a class="reference internal" href="models.html">models</a></li> <li class="toctree-l1 current"><a class="current reference internal" href="#">quantities</a></li> </ul> <div class="relations"> <h3>Related Topics</h3> <ul> <li><a href="index.html">Documentation overview</a><ul> <li>Previous: <a href="models.html" title="previous chapter">models</a></li> </ul></li> </ul> </div> <div id="searchbox" style="display: none" role="search"> <h3 id="searchlabel">Quick search</h3> <div class="searchformwrapper"> <form class="search" action="search.html" method="get"> <input type="text" name="q" aria-labelledby="searchlabel" /> <input type="submit" value="Go" /> </form> </div> </div> <script>$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="footer"> &copy;2018, [email protected]. | Powered by <a href="http://sphinx-doc.org/">Sphinx 2.4.0</a> &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a> | <a href="_sources/quantities.rst.txt" rel="nofollow">Page source</a> </div> </body> </html>
9,950
50.559585
416
html
pycheops
pycheops-master/docs/_build/html/search.html
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title>Search &#8212; pycheops 0.0.16 documentation</title> <link rel="stylesheet" href="_static/alabaster.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> <script src="_static/doctools.js"></script> <script src="_static/language_data.js"></script> <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script> <script src="_static/searchtools.js"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="#" /> <script src="searchindex.js" defer></script> <link rel="stylesheet" href="_static/custom.css" type="text/css" /> <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" /> </head><body> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <h1 id="search-documentation">Search</h1> <div id="fallback" class="admonition warning"> <script>$('#fallback').hide();</script> <p> Please activate JavaScript to enable the search functionality. </p> </div> <p> From here you can search these documents. Enter your search words into the box below and click "search". Note that the search function will automatically search for all of the words. Pages containing fewer words won't appear in the result list. </p> <form action="" method="get"> <input type="text" name="q" aria-labelledby="search-documentation" value="" /> <input type="submit" value="search" /> <span id="search-progress" style="padding-left: 10px"></span> </form> <div id="search-results"> </div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h1 class="logo"><a href="index.html">pycheops</a></h1> <h3>Navigation</h3> <p class="caption"><span class="caption-text">Contents:</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="constants.html">constants</a></li> <li class="toctree-l1"><a class="reference internal" href="funcs.html">funcs</a></li> <li class="toctree-l1"><a class="reference internal" href="instrument.html">instrument</a></li> <li class="toctree-l1"><a class="reference internal" href="ld.html">ld</a></li> <li class="toctree-l1"><a class="reference internal" href="models.html">models</a></li> <li class="toctree-l1"><a class="reference internal" href="quantities.html">quantities</a></li> </ul> <div class="relations"> <h3>Related Topics</h3> <ul> <li><a href="index.html">Documentation overview</a><ul> </ul></li> </ul> </div> </div> </div> <div class="clearer"></div> </div> <div class="footer"> &copy;2018, [email protected]. | Powered by <a href="http://sphinx-doc.org/">Sphinx 2.4.0</a> &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a> </div> </body> </html>
3,484
27.801653
133
html
pyrouge
pyrouge-master/pyrouge/tests/data/spl_test_doc.html
<html> <head> <title>D00000.M.100.A.C</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>BritishCCC authoritiesCCC arrestedCCC GeneralCCC AugustoCCC PinochetCCC inCCC LondonCCC forCCC backCCC surgeryCCC onCCC anCCC internationalCCC warrantCCC</a> <a name="2">[2]</a> <a href="#2" id=2>issuedCCC byCCC SpanishCCC magistrateCCC BaltasarCCC GarzonCCC</a> <a name="3">[3]</a> <a href="#3" id=3>TheCCC MadridCCC courtCCC chargedCCC PinochetCCC</a> <a name="4">[4]</a> <a href="#4" id=4>whoCCC ruledCCC ChileCCC asCCC aCCC despotCCC forCCC yearsCCC</a> <a name="5">[5]</a> <a href="#5" id=5>withCCC crimesCCC againstCCC humanityCCC</a> <a name="6">[6]</a> <a href="#6" id=6>includingCCC genocideCCC andCCC terrorismCCC involvingCCC theCCC deathsCCC ofCCC moreCCC thanCCC peopleCCC</a> <a name="7">[7]</a> <a href="#7" id=7>TheCCC ChileanCCC governmentCCC protestedCCC thatCCC PinochetCCC nowCCC aCCC hasCCC legalCCC immunityCCC</a> <a name="8">[8]</a> <a href="#8" id=8>butCCC fewCCC inCCC ChileanCCC societyCCC protestedCCC theCCC arrestCCC</a> <a name="9">[9]</a> <a href="#9" id=9>PinochetCCC arrestCCC showsCCC theCCC growingCCC significanceCCC ofCCC internationalCCC lawCCC</a> <a name="10">[10]</a> <a href="#10" id=10>suggestingCCC thatCCC officialsCCC accusedCCC ofCCC atrocitiesCCC haveCCC fewerCCC placesCCC toCCC hideCCC theseCCC daysCCC</a> <a name="11">[11]</a> <a href="#11" id=11>evenCCC ifCCC theyCCC areCCC carryingCCC diplomaticCCC passportsCCC</a> </body> </html>
1,503
78.157895
195
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_plain_text/SL.P.10.R.A.SL062003-01.html
Poor nations demand trade subsidies from developed nations.
59
59
59
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_plain_text/SL.P.10.R.A.SL062003-02.html
Indonesia charges Imam Samudra and Amrozi with Bali bombing.
60
60
60
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_plain_text/SL.P.10.R.A.SL062003-03.html
Improvements in homeland security, intelligence required to eliminate terrorist threat.
87
87
87
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_plain_text/SL.P.10.R.A.SL062003-04.html
War against terror for India and world will continue.
53
53
53
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_plain_text/SL.P.10.R.A.SL062003-05.html
Musharraf charms media, but Agra Summit fails.
46
46
46
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_plain_text/SL.P.10.R.A.SL062003-06.html
Uday Marankar reminisces on the devastation caused by Gujrat earthquake.
72
72
72
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_plain_text/SL.P.10.R.A.SL062003-07.html
Vajpayee showed lack of leadership in governing country in 2001.
64
64
64
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_plain_text/SL.P.10.R.A.SL062003-08.html
Iraq has 2 months to turn over weapons of mass destruction.
59
59
59
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_plain_text/SL.P.10.R.A.SL062003-09.html
American Industry saved $10 billion by outsourcing to India: NASSCOM
68
68
68
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_plain_text/SL.P.10.R.A.SL062003-10.html
Mehta and 3 others convicted for stock market scandal.
54
54
54
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_plain_text/SL.P.10.R.A.SL062003-11.html
Defense minister threatens Jayalalitha with criminal investigation.
67
67
67
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_plain_text/SL.P.10.R.A.SL062003-12.html
India wants friendly relations with neighbors: Jaswant Singh
60
60
60
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_plain_text/SL.P.10.R.A.SL062003-13.html
No slandering or slogan shouting at Singh's campaign party.
59
59
59
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_plain_text/SL.P.10.R.A.SL062003-14.html
World Bank president praises India's economic development.
58
58
58
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_plain_text/SL.P.10.R.A.SL062003-15.html
Protests and demonstrations at site of G8 summit.
49
49
49
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_plain_text/SL.P.10.R.A.SL062003-16.html
"No shortage of IT professionals in the country": Pasvaan
57
57
57
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_plain_text/SL.P.10.R.A.SL062003-17.html
New hope for peace in Kashmir after Vajpayee, Sonia's visit.
60
60
60
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_plain_text/SL.P.10.R.A.SL062003-18.html
India's plans to send unmanned moon mission on right track.
59
59
59
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_plain_text/SL.P.10.R.A.SL062003-19.html
Investigation on to determine cause of fire in army depot.
58
58
58
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_plain_text/SL.P.10.R.A.SL062003-20.html
Project to save tigers successful: Environment and Forest Ministry.
67
67
67
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_plain_text/SL.P.10.R.A.SL062003-21.html
Hunt on for killers of BHEL's Vice-President, family.
53
53
53
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_plain_text/SL.P.10.R.A.SL062003-22.html
India can deliver fitting response to Pakistan: Chinmayananda
61
61
61
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_plain_text/SL.P.10.R.A.SL062003-23.html
Project to make India a "Developed Nation" by 2020.
51
51
51
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_plain_text/SL.P.10.R.A.SL062003-24.html
4 killed in accident between Roadway bus and Maruti.
52
52
52
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_plain_text/SL.P.10.R.A.SL062003-25.html
Kashmir can forge friendship between India and Pakistan: Mufti
62
62
62
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_rouge_format/SL.P.10.R.A.SL062003-01.html
<html> <head> <title>SL.P.10.R.A.SL062003-01</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>Poor nations demand trade subsidies from developed nations.</a> </body> </html>
202
21.555556
101
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_rouge_format/SL.P.10.R.A.SL062003-02.html
<html> <head> <title>SL.P.10.R.A.SL062003-02</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>Indonesia charges Imam Samudra and Amrozi with Bali bombing.</a> </body> </html>
203
21.666667
102
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_rouge_format/SL.P.10.R.A.SL062003-03.html
<html> <head> <title>SL.P.10.R.A.SL062003-03</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>Improvements in homeland security, intelligence required to eliminate terrorist threat.</a> </body> </html>
230
24.666667
129
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_rouge_format/SL.P.10.R.A.SL062003-04.html
<html> <head> <title>SL.P.10.R.A.SL062003-04</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>War against terror for India and world will continue.</a> </body> </html>
196
20.888889
95
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_rouge_format/SL.P.10.R.A.SL062003-05.html
<html> <head> <title>SL.P.10.R.A.SL062003-05</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>Musharraf charms media, but Agra Summit fails.</a> </body> </html>
189
20.111111
88
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_rouge_format/SL.P.10.R.A.SL062003-06.html
<html> <head> <title>SL.P.10.R.A.SL062003-06</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>Uday Marankar reminisces on the devastation caused by Gujrat earthquake.</a> </body> </html>
215
23
114
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_rouge_format/SL.P.10.R.A.SL062003-07.html
<html> <head> <title>SL.P.10.R.A.SL062003-07</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>Vajpayee showed lack of leadership in governing country in 2001.</a> </body> </html>
207
22.111111
106
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_rouge_format/SL.P.10.R.A.SL062003-08.html
<html> <head> <title>SL.P.10.R.A.SL062003-08</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>Iraq has 2 months to turn over weapons of mass destruction.</a> </body> </html>
202
21.555556
101
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_rouge_format/SL.P.10.R.A.SL062003-09.html
<html> <head> <title>SL.P.10.R.A.SL062003-09</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>American Industry saved $10 billion by outsourcing to India: NASSCOM</a> </body> </html>
211
22.555556
110
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_rouge_format/SL.P.10.R.A.SL062003-10.html
<html> <head> <title>SL.P.10.R.A.SL062003-10</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>Mehta and 3 others convicted for stock market scandal.</a> </body> </html>
197
21
96
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_rouge_format/SL.P.10.R.A.SL062003-11.html
<html> <head> <title>SL.P.10.R.A.SL062003-11</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>Defense minister threatens Jayalalitha with criminal investigation.</a> </body> </html>
210
22.444444
109
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_rouge_format/SL.P.10.R.A.SL062003-12.html
<html> <head> <title>SL.P.10.R.A.SL062003-12</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>India wants friendly relations with neighbors: Jaswant Singh</a> </body> </html>
203
21.666667
102
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_rouge_format/SL.P.10.R.A.SL062003-13.html
<html> <head> <title>SL.P.10.R.A.SL062003-13</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>No slandering or slogan shouting at Singh's campaign party.</a> </body> </html>
202
21.555556
101
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_rouge_format/SL.P.10.R.A.SL062003-14.html
<html> <head> <title>SL.P.10.R.A.SL062003-14</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>World Bank president praises India's economic development.</a> </body> </html>
201
21.444444
100
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_rouge_format/SL.P.10.R.A.SL062003-15.html
<html> <head> <title>SL.P.10.R.A.SL062003-15</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>Protests and demonstrations at site of G8 summit.</a> </body> </html>
192
20.444444
91
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_rouge_format/SL.P.10.R.A.SL062003-16.html
<html> <head> <title>SL.P.10.R.A.SL062003-16</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>"No shortage of IT professionals in the country": Pasvaan</a> </body> </html>
200
21.333333
99
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_rouge_format/SL.P.10.R.A.SL062003-17.html
<html> <head> <title>SL.P.10.R.A.SL062003-17</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>New hope for peace in Kashmir after Vajpayee, Sonia's visit.</a> </body> </html>
203
21.666667
102
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_rouge_format/SL.P.10.R.A.SL062003-18.html
<html> <head> <title>SL.P.10.R.A.SL062003-18</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>India's plans to send unmanned moon mission on right track.</a> </body> </html>
202
21.555556
101
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_rouge_format/SL.P.10.R.A.SL062003-19.html
<html> <head> <title>SL.P.10.R.A.SL062003-19</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>Investigation on to determine cause of fire in army depot.</a> </body> </html>
201
21.444444
100
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_rouge_format/SL.P.10.R.A.SL062003-20.html
<html> <head> <title>SL.P.10.R.A.SL062003-20</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>Project to save tigers successful: Environment and Forest Ministry.</a> </body> </html>
210
22.444444
109
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_rouge_format/SL.P.10.R.A.SL062003-21.html
<html> <head> <title>SL.P.10.R.A.SL062003-21</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>Hunt on for killers of BHEL's Vice-President, family.</a> </body> </html>
196
20.888889
95
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_rouge_format/SL.P.10.R.A.SL062003-22.html
<html> <head> <title>SL.P.10.R.A.SL062003-22</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>India can deliver fitting response to Pakistan: Chinmayananda</a> </body> </html>
204
21.777778
103
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_rouge_format/SL.P.10.R.A.SL062003-23.html
<html> <head> <title>SL.P.10.R.A.SL062003-23</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>Project to make India a "Developed Nation" by 2020.</a> </body> </html>
194
20.666667
93
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_rouge_format/SL.P.10.R.A.SL062003-24.html
<html> <head> <title>SL.P.10.R.A.SL062003-24</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>4 killed in accident between Roadway bus and Maruti.</a> </body> </html>
195
20.777778
94
html
pyrouge
pyrouge-master/pyrouge/tests/data/SL2003_models_rouge_format/SL.P.10.R.A.SL062003-25.html
<html> <head> <title>SL.P.10.R.A.SL062003-25</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>Kashmir can forge friendship between India and Pakistan: Mufti</a> </body> </html>
205
21.888889
104
html
pyrouge
pyrouge-master/pyrouge/tests/data/models/SL.P.10.R.A.SL062003-01.html
<html> <head> <title>SL.P.10.R.A.SL062003-01</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>Poor nations demand trade subsidies from developed nations.</a> </body> </html>
202
21.555556
101
html
pyrouge
pyrouge-master/pyrouge/tests/data/models/SL.P.10.R.A.SL062003-02.html
<html> <head> <title>SL.P.10.R.A.SL062003-02</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>Indonesia charges Imam Samudra and Amrozi with Bali bombing.</a> </body> </html>
203
21.666667
102
html
pyrouge
pyrouge-master/pyrouge/tests/data/models/SL.P.10.R.A.SL062003-03.html
<html> <head> <title>SL.P.10.R.A.SL062003-03</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>Improvements in homeland security, intelligence required to eliminate terrorist threat.</a> </body> </html>
230
24.666667
129
html
pyrouge
pyrouge-master/pyrouge/tests/data/models/SL.P.10.R.A.SL062003-04.html
<html> <head> <title>SL.P.10.R.A.SL062003-04</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>War against terror for India and world will continue.</a> </body> </html>
196
20.888889
95
html
pyrouge
pyrouge-master/pyrouge/tests/data/models/SL.P.10.R.A.SL062003-05.html
<html> <head> <title>SL.P.10.R.A.SL062003-05</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>Musharraf charms media, but Agra Summit fails.</a> </body> </html>
189
20.111111
88
html
pyrouge
pyrouge-master/pyrouge/tests/data/models/SL.P.10.R.A.SL062003-06.html
<html> <head> <title>SL.P.10.R.A.SL062003-06</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>Uday Marankar reminisces on the devastation caused by Gujrat earthquake.</a> </body> </html>
215
23
114
html
pyrouge
pyrouge-master/pyrouge/tests/data/models/SL.P.10.R.A.SL062003-07.html
<html> <head> <title>SL.P.10.R.A.SL062003-07</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>Vajpayee showed lack of leadership in governing country in 2001.</a> </body> </html>
207
22.111111
106
html
pyrouge
pyrouge-master/pyrouge/tests/data/models/SL.P.10.R.A.SL062003-08.html
<html> <head> <title>SL.P.10.R.A.SL062003-08</title> </head> <body bgcolor="white"> <a name="1">[1]</a> <a href="#1" id=1>Iraq has 2 months to turn over weapons of mass destruction.</a> </body> </html>
202
21.555556
101
html