Commit e988d0e6 authored by Robert Butora's avatar Robert Butora
Browse files

cutout: improves debug-print in overlap

parent a2d27e13
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -68,14 +68,14 @@ struct coordinates
{
   coordinates();

   skysystem skysys;               // mandatory: "GALACTIC"|"ICRS"
   double lon_deg, lat_deg;        // mandatory
   area  shape;                    // mandatory: CIRCLE dlon=dlat=2xRadius, RECT dlon may differ from dlat
   double dlon_deg, dlat_deg;      // mandatory
   std::vector<double> p_lon_deg;  // mandatory polygon arrry
   std::vector<double> p_lat_deg;  // mandatory polygon array

   specsystem specsys;             // mandatory NONE VELO-LSRK WAVE-Bary
   skysystem skysys;               // mandatory: NONE GALACTIC ICRS
   double lon_deg, lat_deg;        // optional, check skysys == NONE
   area  shape;                    // optional: CIRCLE dlon=dlat=2xRadius, RECT dlon may differ dlat
   double dlon_deg, dlat_deg;      // optional
   std::vector<double> p_lon_deg;  // optional polygon arrry
   std::vector<double> p_lat_deg;  // optional polygon array

   specsystem specsys;             // mandatory NONE VELO_LSRK WAVE_Barycentric
   double vl_kmps, vu_kmps;        // optional, check specsystem == NONE

   timesystem timesys;
+140 −135
Original line number Diff line number Diff line
@@ -791,12 +791,17 @@ overlap_ranges ast::frameset::overlap_in_wcs(coordinates coord)
   return overlap_ranges{ov_code, pix_ranges };
}
#else
void log_bounds(string prefix, int length, double low[], double up[])
void ast::frameset::log_bounds(string prefix, int length, double low[], double up[])
{
	int ix;
   LOG_STREAM << prefix << endl;
   for(ix=0; ix<length; ix++) LOG_STREAM << prefix << low[ix] << " " << up[ix] 
      << " deg: " << R2D*low[ix] << " " << R2D*up[ix] << endl;
   double factor;
   bool is_wcs = (prefix.find("WCS") != std::string::npos);
	for(ix=0; ix<length; ix++)
   {
      factor = (is_wcs && (ix == (m_sky_lon_axis-1) || ix == (m_sky_lat_axis-1))) ? R2D : 1.0;
		LOG_STREAM << prefix << factor*low[ix] << " " << factor*up[ix] << endl;
	}
	//   << " deg: " << R2D*low[ix] << " " << R2D*up[ix] << endl;
}


@@ -941,7 +946,7 @@ overlap_ranges ast::frameset::overlap(coordinates coord)
	astGetRegionBounds(pixbox, xlbnd, xubnd);
	if ( !astOK )
		throw runtime_error(failed_with_status(__FILE__,__LINE__,"astGetRegionBounds( pixbox )"));
   log_bounds("XX BOUNDS header_pix: ", naxes, xlbnd, xubnd);
	log_bounds("BOUNDS header PIX: ", naxes, xlbnd, xubnd);
	/* DEBUG only */


@@ -961,7 +966,7 @@ overlap_ranges ast::frameset::overlap(coordinates coord)
	if ( !astOK )
		throw runtime_error(failed_with_status(__FILE__,__LINE__,"astGetRegionBounds"));

   log_bounds("XX BOUNDS header: ", naxes, low, up);
	log_bounds("BOUNDS header WCS: ", naxes, low, up);


	/* overwrite bounds for sky- spec- time- pol-axis if given by coord */
@@ -1008,8 +1013,8 @@ overlap_ranges ast::frameset::overlap(coordinates coord)
			/* set values only to get correct debug print for client */
			low[m_spec_axis-1] = coord.vl_kmps;
			up [m_spec_axis-1] = coord.vu_kmps;
			log_bounds("XX BOUNDS client: ", naxes, low, up);
			LOG_STREAM << "XX BOUNDS no overlap in spectrum axis, returning ov_code=1" << endl;
			log_bounds("BOUNDS client WCS: ", naxes, low, up);
			LOG_STREAM << "BOUNDS no overlap in spectrum axis, returning ov_code=1" << endl;
			return overlap_ranges{1, pix_ranges };
		}
		else // at least partial overlap -> cut coord to min/max of header values
@@ -1034,7 +1039,7 @@ overlap_ranges ast::frameset::overlap(coordinates coord)
		up [m_stokes_axis-1] = max_pol_state(coord.pol);
	}

	log_bounds("XX BOUNDS client: ", naxes, low, up);
	log_bounds("BOUNDS client WCS: ", naxes, low, up);

	/* FIXME ignored coord.shape; add circle later : metters for ovelap-code (but not for cut, which is always rect) */
	AstRegion * crgn = (AstRegion *)astBox( wcsbox, 1, low, up , (AstRegion*)AST__NULL," ");
@@ -1053,7 +1058,7 @@ overlap_ranges ast::frameset::overlap(coordinates coord)
	if ( !astOK )
		throw runtime_error(failed_with_status(__FILE__,__LINE__,"astGetRegionBounds"));

	log_bounds("XX BOUNDS client_pix: ", naxes, cllow, clup);
	log_bounds("BOUNDS client PIX: ", naxes, cllow, clup);
	/* DBG only */


@@ -1083,7 +1088,7 @@ overlap_ranges ast::frameset::overlap(coordinates coord)
		if ( !astOK )
			throw runtime_error(failed_with_status(__FILE__,__LINE__,"astGetRegionBounds( pixOverlap )"));

		log_bounds("XX BOUNDS overlap_pix: ", m_NAXIS, lbnd, ubnd);
		log_bounds("BOUNDS overlap PIX: ", m_NAXIS, lbnd, ubnd);

		int ix;
		for(ix=0; ix<m_NAXIS; ix++)
+1 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ class frameset
      std::ostream& serialize(std::ostream& strm) const;

   private:
      void log_bounds(std::string prefix, int length, double low[], double up[]);
      void log_warnings(const AstFitsChan * fchan);

      AstRegion * create_header_region(void);
+6 −6
Original line number Diff line number Diff line
@@ -110,15 +110,15 @@ std::ostream& operator<<( std::ostream &out, struct coordinates const& p)
   bool is_poly = (p.shape == area::POLYGON);


   out << to_string(p.skysys) << " : (" << p.lon_deg << ", " << p.lat_deg << ") "
   out << "POS["<< to_string(p.skysys) << "; (" << p.lon_deg << ", " << p.lat_deg << ") "
      << to_string(p.shape) <<  ": ("
      << (is_poly ? poly_lon_str : to_string(p.dlon_deg)) << ", "
      << (is_poly ? poly_lat_str : to_string(p.dlat_deg)) << ") "
      << to_string(p.specsys) << " [km/s] : (" << p.vl_kmps << ", " << p.vu_kmps << ") "
      << (is_poly ? poly_lat_str : to_string(p.dlat_deg)) << ")] "
      << "BAND[" <<to_string(p.specsys) << "; (" << p.vl_kmps << ", " << p.vu_kmps << ")] "
//      << "POS(" << p.pos << ") "
//      << "BAND(" << to_string(p.bandsys) << "; " << p.band_value[0]  << ", " << p.band_value[1] << ") "
      << "TIME(" << to_string(p.timesys) << "; " << p.time_value[0]  << ", " << p.time_value[1] << ") "
      << "POL(" << pol_str << ")";
      << "TIME[" << to_string(p.timesys) << "; " << p.time_value[0]  << ", " << p.time_value[1] << "] "
      << "POL[" << pol_str << "]";
   return out;
}