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

cutout/soda: implements PIXEL_i param to cut by pixels on non WCS-standard axis

parent 2036cd7c
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -21,13 +21,6 @@ struct Bounds
   int naxis;
};

struct uint_bounds
{
   unsigned int pix1;
   unsigned int pix2;
   unsigned char type;
};

struct double_xy
{
   double x;
+11 −1
Original line number Diff line number Diff line
@@ -12,6 +12,14 @@ enum class specsystem {NONE, VELO_LSRK, WAVE_Barycentric};
enum class timesystem {NONE, MJD_UTC};


struct uint_bounds
{
   unsigned int pix1;
   unsigned int pix2;
   unsigned char type;
};


/* SODA */

struct circle
@@ -82,11 +90,13 @@ struct coordinates
   double time_value[2];           // time interval (MJD in UTC)

   std::vector<std::string> pol;   // polarization states FIXME pol should be Set<enums>

   std::vector<uint_bounds> pixel_i;   // PIXEL_i for non-standard axes allow direct cut without WCS
};

 coordinates parse_coordinates(const std::string region_string);
 coordinates to_coordinates(const position pos, const band bnd, const time_axis time,
       const std::vector<std::string> pol);
       const std::vector<std::string> pol, const std::vector<uint_bounds> pixel_i);

/* cutout */

+2 −0
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@ void to_json(json& j, const cutout_res_s& p);
void to_json(json& j, const fits_card& p);
void from_json(const json& j, fits_card& p);

void from_json(const json& j, uint_bounds& p);

void to_json(json& j, const coordinates& p);
void from_json(const json& j, coordinates& p);

+8 −3
Original line number Diff line number Diff line
@@ -177,6 +177,7 @@ string axistype2string(unsigned char cc)
      case 'b': return "BAND"; break;
      case 't': return "TIME"; break;
      case 'p': return "POL"; break;
      case 'x': return "PIXEL_i"; break;
      case ' ': return "UNKNOWN"; break;
      default:
         throw invalid_argument(cc + " is not a valid axis type");
@@ -207,7 +208,7 @@ coordinates parse_coordinates(const string region_string)
   LOG_trace(string(__func__) + " : " + region_string);

   json_region reg(region_string);
   coordinates coord = to_coordinates(reg.get_pos(), reg.get_band(), reg.get_time(), reg.get_pol());
   coordinates coord = to_coordinates(reg.get_pos(), reg.get_band(), reg.get_time(), reg.get_pol(), reg.get_pixel_i());

   LOG_STREAM << "coord parsed: " << coord << endl;

@@ -215,7 +216,8 @@ coordinates parse_coordinates(const string region_string)
}


coordinates to_coordinates(const position pos, const band bnd, const time_axis time, const std::vector<std::string> pol)
coordinates to_coordinates(const position pos, const band bnd, const time_axis time,
				const std::vector<std::string> pol, const std::vector<uint_bounds> pixel_i)
{
   coordinates coord;
   coord.skysys = pos.sys;
@@ -274,6 +276,8 @@ coordinates to_coordinates(const position pos, const band bnd, const time_axis t

   coord.pol = pol;

   coord.pixel_i = pixel_i;

   return coord;
}

@@ -336,7 +340,8 @@ cutout_res_s do_cutout_file(
   const string abs_subimg_pathname = conf_fits_cutpath + "/" + generate_cut_fitsname(fits_pathname, hdunum);
   const string abs_fits_pathname{ conf_fits_path + "/" + fits_pathname };

   coordinates coord = to_coordinates(pos, bnd, time, pol);
   vector<uint_bounds> pixel_i_none;
   coordinates coord = to_coordinates(pos, bnd, time, pol, pixel_i_none);

   uintmax_t filesize = cutout_file(abs_fits_pathname, hdunum, coord, abs_subimg_pathname, extra_cards);

+7 −0
Original line number Diff line number Diff line
@@ -119,6 +119,13 @@ void from_json(const json& j, fits_card& p)
}


void from_json(const json& j, uint_bounds& p)
{
   if(j.contains("pix1")) j.at("pix1").get_to(p.pix1); else p.pix1 = 0;
   if(j.contains("pix2")) j.at("pix2").get_to(p.pix2); else p.pix2 = 0;
   if(j.contains("type")) j.at("type").get_to(p.type); else p.type = ' ';
}



// cutout
Loading