[93] | 1 | #include <Detection/columns.hh> |
---|
| 2 | #include <param.hh> |
---|
| 3 | #include <Cubes/cubes.hh> |
---|
| 4 | #include <vector> |
---|
| 5 | #include <string> |
---|
| 6 | |
---|
| 7 | using std::string; |
---|
| 8 | using std::vector; |
---|
| 9 | using namespace Column; |
---|
| 10 | |
---|
| 11 | Col getDefaultCol(int i){ |
---|
| 12 | ColSet columnSet; |
---|
| 13 | switch(i){ |
---|
| 14 | case 0: |
---|
| 15 | return Col(5, "Obj#", ""); //[0] -- in briefCol |
---|
| 16 | break; |
---|
| 17 | case 1: |
---|
| 18 | return Col(8,"Name", ""); //[1] -- in briefCol |
---|
| 19 | break; |
---|
| 20 | case 2: |
---|
| 21 | return Col(6, "X", ""); //[2] -- in briefCol |
---|
| 22 | break; |
---|
| 23 | case 3: |
---|
| 24 | return Col(6, "Y", ""); //[3] -- in briefCol |
---|
| 25 | break; |
---|
| 26 | case 4: |
---|
| 27 | return Col(6, "Z", ""); //[4] -- in briefCol |
---|
| 28 | break; |
---|
| 29 | case 5: |
---|
| 30 | return Col(13,"", ""); //[5] (RA) |
---|
| 31 | break; |
---|
| 32 | case 6: |
---|
| 33 | return Col(13,"", ""); //[6] (Dec) |
---|
| 34 | break; |
---|
| 35 | case 7: |
---|
| 36 | return Col(7, "VEL", ""); //[7] |
---|
| 37 | break; |
---|
| 38 | case 8: |
---|
| 39 | return Col(9, "", "[arcmin]"); //[8] (wRA) |
---|
| 40 | break; |
---|
| 41 | case 9: |
---|
| 42 | return Col(9, "", "[arcmin]"); //[9] (wDEC) |
---|
| 43 | break; |
---|
| 44 | case 10: |
---|
| 45 | return Col(7, "w_VEL", ""); //[10] |
---|
| 46 | break; |
---|
| 47 | case 12: |
---|
| 48 | return Col(9, "F_peak", ""); //[12] -- in briefCol |
---|
| 49 | break; |
---|
| 50 | case 13: |
---|
| 51 | return Col(4, "X1", ""); //[13] -- in briefCol |
---|
| 52 | break; |
---|
| 53 | case 14: |
---|
| 54 | return Col(4, "X2", ""); //[14] -- in briefCol |
---|
| 55 | break; |
---|
| 56 | case 15: |
---|
| 57 | return Col(4, "Y1", ""); //[15] -- in briefCol |
---|
| 58 | break; |
---|
| 59 | case 16: |
---|
| 60 | return Col(4, "Y2", ""); //[16] -- in briefCol |
---|
| 61 | break; |
---|
| 62 | case 17: |
---|
| 63 | return Col(4, "Z1", ""); //[17] -- in briefCol |
---|
| 64 | break; |
---|
| 65 | case 18: |
---|
| 66 | return Col(4, "Z2", ""); //[18] -- in briefCol |
---|
| 67 | break; |
---|
| 68 | case 19: |
---|
| 69 | return Col(6, "Npix", "[pix]"); //[19] -- in briefCol |
---|
| 70 | break; |
---|
| 71 | case 20: |
---|
| 72 | return Col(5, "Flag", ""); //[20] |
---|
| 73 | break; |
---|
| 74 | case 11: |
---|
| 75 | default: |
---|
| 76 | std::cerr << "ERROR <getDefaultCol> : bad value of argument : " << i << "\n"; |
---|
| 77 | break; |
---|
| 78 | } |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | void Cube::setupColumns(){ |
---|
| 82 | |
---|
| 83 | this->fullColSet.vec.clear(); |
---|
| 84 | this->logColSet.vec.clear(); |
---|
| 85 | |
---|
| 86 | // initialise |
---|
| 87 | |
---|
| 88 | Col fint(10,"F_int", ""); |
---|
| 89 | Col ftot(10,"F_tot", ""); |
---|
| 90 | |
---|
| 91 | Col tempC; |
---|
| 92 | string tempstr; |
---|
| 93 | int size; |
---|
| 94 | |
---|
| 95 | // Obj# and Name |
---|
| 96 | this->fullColSet.vec.push_back(getDefaultCol(0)); |
---|
| 97 | tempC = getDefaultCol(1); |
---|
| 98 | for(int o=0;o<this->objectList.size();o++){ |
---|
| 99 | int tempsize = this->objectList[o].getName().size() + 1; |
---|
| 100 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
| 101 | } |
---|
| 102 | for(int i=tempC.getWidth();i<size;i++) tempC.widen(); |
---|
| 103 | this->fullColSet.vec.push_back(tempC); |
---|
| 104 | |
---|
| 105 | // X, Y, Z -- check for widened columns |
---|
| 106 | tempC = getDefaultCol(2); |
---|
| 107 | for(int o=0;o<this->objectList.size();o++){ |
---|
| 108 | int tempsize = int( log10(this->objectList[o].getXcentre()) + 1) + xyzPrec + 2; |
---|
| 109 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
| 110 | } |
---|
| 111 | for(int i=tempC.getWidth();i<size;i++) tempC.widen(); |
---|
| 112 | this->fullColSet.vec.push_back(tempC); |
---|
| 113 | tempC = getDefaultCol(3); |
---|
| 114 | for(int o=0;o<this->objectList.size();o++){ |
---|
| 115 | int tempsize = int( log10(this->objectList[o].getYcentre()) + 1) + xyzPrec + 2; |
---|
| 116 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
| 117 | } |
---|
| 118 | for(int i=tempC.getWidth();i<size;i++) tempC.widen(); |
---|
| 119 | this->fullColSet.vec.push_back(tempC); |
---|
| 120 | tempC = getDefaultCol(4); |
---|
| 121 | for(int o=0;o<this->objectList.size();o++){ |
---|
| 122 | int tempsize = int( log10(this->objectList[o].getZcentre()) + 1) + xyzPrec + 2; |
---|
| 123 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
| 124 | } |
---|
| 125 | for(int i=tempC.getWidth();i<size;i++) tempC.widen(); |
---|
| 126 | this->fullColSet.vec.push_back(tempC); |
---|
| 127 | |
---|
| 128 | // RA & Dec -- should be fine, need to assign correct column title |
---|
| 129 | tempstr = this->head.getWCS()->lngtyp; |
---|
| 130 | tempC = getDefaultCol(5); |
---|
| 131 | tempC.setName(tempstr); |
---|
| 132 | this->fullColSet.vec.push_back(tempC); |
---|
| 133 | tempC = getDefaultCol(6); |
---|
| 134 | tempstr = this->head.getWCS()->lattyp; |
---|
| 135 | tempC.setName(tempstr); |
---|
| 136 | this->fullColSet.vec.push_back(tempC); |
---|
| 137 | |
---|
| 138 | // VEL -- title & width to be checked |
---|
| 139 | tempC = getDefaultCol(7); |
---|
| 140 | tempC.setUnit("[" + this->head.getSpectralUnits() + "]"); |
---|
| 141 | size = this->head.getSpectralUnits().size() + 3; |
---|
| 142 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
| 143 | for(int o=0;o<this->objectList.size();o++){ |
---|
| 144 | int tempsize = int( log10(fabsf(this->objectList[o].getVel())) + 1) + velPrec + 2; |
---|
| 145 | if(this->objectList[o].getVel()<0) tempsize++; // for - sign |
---|
| 146 | if((o==0)||(tempsize > size)) size = tempsize; |
---|
| 147 | } |
---|
| 148 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
| 149 | this->fullColSet.vec.push_back(tempC); |
---|
| 150 | |
---|
| 151 | // w_RA & w_DEC -- titles and widths to be checked. |
---|
| 152 | tempstr = "w_" + this->fullColSet.vec[5].getName(); |
---|
| 153 | tempC = getDefaultCol(8); |
---|
| 154 | tempC.setName(tempstr); |
---|
| 155 | for(int o=0;o<this->objectList.size();o++){ |
---|
[95] | 156 | int tempsize = int( log10(this->objectList[o].getRAWidth()) + 1) + wposPrec + 2; |
---|
[93] | 157 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
| 158 | } |
---|
| 159 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
| 160 | this->fullColSet.vec.push_back(tempC); |
---|
| 161 | |
---|
| 162 | tempstr = "w_" + this->fullColSet.vec[6].name; |
---|
| 163 | tempC = getDefaultCol(9); |
---|
| 164 | tempC.setName(tempstr); |
---|
| 165 | for(int o=0;o<this->objectList.size();o++){ |
---|
[95] | 166 | int tempsize = int( log10(this->objectList[o].getDecWidth()) + 1) + wposPrec + 2; |
---|
[93] | 167 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
| 168 | } |
---|
| 169 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
| 170 | this->fullColSet.vec.push_back(tempC); |
---|
| 171 | |
---|
| 172 | // w_VEL -- title & width to be checked |
---|
| 173 | tempC = getDefaultCol(10); |
---|
| 174 | tempC.setUnit("[" + this->head.getSpectralUnits() + "]"); |
---|
| 175 | size = this->head.getSpectralUnits().size() + 3; |
---|
| 176 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
| 177 | for(int o=0;o<this->objectList.size();o++){ |
---|
| 178 | int tempsize = int( log10(this->objectList[o].getVelWidth()) + 1) + velPrec + 2; |
---|
| 179 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
| 180 | } |
---|
| 181 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
| 182 | this->fullColSet.vec.push_back(tempC); |
---|
| 183 | |
---|
| 184 | // F_int |
---|
| 185 | fint.setUnit("[" + this->head.getIntFluxUnits() + "]"); |
---|
| 186 | size = this->head.getIntFluxUnits().size(); |
---|
| 187 | for(int i=fint.width-3;i<size;i++) fint.widen(); |
---|
| 188 | for(int o=0;o<this->objectList.size();o++){ |
---|
| 189 | int tempsize = int( log10(this->objectList[o].getIntegFlux()) + 1) + fluxPrec + 2; |
---|
| 190 | if((o==0)||(size < tempsize )) size = tempsize; |
---|
| 191 | } |
---|
| 192 | for(int i=fint.width;i<size;i++) fint.widen(); |
---|
| 193 | |
---|
| 194 | // F_tot |
---|
| 195 | ftot.setUnit("[" + this->head.getFluxUnits() + "]"); |
---|
| 196 | size = this->head.getFluxUnits().size(); |
---|
| 197 | for(int i=ftot.width-3;i<size;i++) ftot.widen(); |
---|
| 198 | for(int o=0;o<this->objectList.size();o++){ |
---|
| 199 | int tempsize = int( log10(this->objectList[o].getTotalFlux()) + 1) + fluxPrec + 2; |
---|
| 200 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
| 201 | } |
---|
| 202 | for(int i=ftot.width;i<size;i++) ftot.widen(); |
---|
| 203 | |
---|
| 204 | // Add F_int or F_tot depending on WCS status |
---|
| 205 | if(this->head.isWCS()) this->fullColSet.vec.push_back(fint); |
---|
| 206 | else this->fullColSet.vec.push_back(ftot); |
---|
| 207 | |
---|
| 208 | // F_peak |
---|
| 209 | tempC = getDefaultCol(12); |
---|
| 210 | tempC.setUnit("[" + this->head.getFluxUnits() + "]"); |
---|
| 211 | size = this->head.getFluxUnits().size(); |
---|
| 212 | for(int i=tempC.width-3;i<size;i++) tempC.widen(); |
---|
| 213 | for(int o=0;o<this->objectList.size();o++){ |
---|
| 214 | int tempsize = int( log10(this->objectList[o].getPeakFlux()) + 1); |
---|
| 215 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
| 216 | } |
---|
| 217 | for(int i=tempC.width;i<size+fluxPrec+2;i++) tempC.widen(); |
---|
| 218 | this->fullColSet.vec.push_back(tempC); |
---|
| 219 | |
---|
| 220 | // X1,X2,Y1,Y2,Z1,Z2 -- just check widths |
---|
| 221 | tempC = getDefaultCol(13); |
---|
| 222 | for(int o=0;o<this->objectList.size();o++){ |
---|
| 223 | int tempsize = int( log10(this->objectList[o].getXmin()) + 1 + 1); |
---|
| 224 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
| 225 | } |
---|
| 226 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
| 227 | this->fullColSet.vec.push_back(tempC); |
---|
| 228 | tempC = getDefaultCol(14); |
---|
| 229 | for(int o=0;o<this->objectList.size();o++){ |
---|
| 230 | int tempsize = int( log10(this->objectList[o].getXmax()) + 1 + 1); |
---|
| 231 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
| 232 | } |
---|
| 233 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
| 234 | this->fullColSet.vec.push_back(tempC); |
---|
| 235 | |
---|
| 236 | tempC = getDefaultCol(15); |
---|
| 237 | for(int o=0;o<this->objectList.size();o++){ |
---|
| 238 | int tempsize = int( log10(this->objectList[o].getYmin()) + 1) + 1; |
---|
| 239 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
| 240 | } |
---|
| 241 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
| 242 | this->fullColSet.vec.push_back(tempC); |
---|
| 243 | tempC = getDefaultCol(16); |
---|
| 244 | for(int o=0;o<this->objectList.size();o++){ |
---|
| 245 | int tempsize = int( log10(this->objectList[o].getYmax()) + 1) + 1; |
---|
| 246 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
| 247 | } |
---|
| 248 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
| 249 | this->fullColSet.vec.push_back(tempC); |
---|
| 250 | |
---|
| 251 | tempC = getDefaultCol(17); |
---|
| 252 | for(int o=0;o<this->objectList.size();o++){ |
---|
| 253 | int tempsize = int( log10(this->objectList[o].getZmin()) + 1) + 1; |
---|
| 254 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
| 255 | } |
---|
| 256 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
| 257 | this->fullColSet.vec.push_back(tempC); |
---|
| 258 | tempC = getDefaultCol(18); |
---|
| 259 | for(int o=0;o<this->objectList.size();o++){ |
---|
| 260 | int tempsize = int( log10(this->objectList[o].getZmax()) + 1) + 1; |
---|
| 261 | if((o==0)||(size < tempsize)) size = tempsize; |
---|
| 262 | } |
---|
| 263 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
| 264 | this->fullColSet.vec.push_back(tempC); |
---|
| 265 | |
---|
| 266 | // Npix -- check for width. |
---|
| 267 | tempC = getDefaultCol(19); |
---|
| 268 | for(int o=0;o<this->objectList.size();o++){ |
---|
| 269 | size = int( log10(this->objectList[o].getSize()) ) + 2; |
---|
| 270 | for(int i=tempC.width;i<size;i++) tempC.widen(); |
---|
| 271 | } |
---|
| 272 | this->fullColSet.vec.push_back(tempC); |
---|
| 273 | |
---|
| 274 | // Flags. |
---|
| 275 | this->fullColSet.vec.push_back(getDefaultCol(20)); |
---|
| 276 | |
---|
| 277 | // Now copy the correct columns to the log columnset |
---|
| 278 | this->logColSet.vec.push_back(this->fullColSet.vec[0]); |
---|
| 279 | for(int i=1;i<4;i++) this->logColSet.vec.push_back(this->fullColSet.vec[i+1]); |
---|
| 280 | this->logColSet.vec.push_back(ftot); |
---|
| 281 | for(int i=5;i<13;i++) this->logColSet.vec.push_back(this->fullColSet.vec[i+7]); |
---|
| 282 | this->logColSet.defined= true; |
---|
| 283 | |
---|
| 284 | } |
---|