Commit 62c72158 authored by Janet Barrett's avatar Janet Barrett
Browse files

(PROG) Delete local/apps/kaguyami2isis. Fixes #2033.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@5727 41f8697f-d340-4b68-9986-7bafba869bb8
parent e1d5dd19
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
ifeq ($(ISISROOT), $(BLANK))
.SILENT:
error:
	echo "Please set ISISROOT";
else
	include $(ISISROOT)/make/isismake.apps
endif
 No newline at end of file
+0 −156
Original line number Diff line number Diff line
#include "Isis.h"

#include <cstdio>
#include <string>
#include <sstream>
#include <iomanip>
#include <iostream>

#include "ProcessImportPds.h"
#include "ProgramLauncher.h"

#include "UserInterface.h"
#include "FileName.h"
#include "IString.h"

double range(double x);

using namespace std;
using namespace Isis;

void IsisMain() {
  ProcessImportPds p;
  Pvl label;
  UserInterface &ui = Application::GetUserInterface();

  FileName inFile = ui.GetFileName("FROM");
  QString id;
  Pvl lab(inFile.expanded());

  try {
    id = (QString) lab.findKeyword("DATA_SET_ID");
  }
  catch(IException &e) {
    QString msg = "Unable to read [DATA_SET_ID] from input file [" +
                  inFile.expanded() + "]";
    throw IException(e, IException::Unknown, msg, _FILEINFO_);
  }

  p.SetPdsFile(inFile.expanded(), "", label);
  Cube *outcube = p.SetOutputCube("TO");

  p.SetOrganization(Isis::ProcessImport::BSQ);

  p.StartProcess();

  // Get the directory where the Kaguya MI translation tables are.
  PvlGroup dataDir(Preference::Preferences().findGroup("DataDirectory"));
  QString transDir = (QString) dataDir["Kaguya"] + "/translations/";
  Pvl inputLabel(inFile.expanded());
  Pvl *outputLabel = outcube->label();
  FileName transFile;

  // Translate the Archive group
  transFile = transDir + "kaguyamiArchive.trn";
  PvlTranslationManager archiveXlater(inputLabel, transFile.expanded());
  archiveXlater.Auto(*(outputLabel));

  // Translate the Instrument group
  transFile = transDir + "kaguyamiInstrument.trn";
  PvlTranslationManager instrumentXlater(inputLabel, transFile.expanded());
  instrumentXlater.Auto(*(outputLabel));
    //trim trailing z's from the time strings
  PvlGroup &instGroup(outputLabel->findGroup("Instrument",Pvl::Traverse));
  QString timeString;
    //StartTime 
  PvlKeyword &startTimeKeyword=instGroup["StartTime"];
  timeString = startTimeKeyword[0];
  startTimeKeyword.setValue( timeString.mid(0,timeString.lastIndexOf("Z")) );
    //StartTimeRaw
  PvlKeyword &startTimeRawKeyword=instGroup["StartTimeRaw"];
  timeString = startTimeRawKeyword[0];
  startTimeRawKeyword.setValue( timeString.mid(0,timeString.lastIndexOf("Z")) );
    //StopTime
  PvlKeyword &stopTimeKeyword=instGroup["StopTime"];
  timeString = stopTimeKeyword[0];
  stopTimeKeyword.setValue( timeString.mid(0,timeString.lastIndexOf("Z")) );
    //StopTimeRaw
  PvlKeyword &stopTimeRawKeyword=instGroup["StopTimeRaw"];
  timeString = stopTimeRawKeyword[0];
  stopTimeRawKeyword.setValue( timeString.mid(0,timeString.lastIndexOf("Z")) );


  // Translate the BandBin group
  transFile = transDir + "kaguyamiBandBin.trn";
  PvlTranslationManager bandBinXlater(inputLabel, transFile.expanded());
  bandBinXlater.Auto(*(outputLabel));

  //Set up the Kernels group
  PvlGroup kern("Kernels");
  if      (lab.findKeyword("INSTRUMENT_ID")[0] == "MI-VIS") {
    if (lab.findKeyword("BASE_BAND")[0] == "MV1") {
      kern += PvlKeyword("NaifFrameCode", toString(-131331));
    }
    else if (lab.findKeyword("BASE_BAND")[0] == "MV2") {
      kern += PvlKeyword("NaifFrameCode", toString(-131332));
    }
    else if (lab.findKeyword("BASE_BAND")[0] == "MV3") {
      kern += PvlKeyword("NaifFrameCode", toString(-131333));
    }
    else if (lab.findKeyword("BASE_BAND")[0] == "MV4") {
      kern += PvlKeyword("NaifFrameCode", toString(-131334));
    }
    else if (lab.findKeyword("BASE_BAND")[0] == "MV5") {
      kern += PvlKeyword("NaifFrameCode", toString(-131335));
    }
    kern += PvlKeyword("NaifCkCode", toString(-131330));
  }
  else if (lab.findKeyword("INSTRUMENT_ID")[0] == "MI-NIR") {
    if (lab.findKeyword("BASE_BAND")[0] == "MN1") {
      kern += PvlKeyword("NaifFrameCode", toString(-131341));
    }
    else if (lab.findKeyword("BASE_BAND")[0] == "MN2") {
      kern += PvlKeyword("NaifFrameCode", toString(-131342));
    }
    else if (lab.findKeyword("BASE_BAND")[0] == "MN3") {
      kern += PvlKeyword("NaifFrameCode", toString(-131343));
    }
    else if (lab.findKeyword("BASE_BAND")[0] == "MN4") {
      kern += PvlKeyword("NaifFrameCode", toString(-131344));
    }
    kern += PvlKeyword("NaifCkCode", toString(-131340));
  }

  //At the time of this writing there was no expectation that Kaguya ever did any binning
  //  so this is check to make sure an error is thrown if an image was binned
  if (lab.findKeyword("INSTRUMENT_ID")[0] == "MI-VIS" && outcube->sampleCount() != 962 ) {
    QString msg = "Input file [" + inFile.expanded() + "]" + " appears to be binned.  Binning was "
                  "unexpected, and is unsupported by the camera model";
    throw IException(IException::Unknown, msg, _FILEINFO_);
  }
  if (lab.findKeyword("INSTRUMENT_ID")[0] == "MI-NIR" && outcube->sampleCount() != 320 ) {
    QString msg = "Input file [" + inFile.expanded() + "]" + " appears to be binned.  Binning was "
                  "unexpected, and is unsupported by the camera model";
    throw IException(IException::Unknown, msg, _FILEINFO_);
  }

  outcube->putGroup(kern);

  p.EndProcess();
}

