Commit 945d219c authored by Robert Butora's avatar Robert Butora
Browse files

adds WAVELEN keys for continuum band

parent e9e6a485
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -26,7 +26,10 @@ namespace ObsCoreKeys
      = {
         "CDELT1",
         "CDELT2",
         "CDELT3"
         "CDELT3",
         "WAVELEN",
         "WAVELENG",
         "WAVELNTH",
      };

   inline std::set<std::string> add_str_keys(const std::set<std::string> strSet1, std::set<std::string> strSet2)
+60 −28
Original line number Diff line number Diff line
@@ -147,6 +147,32 @@ string asSqlString(fitsfiles::key_values_by_type key_values, string key)
   }
}

string get_wavelen(fitsfiles::key_values_by_type key_values)
{
   const double UNIT_CONVERT = 0.001; // FIXME header-card unit [mm] but ObsCore em_ is [m]
   if(key_values.doubleValues.find("WAVELEN") == key_values.doubleValues.end() )
   {
      if(key_values.doubleValues.find("WAVELENG") == key_values.doubleValues.end() )
      {
         if(key_values.doubleValues.find("WAVELNTH") == key_values.doubleValues.end() )
         {
            return "NULL";
         }
         else
         {
            return to_string(UNIT_CONVERT * key_values.doubleValues["WAVELNTH"]);
         }
      }
      else
      {
         return to_string(UNIT_CONVERT * key_values.doubleValues["WAVELENG"]);
      }
   }
   else
   {
      return to_string(UNIT_CONVERT * key_values.doubleValues["WAVELEN"]);
   }
}



@@ -323,18 +349,24 @@ void SqlSchema_INSERT::appendRow(/*const int hid, const int sid,*/

   if(icrsBounds.size() >= 3) // 3D cubes
   {
      obscoreRow[em_min]        = to_string(galBounds[2].low);
      obscoreRow[em_max]        = to_string(galBounds[2].up);
      //obscoreRow[em_min]        = to_string(galBounds[2].low);
      //obscoreRow[em_max]        = to_string(galBounds[2].up);
      obscoreRow[em_min]        = to_string(icrsBounds[2].low); // FIXME must be Wave-length in [m]
      obscoreRow[em_max]        = to_string(icrsBounds[2].up);  // FIXME must be Wave-length in [m]

      obscoreRow[em_res_power]  = asSqlString(hdu.key_values, "CDELT3");
      obscoreRow[em_xel]        = asSqlString(hdu.key_values, "NAXIS3");
   }
#if 0
   else if(icrsBounds.naxis == 2) // 2D images
   else if(icrsBounds.size() == 2) // 2D images
   {
      if(!strcmp(survey.survSpecies.c_str(), "Continuum"))
         dem_min = dem_max = 0.0; // FIXME transtod(psurv->transition);
      //if(!strcmp(survey.survSpecies.c_str(), "Continuum"))
      //   dem_min = dem_max = 0.0; // FIXME transtod(psurv->transition);

      obscoreRow[em_min] = get_wavelen(hdu.key_values);
      obscoreRow[em_max] = obscoreRow[em_min];
      obscoreRow[em_res_power] = "NULL";
      obscoreRow[em_xel]       = "NULL";
   }
#endif
   else
   {
      obscoreRow[em_min]       = "NULL";