diff --git a/README.md b/README.md index b40b5a3ad1..6dc9ae18e1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # ISIS3 [![Join the chat at https://gitter.im/USGS-Astrogeology/isis3_cmake](https://badges.gitter.im/USGS-Astrogeology/isis3_cmake.svg)](https://gitter.im/USGS-Astrogeology/isis3_cmake?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Join the discourse at https://astrodiscuss.usgs.gov](https://img.shields.io/discourse/https/astrodiscuss.usgs.gov/topics.svg?style=flat)](https://astrodiscuss.usgs.gov/) ## Table of Contents diff --git a/isis/src/hayabusa2/apps/hyb2onc2isis/hyb2onc2isis.cpp b/isis/src/hayabusa2/apps/hyb2onc2isis/hyb2onc2isis.cpp index 6f38ae616a..987e6ae55d 100644 --- a/isis/src/hayabusa2/apps/hyb2onc2isis/hyb2onc2isis.cpp +++ b/isis/src/hayabusa2/apps/hyb2onc2isis/hyb2onc2isis.cpp @@ -259,15 +259,10 @@ Pvl hyb2onc2isis(QString fitsFileName, QString outputCubeFileName, CubeAttribute importFits.StartProcess(); importFits.Finalize(); - - return outputLabel; - + return finalLabel; + } - - - - } diff --git a/isis/src/hayabusa2/apps/hyb2onccal/Hyb2OncCalUtils.h b/isis/src/hayabusa2/apps/hyb2onccal/Hyb2OncCalUtils.h index e2ef7e6a7a..967cf07920 100644 --- a/isis/src/hayabusa2/apps/hyb2onccal/Hyb2OncCalUtils.h +++ b/isis/src/hayabusa2/apps/hyb2onccal/Hyb2OncCalUtils.h @@ -103,9 +103,8 @@ static double g_d1(0); static double g_darkCurrent(0); //Linearity correction variables -static double g_L0(0); -static double g_L1(0); -static double g_L2(0); + +static double g_L[3] = {0.0,0.0,0.0}; // TODO: we do not have the readout time (transfer period) for Hayabusa2 ONC. //Smear calculation variables @@ -151,6 +150,40 @@ static AlphaCube *alpha(0); static Pvl g_configFile; +double linearFun(double Iobs,double x, double g[3]) { + return Iobs - g[0]*x -g[1]*pow(x,2.0) -g[2]*pow(x,3.0); + +} + +double dFun(double x, double g[3]) { + return -g[0] - 2*g[1]*x -3*g[2]*pow(x,2.0); + +} + + +bool newton_rapheson(double Iobs,double x0, double g[3],double &result, double epsilon=1e-6 ) { + + double x[2]; + double dx = 1.0; + int iter = 0; + int maxIterations=500; + x[0] = x0; + while (dx > epsilon) { + + x[1]=x[0] - linearFun(Iobs,x[0],g)/dFun(x[0],g); + dx = fabs(x[1]-x[0]) ; + x[0]=x[1]; + iter++; + if (iter > maxIterations) { + + return false; + } + } + result = x[1]; + return true; +} + + /** * @brief Apply radiometric correction to each line of an AMICA image. @@ -212,13 +245,14 @@ void Calibrate(vector& in, vector& out) { } } - -#if 0 + double dn = imageOut[i]; double linearCorrection; - linearCorrection = g_L0+g_L1*pow(imageOut[i],2.0)+g_L2*pow(imageOut[i],3.0); - imageOut[i]*=linearCorrection; + double result = 1.0; + double x0 = 1.0; + newton_rapheson(imageOut[i],x0, g_L,result ); + imageOut[i] = result; -#endif + //qDebug() << dn << ","<< result; // DARK Current @@ -247,13 +281,6 @@ void Calibrate(vector& in, vector& out) { //In the SIS this adjustment is made just after the bias, but //in the Calibration paper it happens just before the flat field correction. -#if 0 - double linearCorrection; - linearCorrection = g_L0+g_L1*pow(imageOut[i],2.0)+g_L2*pow(imageOut[i],3.0); - qDebug() << "linearCorrection=" << linearCorrection; - imageOut[i]*=linearCorrection; - #endif - // FLATFIELD correction // Check for any special pixels in the flat field (unlikely) @@ -594,9 +621,10 @@ QString loadCalibrationVariables(const QString &config) { g_solarFlux = solar[g_filter.toLower()]; //Load the linearity variables - g_L0 = linearity["L"][0].toDouble(); - g_L1 = linearity["L"][1].toDouble(); - g_L2 = linearity["L"][2].toDouble(); + g_L[0] = linearity["L"][0].toDouble(); + g_L[1] = linearity["L"][1].toDouble(); + g_L[2] = linearity["L"][2].toDouble(); + // radiance = g_v_standard * g_iofScale @@ -608,8 +636,6 @@ QString loadCalibrationVariables(const QString &config) { - - } #endif