Commit 2c337216 authored by Tyler Wilson's avatar Tyler Wilson Committed by Adam Paquette
Browse files

Merge of dev into hayabusa2_fy19 (#692)

* Added AlphaCube group to outputlabel in the event the image is cropped.

* Fix libtiff dependency (#636) (#644)

* Upgrade libtiff to 4.0.10 (#636)

* Switch libtiff to 4.0.9 or higher to remove geotiff conflict

* Moved ISIS3 conda-build recipe from ISIS3_deps repository (#650)

* Fixed warning in Pixel unit tests

* Made a tweak to the dimensions of the alpha cube for cropped images to give it the correct dimensions.

* Changed the transform function so it could process an array of doubles instead of an array of ints.

* Smear correction was being incorrectly applied to onboard smear corrected images and screwing things up.  Fixed it.

* Added gtest capability to hyb2onc2isis

* Removing build numbers from external libraries (#660)

* Moved ISIS3 conda-build recipe from ISIS3_deps repository

* Un-pinned non-astro build numbers

* Removing build numbers from external libraries in the environment and meta.yeml files

* Final merging

* Added pixel type attribute to the output image of program shadow. Fixes #5187 (#659)

* Removed bolding of some text to decrease distraction.

* Fixed some typos.

* Reworded documentation.

* Added section for Environment and PreferemcesSetup in the Getting Started Section. (#663)

* Updated .gitmodules to use https rather than ssh (#673)

* Added build type release to conda recipe (#676)

* Modified isis/tests/CMakeLists.txt as well as hyb2onc2isis to fix unresolved symbol errors (CMakeLists.txt) and to fix some bugs in hyb2onc2isis involved with turning it into a callable function.

* Added w1 test to hyb2onc2isisTests.cpp

* Modified hyb2onccal to be a callable function.

* Updates README with Discourse (#690)

* Updates README with Discourse

* Update README.md

* Update README.md

* Changed the Pvl label output for Pvl hyb2onc2isis(QString fitsFileName, QString outputCubeFileName, CubeAttributeOutput att, QString target)

* Added Newton-Rapheson method to Hyb2OncCalUtils.h to solve the linearity equation.
parent 32c72646
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -259,15 +259,10 @@ Pvl hyb2onc2isis(QString fitsFileName, QString outputCubeFileName, CubeAttribute
  importFits.StartProcess();
  importFits.Finalize();


  return outputLabel;
  return finalLabel;
  

  }





}
+46 −20
Original line number Diff line number Diff line
@@ -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<Buffer *>& in, vector<Buffer *>& 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<Buffer *>& in, vector<Buffer *>& 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