double range(double x) {
  double a,b,c;
  b = x / 360;
  if(b > 0) {
    c = floor(b);
  }
  else {
    c = ceil(b);
  }
  a = 360 * (b - c);
  if(a < 0) {
    a = a + 360;
  }
  return a;
}
+0 −75
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>

<application name="kaguyami2isis" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://isis.astrogeology.usgs.gov/Schemas/Application/application.xsd">

  <brief>Import PDS formatted Kaguya MI image cube into Isis format cube</brief>

  <description>
    This program will import a PDS formatted Kaguya MI VIS and NIR level 1 (EDR) 
    image into an Isis cube.
  </description>

  <history>
    <change name="Janet Barrett" date="2011-05-09">
      Original version
    </change>
    <change name="Janet Barrett" date="2012-05-02">
      At this time, there is no camera model for the Kaguya MI data. In order to
      be able to perform photometry on the Kaguya MI data, the SubSolarLongitude
      and SubSolarLatitude information needed to be calculated. These calculations 
      are done by using the aaplus library developed by P J Naughter at 
      http://www.naughter.com. This library can only be distributed in binary form,
      so it has to stay in the local directory of ISIS where it will not be 
      distributed. The formulae used to do the calculations were taken from Meeus 
      "Astronomical Algorithms" (1st Ed). This code can be removed as soon as a camera 
      model is available for the Kaguya MI camera. The start and stop times for these 
      images are very close, so the start time is used to calculate the SubSolar lat/lon
      information.
    </change>
    <change name="Lynn Weller" date="2012-01-23">
      Application category name changed from Import and Export to Kaguya.  Fixes mantis ticket #951.
    </change>
    <change name="Janet Barrett" date="2013-06-13">
      Fixed code so that it sets the NaifFrameCode appropriately according to the base band specified
      in the labels.  Fixes mantis tickets #1167 and #1680.
    </change>
  </history>

  <category>
    <missionItem>Kaguya</missionItem>
  </category>

  <groups>
    <group name="Files">
      <parameter name="FROM">
        <type>filename</type>
        <fileMode>input</fileMode>
        <brief>
          Input PDS formatted Kaguya MI VIS or NIR file
        </brief>
        <description>
          Use this parameter to select the Kaguya MI VIS or
	  NIR EDR filename. This file must contain the PDS 
          labels.
        </description>
        <filter>
          *.img *.IMG
        </filter>
      </parameter>

      <parameter name="TO">
         <type>cube</type>
         <fileMode>output</fileMode>
         <brief>
           Output Isis cube
         </brief>
         <description>
           Use this parameter to select the output filename
         </description>
         <filter>
           *.cub
         </filter>
      </parameter>
    </group>
  </groups>
</application>
+0 −33
Original line number Diff line number Diff line
#if _MSC_VER > 1000
#pragma once
#endif

#ifndef STRICT
#define STRICT
#endif

#ifndef WINVER
#define WINVER 0x0400
#endif

#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif

#ifndef _WIN32_WINDOWS
#define _WIN32_WINDOWS 0x0400
#endif

#ifndef _WIN32_IE
#define _WIN32_IE 0x0400
#endif

#define VC_EXTRALEAN  // Exclude rarely-used stuff from Windows headers

#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS  // some CString constructors will be explicit

#define _AFX_ALL_WARNINGS // turns off MFC's hiding of some common and often safely ignored warning messages

#ifndef _SECURE_ATL
#define _SECURE_ATL 1 //Use the Secure C Runtime in ATL
#endif
+0 −4
Original line number Diff line number Diff line
BLANKS = "%-6s"    
LENGTH = "%-40s"

include $(ISISROOT)/make/isismake.tststree
Loading