Commit f4656b5c authored by Stuart Sides's avatar Stuart Sides
Browse files

Merge of New Horizons into trunk Ref #1963, 1898, 2229

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@6089 41f8697f-d340-4b68-9986-7bafba869bb8
parents 8b50dd8a 049791bd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ void IsisMain() {
  ProcessImportFits pfits;

  pfits.setFitsFile(FileName(ui.GetFileName("FROM")));
  pfits.setProcessFileStructure(0);
  pfits.setProcessFileStructure(ui.GetInteger("IMAGENUMBER"));

  Cube *output = pfits.SetOutputCube("TO");

+23 −5
Original line number Diff line number Diff line
@@ -6,17 +6,20 @@
    Import fits files into Isis format
  </brief>
  <description>
    This program will import fits (Flexible Image Transport System) files into 
    Isis format. Only simple fits files are accepted. Extensions are not 
    support and files with no initial data, NAXIS = 0 , implying extensions with 
    data, are not supported either. Some common header data is transfered to 
    Isis labels. Primary image data is transfered completely and reliably.
    This program will import fits (Flexible Image Transport System) image files into 
    ISIS format. FITS files with extensions are supported upto and including the first  non-image
    extension. Images follwing the first  non-image extension can not be accessed
    (i.e., NAXIS = 0 , implying extensions with data, are not supported). Some common header data
     is transfered to the ISIS labels. Primary image data is transfered completely.
  </description>
  
  <history>
    <change name="Mackenzie Boyd" date="2009-10-27">
      Original version
    </change> 
    <change name="Stuart Sides" date="2014-08-29">
      Added the ability to read image extensions.
    </change> 
  </history>

  <seeAlso>
@@ -61,6 +64,21 @@
        </filter>
      </parameter>
    </group>

    <group name="Controls">
      <parameter name="IMAGENUMBER">
        <type>integer</type>
        <default><item>0</item></default>
        <brief>
          A fits file to be converted to an ISIS cube
        </brief>
        <description>
          Use this parameter to select which image to extract from the FITS file. The primary image
          is 0, the first  image extension is 1, the second image extension is 2, and so on. NOTE: 
          Image extensions following any non-image extension can not be accessed.
        </description>
      </parameter>
    </group>
  </groups>

  <examples>
+52 −8
Original line number Diff line number Diff line
@@ -30,8 +30,16 @@ Angle latInc, lonInc;
double lineValue;
bool image;
double bkgndValue;
void changeBand(int band);
Cube *icube; 
UniversalGroundMap *gmap; 
int currentBand = 0;
bool recalculateForEachBand = false; 
bool walkBoundary = false; 
Latitude minLat, maxLat;
Longitude minLon, maxLon;

int inputSamples, inputLines;
int inputSamples, inputLines, inputBands;
GroundGrid *latLonGrid;

void IsisMain() {
@@ -39,7 +47,7 @@ void IsisMain() {

  // We will be processing by line
  ProcessByLine p;
  Cube *icube = p.SetInputCube("FROM");
  icube = p.SetInputCube("FROM");

  UserInterface &ui = Application::GetUserInterface();
  QString mode = ui.GetString("MODE");
@@ -95,6 +103,7 @@ void IsisMain() {

  inputSamples = icube->sampleCount();
  inputLines   = icube->lineCount();
  inputBands = icube->bandCount();

  // Line & sample based grid
  if (mode == "IMAGE") {
@@ -110,8 +119,14 @@ void IsisMain() {
  else {
    p.SetOutputCube("TO");

    UniversalGroundMap *gmap = new UniversalGroundMap(*icube,
        UniversalGroundMap::ProjectionFirst);
    //if > 1 input band and IsBandIndependent = false, need to regenerate grid for 
    // each band
    if ( (inputBands >= 2) && !(icube->camera()->IsBandIndependent()) ) {
      recalculateForEachBand = true; 
    }

    gmap = new UniversalGroundMap(*icube, UniversalGroundMap::ProjectionFirst);

    latLonGrid = new GroundGrid(gmap, ticks, icube->sampleCount(), icube->lineCount());

    baseLat = Latitude(ui.GetDouble("BASELAT"),
@@ -124,8 +139,6 @@ void IsisMain() {
    Progress progress;
    progress.SetText("Calculating Grid");

    Latitude minLat, maxLat;

    if (ui.WasEntered("MINLAT"))
      minLat = Latitude(ui.GetDouble("MINLAT"),
        *latLonGrid->GetMappingGroup(), Angle::Degrees);
@@ -134,8 +147,6 @@ void IsisMain() {
      maxLat = Latitude(ui.GetDouble("MAXLAT"),
        *latLonGrid->GetMappingGroup(), Angle::Degrees);

    Longitude minLon, maxLon;

    if (ui.WasEntered("MINLON"))
      minLon = Longitude(ui.GetDouble("MINLON"),
        *latLonGrid->GetMappingGroup(), Angle::Degrees);
@@ -150,6 +161,7 @@ void IsisMain() {

    if (ui.GetBoolean("BOUNDARY"))
      latLonGrid->WalkBoundary();
      walkBoundary = true;

    p.StartProcess(groundGrid);
    p.EndProcess();
@@ -288,8 +300,40 @@ bool groundDrawPoint(int samp, int line, bool latGrid = true) {
  return drawPoint;
}

//If camera is band-dependent, need to re-calculate the grid when changing bands

void changeBand(int band){ 
  Progress progress;

  // change band of UniversalGroundMap
  gmap->SetBand(band);

  //update latLonGrid to use new UniversalGroundMap
  latLonGrid = new GroundGrid(gmap, ticks, icube->sampleCount(), icube->lineCount());

  //re-set old ground limits from GUI
  latLonGrid->SetGroundLimits(minLat, minLon, maxLat, maxLon);

  QString progressMessage = QString("Recalculating grid for band %1").arg(band);
  progress.SetText(progressMessage);

  //re-set lat/lon base/in from GUI
  latLonGrid->CreateGrid(baseLat, baseLon, latInc, lonInc, &progress);

  if (walkBoundary)
    latLonGrid->WalkBoundary();

}

// Line processing routine
void groundGrid(Buffer &in, Buffer &out) {

  //check to see if we're in the same band: 
  if ( (currentBand != in.Band()) && recalculateForEachBand ) {
    currentBand = in.Band(); 
    changeBand(currentBand); 
  }

  for (int samp = 1; samp <= in.SampleDimension(); samp++) {
    if (!ticks) {
      if (groundDrawPoint(samp, in.Line())) {
+10 −2
Original line number Diff line number Diff line
@@ -40,10 +40,13 @@
    <def link="Level2">level2</def> <def link="Cube">cubes</def>, or mosaics.  
    The mapping information in the labels will be used to draw grid lines on mosaics 
    and Level2 images.  If the
    latitude and longitde information cannot be calculated or extracted using the image 
    latitude and longitude information cannot be calculated or extracted using the image 
    label contents, then use the IMAGE mode.<br/><br/>
    
    <b>Example Parameter Settings for Grids:</b><br/> <br/>
     For Cubes with an associated band-dependent camera model (latitude, longitude coordinates do not correspond to the same sample, line coordinates 
     in each band,) the grid is recalculated for each band.<br/><br/>    
						     
    <b>Example Parameter Settings for Grids:</b><br/> 
    Example 1: Superimpose a basic latitude/longitude graticule with grid lines drawn
    every 10 degrees based on zero: <br/> 
    MODE=GROUND BASELAT=0 BASELON=0 LATINC=10 LONINC=10<br/><br/>
@@ -158,6 +161,11 @@
      Modified so that the output cube characteristics are obtained from the input cube
      and/or cube characteristics specified on the command line. Fixes #2063.
    </change>
    <change name="Kristin Berry" date="2014-11-25">
      Modified to work on Cubes with associated band-dependent camera models. Now 
      when MODE="GROUND" on a Cube with a band-dependent camera model, the grid will 
      be re-calculated for each band. Fixes #2191.
    </change>
  </history>

  <groups>
+8 −0
Original line number Diff line number Diff line
APPNAME = grid

include $(ISISROOT)/make/isismake.tsts

commands:
	$(APPNAME) from=$(INPUT)/leisaCrop.cub+20,1,38,194 \
	to=$(OUTPUT)/leisaCropTruth.cub > /dev/null;
Loading