Skip to content
Snippets Groups Projects
Commit 86c16695 authored by Robert Butora's avatar Robert Butora
Browse files

vlkb-obscore: implements s_region_galactic and vel_min vel_max to obscore

parent 27d2d416
No related branches found
No related tags found
No related merge requests found
......@@ -94,6 +94,7 @@ void SqlSchema::reset(void)
{s_dec, "s_dec double precision"},
{s_fov, "s_fov double precision"},
{s_region, "s_region VARCHAR"},
{s_region_galactic,"s_region_galactic VARCHAR"},
{s_xel1, "s_xel1 bigint"},
{s_xel2, "s_xel2 bigint"},
{s_resolution, "s_resolution double precision"},
......@@ -104,6 +105,8 @@ void SqlSchema::reset(void)
{t_xel, "t_xel bigint"},
{em_min, "em_min double precision"},
{em_max, "em_max double precision"},
{vel_min, "vel_min double precision"},
{vel_max, "vel_max double precision"},
{em_res_power, "em_res_power double precision"},
{em_xel, "em_xel bigint"},
{o_ucd, "o_ucd VARCHAR"},
......
......@@ -36,9 +36,9 @@ class SqlSchema
enum obscoreColId {dataproduct_type, calib_level,
obs_collection, obs_id, obs_publisher_id,
access_url, access_format, access_estsize, target_name,
s_ra, s_dec, s_fov, s_region, s_xel1, s_xel2, s_resolution,
s_ra, s_dec, s_fov, s_region, s_region_galactic, s_xel1, s_xel2, s_resolution,
t_min, t_max, t_exptime, t_resolution, t_xel,
em_min, em_max, em_res_power, em_xel,
em_min, em_max, vel_min, vel_max, em_res_power, em_xel,
o_ucd,
pol_states, pol_xel,
facility_name, instrument_name,
......
......@@ -117,12 +117,12 @@ string region_spoly(vector<point2d> vert)
return spoly;
}
string region_stcs(vector<point2d> vert)
string region_stcs(string coord_sys, vector<point2d> vert)
{
my_assert((vert.size()==4), __FILE__,__LINE__, "expected 4 vertices, but found " + to_string(vert.size()) );
string stcs =
"Polygon ICRS "
"Polygon " + coord_sys + " "
+ to_string(vert[0].lon) + " " + to_string(vert[0].lat) + " "
+ to_string(vert[1].lon) + " " + to_string(vert[1].lat) + " "
+ to_string(vert[2].lon) + " " + to_string(vert[2].lat) + " "
......@@ -272,8 +272,8 @@ void SqlSchema_INSERT::appendRow(
// sky & spectrum
//const string VELOLSRK{"System=VELO,StdOfRest=LSRK,Unit=km/s"};
//vector<struct Bounds> galBounds = calc_bounds(hdu.m_header, "GALACTIC", VELOLSRK);
const string VELOLSRK{"System=VELO,StdOfRest=LSRK,Unit=km/s"};
vector<struct Bounds> galBounds = calc_bounds(hdu.m_header, "GALACTIC", VELOLSRK);
const string WAVELSRK{"System=WAVE,StdOfRest=LSRK,Unit=m"};
vector<struct Bounds> icrsBounds = calc_bounds(hdu.m_header, "ICRS", WAVELSRK);
double ds_ra = (icrsBounds[0].low + icrsBounds[0].up)/2.0;
......@@ -290,18 +290,17 @@ void SqlSchema_INSERT::appendRow(
vector<point2d> icrsVerts = calc_skyvertices(hdu.m_header, "ICRS");
reorder_vertices(icrsVerts);
obscoreRow[s_region] = to_sqlstring(region_stcs(icrsVerts));
obscoreRow[s_region] = to_sqlstring(region_stcs("ICRS", icrsVerts));
const int EM_PRECISION{10}; // nanometers
if(icrsBounds.size() >= 3) // 3D cubes
{
//obscoreRow[em_min] = to_string(EM_PRECISION, galBounds[2].low);
//obscoreRow[em_max] = to_string(EM_PRECISION, galBounds[2].up);
obscoreRow[em_min] = to_string(EM_PRECISION, icrsBounds[2].low);
obscoreRow[em_max] = to_string(EM_PRECISION, icrsBounds[2].up);
obscoreRow[em_res_power] = "NULL";//to_sql_value(hdu.key_values, "CDELT3");
obscoreRow[em_xel] = to_sql_value(hdu.key_values, "NAXIS3");
obscoreRow[vel_min] = to_string(EM_PRECISION, galBounds[2].low);// VLKB extension
obscoreRow[vel_max] = to_string(EM_PRECISION, galBounds[2].up); // VLKB extension
obscoreRow[em_min] = to_string(EM_PRECISION, icrsBounds[2].low);
obscoreRow[em_max] = to_string(EM_PRECISION, icrsBounds[2].up);
obscoreRow[em_res_power] = "NULL";//to_sql_value(hdu.key_values, "CDELT3");
obscoreRow[em_xel] = to_sql_value(hdu.key_values, "NAXIS3");
}
else if(icrsBounds.size() == 2) // 2D images
{
......@@ -319,6 +318,8 @@ void SqlSchema_INSERT::appendRow(
obscoreRow[em_min] = "NULL";
}
obscoreRow[em_max] = obscoreRow[em_min];
obscoreRow[vel_min] = "NULL";
obscoreRow[vel_max] = "NULL";
obscoreRow[em_res_power] = "NULL";
obscoreRow[em_xel] = "NULL";
}
......@@ -326,6 +327,8 @@ void SqlSchema_INSERT::appendRow(
{
obscoreRow[em_min] = "NULL";
obscoreRow[em_max] = "NULL";
obscoreRow[vel_min] = "NULL";
obscoreRow[vel_max] = "NULL";
obscoreRow[em_res_power] = "NULL";
obscoreRow[em_xel] = "NULL";
}
......@@ -357,6 +360,7 @@ void SqlSchema_INSERT::appendRow(
// GALACTIC coords
vector<point2d> galVerts = calc_skyvertices(hdu.m_header, "GALACTIC");
reorder_vertices(galVerts);
obscoreRow[s_region_galactic] = to_sqlstring(region_stcs("GALACTIC", galVerts));
obscoreRow[polygon_region_galactic] = to_sqlstring(region_spoly(galVerts));
// pgSphere-types
obscoreRow[polygon_region] = to_sqlstring(region_spoly(icrsVerts));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment