Commits
144 144 | |
145 145 | image::~image() {} |
146 146 | |
147 147 | image* image::adddegaxes( |
148 148 | const std::string& outfile, bool direction, |
149 149 | bool spectral, const std::string& stokes, bool linear, |
150 150 | bool tabular, bool overwrite, bool silent |
151 151 | ) { |
152 152 | try { |
153 153 | _log << _ORIGIN; |
154 - | if (detached()) { |
154 + | if (_detached()) { |
155 155 | return 0; |
156 156 | } |
157 157 | if (_imageF) { |
158 158 | casa::SPCIIF myim = _imageF; |
159 159 | return _adddegaxes( |
160 160 | myim, outfile, direction, spectral, stokes, |
161 161 | linear, tabular, overwrite, silent |
162 162 | ); |
163 163 | } |
164 164 | else { |
203 203 | _addHistory(z, "adddegaxes", names, values); |
204 204 | return new image(z); |
205 205 | } |
206 206 | |
207 207 | bool image::addnoise( |
208 208 | const std::string& type, const std::vector<double>& pars, |
209 209 | const variant& region, bool zeroIt, const vector<int>& seeds |
210 210 | ) { |
211 211 | try { |
212 212 | _log << LogOrigin("image", __func__); |
213 - | if (detached()) { |
213 + | if (_detached()) { |
214 214 | return false; |
215 215 | } |
216 216 | SHARED_PTR<Record> pRegion = _getRegion(region, false); |
217 217 | SHARED_PTR<std::pair<Int, Int> > seedPair(new std::pair<Int, Int>(0, 0)); |
218 218 | if (seeds.size() >= 2) { |
219 219 | seedPair->first = seeds[0]; |
220 220 | seedPair->second = seeds[1]; |
221 221 | } |
222 222 | else { |
223 223 | Time now; |
249 249 | _log << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
250 250 | << LogIO::POST; |
251 251 | RETHROW(x); |
252 252 | } |
253 253 | return false; |
254 254 | } |
255 255 | |
256 256 | record* image::beamarea(int channel, int polarization) { |
257 257 | try { |
258 258 | _log << _ORIGIN; |
259 - | if (detached()) { |
259 + | if (_detached()) { |
260 260 | return nullptr; |
261 261 | } |
262 262 | auto dc = _imageF |
263 263 | ? _imageF->coordinates().directionCoordinate() |
264 264 | : _imageC->coordinates().directionCoordinate(); |
265 265 | auto pixelArea = dc.getPixelArea(); |
266 266 | auto beamInPixels = _imageF |
267 267 | ? _imageF->imageInfo().getBeamAreaInPixels( |
268 268 | channel, polarization, dc |
269 269 | ) |
333 333 | _log << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
334 334 | << LogIO::POST; |
335 335 | RETHROW(x); |
336 336 | } |
337 337 | return nullptr; |
338 338 | } |
339 339 | |
340 340 | record* image::boundingbox(const variant& region) { |
341 341 | try { |
342 342 | _log << _ORIGIN; |
343 - | if (detached()) { |
343 + | if (_detached()) { |
344 344 | return nullptr; |
345 345 | } |
346 346 | auto myreg = _getRegion(region, false); |
347 347 | unique_ptr<ImageMetaData> md( |
348 348 | _imageF |
349 349 | ? new ImageMetaData(_imageF) |
350 350 | : new ImageMetaData(_imageC) |
351 351 | ); |
352 352 | return fromRecord(*md->getBoundingBox(*myreg)); |
353 353 | } |
360 360 | } |
361 361 | |
362 362 | image* image::boxcar( |
363 363 | const string& outfile, const variant& region, |
364 364 | const variant& vmask, int axis, int width, bool drop, |
365 365 | const string& dmethod, |
366 366 | bool overwrite, bool stretch |
367 367 | ) { |
368 368 | LogOrigin lor(_class, __func__); |
369 369 | _log << lor; |
370 - | if (detached()) { |
370 + | if (_detached()) { |
371 371 | throw AipsError("Unable to create image"); |
372 372 | } |
373 373 | try { |
374 374 | if (axis < 0) { |
375 375 | const auto& csys = _imageF |
376 376 | ? _imageF->coordinates() |
377 377 | : _imageC->coordinates(); |
378 378 | ThrowIf( |
379 379 | ! csys.hasSpectralAxis(), |
380 380 | "Axis not specified and image has no spectral coordinate" |
447 447 | drop, dmethod, overwrite, stretch |
448 448 | }; |
449 449 | if (_doHistory) { |
450 450 | auto msgs = _newHistory("boxcar", names, values); |
451 451 | smoother.addHistory(lor, msgs); |
452 452 | } |
453 453 | return new image(smoother.smooth()); |
454 454 | } |
455 455 | |
456 456 | std::string image::brightnessunit() { |
457 - | if (detached()) { |
457 + | if (_detached()) { |
458 458 | return ""; |
459 459 | } |
460 460 | try { |
461 461 | auto unit =_imageF |
462 462 | ? _imageF->units().getName() |
463 463 | : _imageC->units().getName(); |
464 464 | return unit; |
465 465 | } |
466 466 | catch (const AipsError& x) { |
467 467 | _log << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
468 468 | << LogIO::POST; |
469 469 | RETHROW(x); |
470 470 | } |
471 471 | return ""; |
472 472 | } |
473 473 | |
474 474 | bool image::calc(const std::string& expr, bool verbose) { |
475 475 | try { |
476 476 | _log << _ORIGIN; |
477 - | if (detached()) { |
477 + | if (_detached()) { |
478 478 | return false; |
479 479 | } |
480 480 | if (_imageF) { |
481 481 | ImageExprCalculator<Float>::compute2(_imageF, expr, verbose); |
482 482 | } |
483 483 | else { |
484 484 | ImageExprCalculator<Complex>::compute2(_imageC, expr, verbose); |
485 485 | } |
486 486 | vector<String> names = {"expr", "verbose"}; |
487 487 | vector<variant> values = {expr, verbose}; |
495 495 | RETHROW(x); |
496 496 | } |
497 497 | return false; |
498 498 | } |
499 499 | |
500 500 | bool image::calcmask( |
501 501 | const string& mask, const string& maskName, bool makeDefault |
502 502 | ) { |
503 503 | try { |
504 504 | _log << _ORIGIN; |
505 - | if (detached()) { |
505 + | if (_detached()) { |
506 506 | return false; |
507 507 | } |
508 508 | Record region; |
509 509 | if (_imageF) { |
510 510 | ImageMaskHandler<Float> imh(_imageF); |
511 511 | imh.calcmask(mask, region, maskName, makeDefault); |
512 512 | } |
513 513 | else { |
514 514 | ImageMaskHandler<Complex> imh(_imageC); |
515 515 | imh.calcmask(mask, region, maskName, makeDefault); |
542 542 | return false; |
543 543 | } |
544 544 | |
545 545 | image* image::collapse( |
546 546 | const string& function, const variant& axes, |
547 547 | const string& outfile, const variant& region, const string& box, |
548 548 | const string& chans, const string& stokes, const string& mask, |
549 549 | const bool overwrite, const bool stretch |
550 550 | ) { |
551 551 | _log << _ORIGIN; |
552 - | if (detached()) { |
552 + | if (_detached()) { |
553 553 | return 0; |
554 554 | } |
555 555 | try { |
556 556 | IPosition myAxes; |
557 557 | if (axes.type() == variant::INT) { |
558 558 | myAxes = IPosition(1, axes.toInt()); |
559 559 | } |
560 560 | else if (axes.type() == variant::INTVEC) { |
561 561 | myAxes = IPosition(axes.getIntVec()); |
562 562 | } |
650 650 | _log << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
651 651 | << LogIO::POST; |
652 652 | RETHROW(x); |
653 653 | } |
654 654 | return nullptr; |
655 655 | } |
656 656 | |
657 657 | record* image::commonbeam() { |
658 658 | try { |
659 659 | _log << _ORIGIN; |
660 - | if (detached()) { |
660 + | if (_detached()) { |
661 661 | return nullptr; |
662 662 | } |
663 663 | ImageInfo myInfo = _imageF ? _imageF->imageInfo() : _imageC->imageInfo(); |
664 664 | ThrowIf( |
665 665 | ! myInfo.hasBeam(), |
666 666 | "This image has no beam(s)." |
667 667 | ); |
668 668 | GaussianBeam beam; |
669 669 | if (myInfo.hasSingleBeam()) { |
670 670 | _log << LogIO::WARN |
690 690 | return nullptr; |
691 691 | } |
692 692 | |
693 693 | image* image::continuumsub( |
694 694 | const string& outline, const string& outcont, |
695 695 | const variant& region, const vector<int>& channels, |
696 696 | const string& pol, const int in_fitorder, const bool overwrite |
697 697 | ) { |
698 698 | try { |
699 699 | _log << _ORIGIN; |
700 - | if (detached()) { |
700 + | if (_detached()) { |
701 701 | return nullptr; |
702 702 | } |
703 703 | ThrowIf(in_fitorder < 0, "Polynomial order cannot be negative"); |
704 704 | if (! pol.empty()) { |
705 705 | _log << LogIO::NORMAL << "The pol parameter is no longer " |
706 706 | << "supported and will be removed in the near future. " |
707 707 | << "Please set the region parameter appropriately " |
708 708 | << "to select the polarization in which you are interested." |
709 709 | << LogIO::POST; |
710 710 | } |
756 756 | } |
757 757 | |
758 758 | record* image::convertflux( |
759 759 | const variant& qvalue, const variant& major, |
760 760 | const variant& minor, const string& /*type*/, |
761 761 | const bool toPeak, |
762 762 | const int channel, const int polarization |
763 763 | ) { |
764 764 | try { |
765 765 | _log << _ORIGIN; |
766 - | if (detached()) { |
766 + | if (_detached()) { |
767 767 | return 0; |
768 768 | } |
769 769 | ThrowIf( |
770 770 | ! _imageF, |
771 771 | "This method only supports Float valued images" |
772 772 | ); |
773 773 | casacore::Quantity value = casaQuantity(qvalue); |
774 774 | casacore::Quantity majorAxis = casaQuantity(major); |
775 775 | casacore::Quantity minorAxis = casaQuantity(minor); |
776 776 | Bool noBeam = false; |
794 794 | } |
795 795 | |
796 796 | image* image::convolve( |
797 797 | const string& outfile, const variant& kernel, |
798 798 | double scale, const variant& region, |
799 799 | const variant& vmask, bool overwrite, |
800 800 | bool stretch |
801 801 | ) { |
802 802 | try { |
803 803 | _log << _ORIGIN; |
804 - | if (detached()) { |
804 + | if (_detached()) { |
805 805 | return nullptr; |
806 806 | } |
807 807 | ThrowIf( |
808 808 | ! _imageF, |
809 809 | "This method only supports real valued images" |
810 810 | ); |
811 811 | Array<Float> fkernelArray; |
812 812 | casacore::String kernelFileName = ""; |
813 813 | if (kernel.type() == variant::DOUBLEVEC) { |
814 814 | const auto kernelVector = kernel.toDoubleVec(); |
868 868 | |
869 869 | image* image::convolve2d( |
870 870 | const string& outFile, const vector<int>& axes, |
871 871 | const string& type, const variant& major, const variant& minor, |
872 872 | const variant& pa, double in_scale, const variant& region, |
873 873 | const variant& vmask, bool overwrite, bool stretch, |
874 874 | bool targetres, const record& beam |
875 875 | ) { |
876 876 | try { |
877 877 | _log << _ORIGIN; |
878 - | if (detached()) { |
878 + | if (_detached()) { |
879 879 | return nullptr; |
880 880 | } |
881 881 | UnitMap::putUser("pix", UnitVal(1.0), "pixel units"); |
882 882 | SHARED_PTR<Record> Region(_getRegion(region, false)); |
883 883 | auto mask = _getMask(vmask); |
884 884 | String kernel(type); |
885 885 | casacore::Quantity majorKernel; |
886 886 | casacore::Quantity minorKernel; |
887 887 | casacore::Quantity paKernel; |
888 888 | _log << _ORIGIN; |
1001 1001 | } |
1002 1002 | return nullptr; |
1003 1003 | } |
1004 1004 | |
1005 1005 | record* image::coordmeasures( |
1006 1006 | const std::vector<double>&pixel, const string& dframe, |
1007 1007 | const string& sframe |
1008 1008 | ) { |
1009 1009 | try { |
1010 1010 | _log << _ORIGIN; |
1011 - | if (detached()) { |
1011 + | if (_detached()) { |
1012 1012 | return nullptr; |
1013 1013 | } |
1014 1014 | casacore::Record theDir; |
1015 1015 | casacore::Record theFreq; |
1016 1016 | casacore::Record theVel; |
1017 1017 | Vector<Double> vpixel; |
1018 1018 | if (!(pixel.size() == 1 && pixel[0] == -1)) { |
1019 1019 | vpixel = pixel; |
1020 1020 | } |
1021 1021 | unique_ptr<Record> retval; |
1056 1056 | _log << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
1057 1057 | << LogIO::POST; |
1058 1058 | RETHROW(x); |
1059 1059 | } |
1060 1060 | return nullptr; |
1061 1061 | } |
1062 1062 | |
1063 1063 | coordsys* image::coordsys(const std::vector<int>& pixelAxes) { |
1064 1064 | _log << _ORIGIN; |
1065 1065 | try { |
1066 - | if (detached()) { |
1066 + | if (_detached()) { |
1067 1067 | return nullptr; |
1068 1068 | } |
1069 1069 | vector<Int> myAxes = pixelAxes; |
1070 1070 | if (pixelAxes.size() == 1 && pixelAxes[0] == -1) { |
1071 1071 | myAxes.clear(); |
1072 1072 | } |
1073 1073 | unique_ptr<ImageMetaData> imd( |
1074 1074 | _imageF |
1075 1075 | ? new ImageMetaData(_imageF) |
1076 1076 | : new ImageMetaData(_imageC) |
1090 1090 | } |
1091 1091 | |
1092 1092 | image* image::crop( |
1093 1093 | const string& outfile, const vector<int>& axes, |
1094 1094 | bool overwrite, const variant& region, const string& box, |
1095 1095 | const string& chans, const string& stokes, const string& mask, |
1096 1096 | bool stretch, bool wantreturn |
1097 1097 | ) { |
1098 1098 | try { |
1099 1099 | _log << _ORIGIN; |
1100 - | if (detached()) { |
1100 + | if (_detached()) { |
1101 1101 | return nullptr; |
1102 1102 | } |
1103 1103 | ThrowIf( |
1104 1104 | ! _imageF, |
1105 1105 | "This method only supports Float valued images" |
1106 1106 | ); |
1107 1107 | if (axes.size() > 0) { |
1108 1108 | std::set<int> saxes(axes.begin(), axes.end()); |
1109 1109 | if (*saxes.begin() < 0) { |
1110 1110 | _log << "All axes values must be >= 0" << LogIO::EXCEPTION; |
1145 1145 | RETHROW(x); |
1146 1146 | } |
1147 1147 | return nullptr; |
1148 1148 | } |
1149 1149 | |
1150 1150 | image* image::decimate( |
1151 1151 | const string& outfile, int axis, int factor, const string& method, |
1152 1152 | const variant& region, const string& mask, bool overwrite, bool stretch |
1153 1153 | ) { |
1154 1154 | try { |
1155 - | if (detached()) { |
1155 + | if (_detached()) { |
1156 1156 | return nullptr; |
1157 1157 | } |
1158 1158 | ThrowIf( |
1159 1159 | axis < 0, |
1160 1160 | "The value of axis cannot be negative" |
1161 1161 | ); |
1162 1162 | ThrowIf( |
1163 1163 | factor < 0, |
1164 1164 | "The value of factor cannot be negative" |
1165 1165 | ); |
1233 1233 | } |
1234 1234 | |
1235 1235 | record* image::decompose( |
1236 1236 | const variant& region, const ::casac::variant& vmask, |
1237 1237 | bool simple, double threshold, int ncontour, int minrange, |
1238 1238 | int naxis, bool fit, double maxrms, int maxretry, int maxiter, |
1239 1239 | double convcriteria, bool stretch |
1240 1240 | ) { |
1241 1241 | try { |
1242 1242 | _log << _ORIGIN; |
1243 - | if (detached()) { |
1243 + | if (_detached()) { |
1244 1244 | return nullptr; |
1245 1245 | } |
1246 1246 | ThrowIf(! _imageF, "This application supports only real-valued images"); |
1247 1247 | ThrowIf( |
1248 1248 | threshold < 0, |
1249 1249 | "Threshold = " + String::toString(threshold) |
1250 1250 | + ". You must specify a nonnegative threshold" |
1251 1251 | ); |
1252 1252 | auto Region = _getRegion(region, false); |
1253 1253 | String mask = _getMask(vmask); |
1270 1270 | << LogIO::POST; |
1271 1271 | RETHROW(x); |
1272 1272 | } |
1273 1273 | return nullptr; |
1274 1274 | } |
1275 1275 | |
1276 1276 | record* image::deconvolvecomponentlist( |
1277 1277 | const record& complist, int channel, int polarization |
1278 1278 | ) { |
1279 1279 | _log << _ORIGIN; |
1280 - | if (detached()) { |
1280 + | if (_detached()) { |
1281 1281 | return nullptr; |
1282 1282 | } |
1283 1283 | try { |
1284 1284 | std::unique_ptr<Record> compList(toRecord(complist)); |
1285 1285 | ComponentList cl, clOut; |
1286 1286 | casacore::String err; |
1287 1287 | ThrowIf( |
1288 1288 | ! cl.fromRecord(err, *compList), |
1289 1289 | "Input dictionary is not a valid component list: " + err |
1290 1290 | ); |
1377 1377 | return fromRecord(outrec1); |
1378 1378 | } |
1379 1379 | catch (const AipsError& x) { |
1380 1380 | _log << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
1381 1381 | << LogIO::POST; |
1382 1382 | RETHROW(x); |
1383 1383 | } |
1384 1384 | return nullptr; |
1385 1385 | } |
1386 1386 | |
1387 - | bool image::detached() const { |
1387 + | bool image::_detached() const { |
1388 1388 | if ( ! _imageF && ! _imageC) { |
1389 1389 | _log << _ORIGIN; |
1390 1390 | _log << LogIO::SEVERE |
1391 - | << "Image is detached - cannot perform operation." << endl |
1391 + | << "Image is _detached - cannot perform operation." << endl |
1392 1392 | << "Call image.open('filename') to reattach." << LogIO::POST; |
1393 1393 | return true; |
1394 1394 | } |
1395 1395 | return false; |
1396 1396 | } |
1397 1397 | |
1398 1398 | bool image::dohistory(bool enable) { |
1399 1399 | _doHistory = enable; |
1400 1400 | return True; |
1401 1401 | } |
1402 1402 | |
1403 1403 | bool image::done(bool remove, bool verbose) { |
1404 1404 | try { |
1405 1405 | _log << _ORIGIN; |
1406 1406 | // resetting _stats must come before the table removal or the table |
1407 1407 | // removal will fail |
1408 1408 | _stats.reset(); |
1409 1409 | MeasIERS::closeTables(); |
1410 - | if (remove && !detached()) { |
1410 + | if (remove && !_detached()) { |
1411 1411 | _remove(verbose); |
1412 1412 | } |
1413 1413 | else { |
1414 1414 | _imageF.reset(); |
1415 1415 | _imageC.reset(); |
1416 1416 | } |
1417 1417 | return true; |
1418 1418 | } |
1419 1419 | catch (const AipsError& x) { |
1420 1420 | _log << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
1423 1423 | } |
1424 1424 | return false; |
1425 1425 | } |
1426 1426 | |
1427 1427 | record* image::findsources( |
1428 1428 | int nMax, double cutoff, const variant& region, |
1429 1429 | const variant& vmask, bool point, int width, bool absFind |
1430 1430 | ) { |
1431 1431 | try { |
1432 1432 | _log << _ORIGIN; |
1433 - | if (detached()) { |
1433 + | if (_detached()) { |
1434 1434 | return nullptr; |
1435 1435 | } |
1436 1436 | ThrowIf(_imageC, "This application supports only real-valued images"); |
1437 1437 | SHARED_PTR<Record> Region(_getRegion(region, false)); |
1438 1438 | auto mask = _getMask(vmask); |
1439 1439 | ImageSourceFinder<Float> sf(_imageF, Region.get(), mask); |
1440 1440 | sf.setCutoff(cutoff); |
1441 1441 | sf.setDoPoint(point); |
1442 1442 | sf.setWidth(width); |
1443 1443 | sf.setAbsFind(absFind); |
1460 1460 | |
1461 1461 | bool image::fft( |
1462 1462 | const string& realOut, const string& imagOut, |
1463 1463 | const string& ampOut, const string& phaseOut, |
1464 1464 | const std::vector<int>& axes, const variant& region, |
1465 1465 | const variant& vmask, bool stretch, |
1466 1466 | const string& complexOut |
1467 1467 | ) { |
1468 1468 | try { |
1469 1469 | _log << LogOrigin(_class, __func__); |
1470 - | if (detached()) { |
1470 + | if (_detached()) { |
1471 1471 | return false; |
1472 1472 | } |
1473 1473 | SHARED_PTR<Record> myregion(_getRegion(region, false)); |
1474 1474 | String mask = vmask.toString(); |
1475 1475 | if (mask == "[]") { |
1476 1476 | mask = ""; |
1477 1477 | } |
1478 1478 | Vector<uInt> leAxes(0); |
1479 1479 | if ( |
1480 1480 | axes.size() > 1 |
1548 1548 | const string& stokes, const variant& vmask, |
1549 1549 | const vector<double>& in_includepix, |
1550 1550 | const vector<double>& in_excludepix, const string& residual, |
1551 1551 | const string& model, const string& estimates, |
1552 1552 | const string& logfile, const bool append, |
1553 1553 | const string& newestimates, const string& complist, |
1554 1554 | bool overwrite, bool dooff, double offset, |
1555 1555 | bool fixoffset, bool stretch, const variant& rms, |
1556 1556 | const variant& noisefwhm, const string& summary |
1557 1557 | ) { |
1558 - | if (detached()) { |
1558 + | if (_detached()) { |
1559 1559 | return nullptr; |
1560 1560 | } |
1561 1561 | _log << _ORIGIN; |
1562 1562 | try { |
1563 1563 | ThrowIf( |
1564 1564 | ! _imageF, |
1565 1565 | "This method only supports Float valued images" |
1566 1566 | ); |
1567 1567 | auto num = in_includepix.size(); |
1568 1568 | Vector<Float> includepix(num); |
1707 1707 | const vector<double>& gmcenterest, const vector<double>& gmfwhmest, |
1708 1708 | const variant& gmfix, const string& spxtype, const vector<double>& spxest, |
1709 1709 | const vector<bool>& spxfix, const variant& div, const string& spxsol, |
1710 1710 | const string& spxerr, const string& logfile, bool append, |
1711 1711 | const variant& pfunc, const vector<double>& goodamprange, |
1712 1712 | const vector<double>& goodcenterrange, |
1713 1713 | const vector<double>& goodfwhmrange, const variant& sigma, |
1714 1714 | const string& outsigma, const vector<int>& planes |
1715 1715 | ) { |
1716 1716 | _log << LogOrigin(_class, __func__); |
1717 - | if (detached()) { |
1717 + | if (_detached()) { |
1718 1718 | return 0; |
1719 1719 | } |
1720 1720 | try { |
1721 1721 | ThrowIf( |
1722 1722 | ! _imageF, |
1723 1723 | "This method only supports Float valued images" |
1724 1724 | ); |
1725 1725 | String regionName; |
1726 1726 | SHARED_PTR<Record> regionPtr = _getRegion(region, true); |
1727 1727 | if (ngauss < 0) { |
2225 2225 | return false; |
2226 2226 | } |
2227 2227 | |
2228 2228 | variant* image::getchunk( |
2229 2229 | const std::vector<int>& blc, const std::vector<int>& trc, |
2230 2230 | const std::vector<int>& inc, const std::vector<int>& axes, |
2231 2231 | bool list, bool dropdeg, bool getmask |
2232 2232 | ) { |
2233 2233 | try { |
2234 2234 | _log << _ORIGIN; |
2235 - | if (detached()) { |
2235 + | if (_detached()) { |
2236 2236 | return nullptr; |
2237 2237 | } |
2238 2238 | Record ret; |
2239 2239 | if (_imageF) { |
2240 2240 | ret = _getchunk<Float>( |
2241 2241 | _imageF, blc, trc, inc, |
2242 2242 | axes, list, dropdeg |
2243 2243 | ); |
2244 2244 | if (! getmask) { |
2245 2245 | Array<Float> vals = ret.asArrayFloat("values"); |
2357 2357 | |
2358 2358 | record* image::getprofile( |
2359 2359 | int axis, const string& function, const variant& region, |
2360 2360 | const string& mask, const string& unit, bool stretch, |
2361 2361 | const string& spectype, const variant& restfreq, |
2362 2362 | const string& frame, const string& logfile |
2363 2363 | ) { |
2364 2364 | try { |
2365 2365 | _log << _ORIGIN; |
2366 2366 | ThrowIf( |
2367 - | detached(), "No image attached to tool" |
2367 + | _detached(), "No image attached to tool" |
2368 2368 | ); |
2369 2369 | ThrowIf(axis<0, "Axis must be greater than 0"); |
2370 2370 | SHARED_PTR<Record> myregion(_getRegion(region, false)); |
2371 2371 | SHARED_PTR<casacore::Quantity> rfreq; |
2372 2372 | if (restfreq.type() != variant::BOOLVEC) { |
2373 2373 | String rf = restfreq.toString(); |
2374 2374 | rf.trim(); |
2375 2375 | if (! rf.empty()) { |
2376 2376 | rfreq.reset( |
2377 2377 | new casacore::Quantity(_casaQuantityFromVar(variant(restfreq))) |
2429 2429 | return x; |
2430 2430 | } |
2431 2431 | |
2432 2432 | variant* image::getregion( |
2433 2433 | const variant& region, const std::vector<int>& axes, |
2434 2434 | const variant& mask, bool list, bool dropdeg, |
2435 2435 | bool getmask, bool stretch |
2436 2436 | ) { |
2437 2437 | try { |
2438 2438 | _log << _ORIGIN; |
2439 - | if (detached()) { |
2439 + | if (_detached()) { |
2440 2440 | return 0; |
2441 2441 | } |
2442 2442 | SHARED_PTR<Record> Region(_getRegion(region, false)); |
2443 2443 | auto Mask = _getMask(mask); |
2444 2444 | Vector<Int> iaxes(axes); |
2445 2445 | // if default value change it to empty vector |
2446 2446 | if (iaxes.size() == 1 && iaxes[0] < 0) { |
2447 2447 | iaxes.resize(); |
2448 2448 | } |
2449 2449 | Record ret; |
2497 2497 | return nullptr; |
2498 2498 | } |
2499 2499 | |
2500 2500 | record* image::getslice( |
2501 2501 | const std::vector<double>& x, const std::vector<double>& y, |
2502 2502 | const std::vector<int>& axes, const std::vector<int>& coord, |
2503 2503 | int npts, const std::string& method |
2504 2504 | ) { |
2505 2505 | try { |
2506 2506 | _log << _ORIGIN; |
2507 - | if (detached()) { |
2507 + | if (_detached()) { |
2508 2508 | return nullptr; |
2509 2509 | } |
2510 2510 | ThrowIf( |
2511 2511 | _imageC, |
2512 2512 | "This method only supports Float valued images" |
2513 2513 | ); |
2514 2514 | // handle default coord |
2515 2515 | vector<int> ncoord(coord); |
2516 2516 | if (ncoord.size() == 1 && ncoord[0] == -1) { |
2517 2517 | ncoord.assign(_imageF->ndim(), 0); |
2537 2537 | } |
2538 2538 | |
2539 2539 | image* image::hanning( |
2540 2540 | const string& outfile, const variant& region, |
2541 2541 | const variant& vmask, int axis, bool drop, |
2542 2542 | bool overwrite, bool /* async */, bool stretch, |
2543 2543 | const string& dmethod |
2544 2544 | ) { |
2545 2545 | LogOrigin lor(_class, __func__); |
2546 2546 | _log << lor; |
2547 - | if (detached()) { |
2547 + | if (_detached()) { |
2548 2548 | throw AipsError("Unable to create image"); |
2549 2549 | } |
2550 2550 | try { |
2551 2551 | auto myregion = _getRegion( |
2552 2552 | region, true |
2553 2553 | ); |
2554 2554 | auto mask = _getMask(vmask); |
2555 2555 | if (axis < 0) { |
2556 2556 | const CoordinateSystem csys = _imageF |
2557 2557 | ? _imageF->coordinates() |
2627 2627 | }; |
2628 2628 | auto msgs = _newHistory("hanning", names, values); |
2629 2629 | smoother.addHistory(_ORIGIN, msgs); |
2630 2630 | } |
2631 2631 | return new image(smoother.smooth()); |
2632 2632 | } |
2633 2633 | |
2634 2634 | vector<bool> image::haslock() { |
2635 2635 | try { |
2636 2636 | _log << _ORIGIN; |
2637 - | if (detached()) { |
2637 + | if (_detached()) { |
2638 2638 | return vector<bool>(); |
2639 2639 | } |
2640 2640 | if (_imageF) { |
2641 2641 | return vector<bool> { |
2642 2642 | _imageF->hasLock(FileLocker::Read), |
2643 2643 | _imageF->hasLock(FileLocker::Write) |
2644 2644 | }; |
2645 2645 | } |
2646 2646 | else { |
2647 2647 | return vector<bool> { |
2658 2658 | return vector<bool>(); |
2659 2659 | } |
2660 2660 | |
2661 2661 | record* image::histograms( |
2662 2662 | const vector<int>& axes, |
2663 2663 | const variant& region, const variant& mask, |
2664 2664 | int nbins, const vector<double>& includepix, |
2665 2665 | bool cumu, bool log, bool stretch |
2666 2666 | ) { |
2667 2667 | _log << _ORIGIN; |
2668 - | if (detached()) { |
2668 + | if (_detached()) { |
2669 2669 | return 0; |
2670 2670 | } |
2671 2671 | try { |
2672 2672 | vector<uInt> myaxes; |
2673 2673 | if (axes.size() != 1 || axes[0] != -1) { |
2674 2674 | ThrowIf( |
2675 2675 | *min_element(axes.begin(), axes.end()) < 0, |
2676 2676 | "All axes must be nonnegative" |
2677 2677 | ); |
2678 2678 | myaxes.insert(begin(myaxes), begin(axes), end(axes)); |
2702 2702 | _log << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
2703 2703 | << LogIO::POST; |
2704 2704 | RETHROW(x); |
2705 2705 | } |
2706 2706 | return nullptr; |
2707 2707 | } |
2708 2708 | |
2709 2709 | std::vector<std::string> image::history(bool list) { |
2710 2710 | try { |
2711 2711 | _log << _ORIGIN; |
2712 - | if (detached()) { |
2712 + | if (_detached()) { |
2713 2713 | return vector<string>(); |
2714 2714 | } |
2715 2715 | if (_imageF) { |
2716 2716 | SPIIF im = _imageF; |
2717 2717 | ImageHistory<Float> hist(im); |
2718 2718 | return fromVectorString(hist.get(list)); |
2719 2719 | } |
2720 2720 | else { |
2721 2721 | SPIIC im = _imageC; |
2722 2722 | ImageHistory<Complex> hist(im); |
2848 2848 | } |
2849 2849 | return nullptr; |
2850 2850 | } |
2851 2851 | |
2852 2852 | bool image::insert( |
2853 2853 | const std::string& infile, const variant& region, |
2854 2854 | const std::vector<double>& locate, bool verbose |
2855 2855 | ) { |
2856 2856 | try { |
2857 2857 | _log << _ORIGIN; |
2858 - | if (detached()) { |
2858 + | if (_detached()) { |
2859 2859 | return false; |
2860 2860 | } |
2861 2861 | Vector<Double> locatePixel(locate); |
2862 2862 | if (locatePixel.size() == 1 && locatePixel[0] < 0) { |
2863 2863 | locatePixel.resize(0); |
2864 2864 | } |
2865 2865 | auto Region = _getRegion(region, false); |
2866 2866 | auto imagePair = ImageFactory::fromFile(infile); |
2867 2867 | |
2868 2868 | if (imagePair.first && _imageF) { |
2906 2906 | _log << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
2907 2907 | << LogIO::POST; |
2908 2908 | RETHROW(x); |
2909 2909 | } |
2910 2910 | return false; |
2911 2911 | } |
2912 2912 | |
2913 2913 | bool image::ispersistent() { |
2914 2914 | try { |
2915 2915 | _log << LogOrigin("image", "ispersistent"); |
2916 - | if (detached()) { |
2916 + | if (_detached()) { |
2917 2917 | return false; |
2918 2918 | } |
2919 2919 | if (_imageF) { |
2920 2920 | return _imageF->isPersistent(); |
2921 2921 | } |
2922 2922 | else { |
2923 2923 | return _imageC->isPersistent(); |
2924 2924 | } |
2925 2925 | } |
2926 2926 | catch (const AipsError& x) { |
2927 2927 | _log << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
2928 2928 | << LogIO::POST; |
2929 2929 | RETHROW(x); |
2930 2930 | } |
2931 2931 | return false; |
2932 2932 | } |
2933 2933 | |
2934 2934 | bool image::lock(bool writelock, int nattempts) { |
2935 2935 | try { |
2936 2936 | _log << LogOrigin("image", __func__); |
2937 - | if (detached()) { |
2937 + | if (_detached()) { |
2938 2938 | return false; |
2939 2939 | } |
2940 2940 | FileLocker::LockType locker = FileLocker::Read; |
2941 2941 | if (writelock) { |
2942 2942 | locker = FileLocker::Write; |
2943 2943 | } |
2944 2944 | uInt n = max(0, nattempts); |
2945 2945 | if (_imageF) { |
2946 2946 | return _imageF->lock(locker, n); |
2947 2947 | } |
2956 2956 | } |
2957 2957 | return false; |
2958 2958 | } |
2959 2959 | |
2960 2960 | bool image::makecomplex( |
2961 2961 | const std::string& outfile, const std::string& imagFile, |
2962 2962 | const variant& region, bool overwrite |
2963 2963 | ) { |
2964 2964 | try { |
2965 2965 | _log << _ORIGIN; |
2966 - | if (detached()) { |
2966 + | if (_detached()) { |
2967 2967 | return false; |
2968 2968 | } |
2969 2969 | ThrowIf( |
2970 2970 | ! _imageF, "The attached image must be real valued" |
2971 2971 | ); |
2972 2972 | SHARED_PTR<Record> Region(_getRegion(region, false)); |
2973 2973 | auto mypair = ImageFactory::fromFile(imagFile); |
2974 2974 | ThrowIf( |
2975 2975 | ! mypair.first, imagFile + " does not have real valued pixels" |
2976 2976 | ); |
2998 2998 | image* image::deviation( |
2999 2999 | const std::string& outfile, const variant& region, |
3000 3000 | const string& mask, bool overwrite, bool stretch, |
3001 3001 | const vector<int>& grid, const variant& anchor, |
3002 3002 | const variant& xlength, const variant& ylength, |
3003 3003 | const string& interp, const string& stattype, |
3004 3004 | const string& statalg, double zscore, int maxiter |
3005 3005 | ) { |
3006 3006 | _log << _ORIGIN; |
3007 3007 | try { |
3008 - | if (detached()) { |
3008 + | if (_detached()) { |
3009 3009 | return nullptr; |
3010 3010 | } |
3011 3011 | ThrowIf( |
3012 3012 | ! _imageF, |
3013 3013 | "This method only supports Float valued images" |
3014 3014 | ); |
3015 3015 | ThrowIf( |
3016 3016 | grid.size() != 2, |
3017 3017 | "grid must have exactly two positive integer values" |
3018 3018 | ); |
3166 3166 | RETHROW(x); |
3167 3167 | } |
3168 3168 | return false; |
3169 3169 | } |
3170 3170 | |
3171 3171 | vector<string> image::maskhandler( |
3172 3172 | const string& op, const vector<string>& name |
3173 3173 | ) { |
3174 3174 | try { |
3175 3175 | _log << _ORIGIN; |
3176 - | if (detached()) { |
3176 + | if (_detached()) { |
3177 3177 | return vector<string>(0); |
3178 3178 | } |
3179 3179 | String oper = op; |
3180 3180 | oper.upcase(); |
3181 3181 | vector<string> res = _imageF |
3182 3182 | ? _handleMask(_imageF, oper, name) |
3183 3183 | : _handleMask(_imageC, oper, name); |
3184 3184 | if (res.empty()) { |
3185 3185 | res = vector<string>(1, "T"); |
3186 3186 | } |
3241 3241 | ThrowCc("Unknown operation " + oper); |
3242 3242 | } |
3243 3243 | } |
3244 3244 | |
3245 3245 | record* image::maxfit( |
3246 3246 | const variant& region, bool doPoint, |
3247 3247 | int width, bool absFind, bool list |
3248 3248 | ) { |
3249 3249 | try { |
3250 3250 | _log << _ORIGIN; |
3251 - | if (detached()) { |
3251 + | if (_detached()) { |
3252 3252 | return nullptr; |
3253 3253 | } |
3254 3254 | ThrowIf( |
3255 3255 | ! _imageF, |
3256 3256 | "This method only supports float-valued images" |
3257 3257 | ); |
3258 3258 | auto Region = _getRegion(region, false); |
3259 3259 | ImageMaxFitter<Float> imf(_imageF, Region.get()); |
3260 3260 | return fromRecord(imf.fit(doPoint, width, absFind, list)); |
3261 3261 | } |
3262 3262 | catch (const AipsError& x) { |
3263 3263 | _log << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
3264 3264 | << LogIO::POST; |
3265 3265 | RETHROW(x); |
3266 3266 | } |
3267 3267 | return nullptr; |
3268 3268 | } |
3269 3269 | |
3270 3270 | record* image::miscinfo() { |
3271 3271 | try { |
3272 3272 | _log << LogOrigin("image", "miscinfo"); |
3273 - | if (detached()) { |
3273 + | if (_detached()) { |
3274 3274 | return nullptr; |
3275 3275 | } |
3276 3276 | if (_imageF) { |
3277 3277 | return fromRecord(_imageF->miscInfo()); |
3278 3278 | } |
3279 3279 | else { |
3280 3280 | return fromRecord(_imageC->miscInfo()); |
3281 3281 | } |
3282 3282 | } |
3283 3283 | catch (const AipsError& x) { |
3287 3287 | } |
3288 3288 | return nullptr; |
3289 3289 | } |
3290 3290 | |
3291 3291 | bool image::modify( |
3292 3292 | const record& model, const variant& region, |
3293 3293 | const variant& vmask, bool subtract, bool list, |
3294 3294 | bool stretch |
3295 3295 | ) { |
3296 3296 | _log << _ORIGIN; |
3297 - | if (detached()) { |
3297 + | if (_detached()) { |
3298 3298 | return false; |
3299 3299 | } |
3300 3300 | try { |
3301 3301 | ThrowIf( |
3302 3302 | ! _imageF, |
3303 3303 | "This method only supports real valued images" |
3304 3304 | ); |
3305 3305 | String error; |
3306 3306 | std::unique_ptr<Record> mymodel(toRecord(model)); |
3307 3307 | ComponentList cl; |
3347 3347 | const vector<double>& smoothwidths, |
3348 3348 | const vector<double>& d_includepix, |
3349 3349 | const vector<double>& d_excludepix, double peaksnr, |
3350 3350 | double stddev, const string& velocityType, |
3351 3351 | const string& out, const string& smoothout, |
3352 3352 | bool overwrite, bool removeAxis, |
3353 3353 | bool stretch, bool /* async */ |
3354 3354 | ) { |
3355 3355 | try { |
3356 3356 | _log << _ORIGIN; |
3357 - | if (detached()) { |
3357 + | if (_detached()) { |
3358 3358 | return nullptr; |
3359 3359 | } |
3360 3360 | UnitMap::putUser("pix", UnitVal(1.0), "pixel units"); |
3361 3361 | Vector<Int> whichmoments(moments); |
3362 3362 | SHARED_PTR<Record> Region(_getRegion(region, false)); |
3363 3363 | auto mask = _getMask(vmask); |
3364 3364 | Vector<String> kernels; |
3365 3365 | if (smoothtypes.type() == ::casac::variant::BOOLVEC) { |
3366 3366 | kernels.resize(0); // unset |
3367 3367 | } |
3466 3466 | _log << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
3467 3467 | << LogIO::POST; |
3468 3468 | RETHROW(x); |
3469 3469 | } |
3470 3470 | return nullptr; |
3471 3471 | } |
3472 3472 | |
3473 3473 | string image::name(bool strippath) { |
3474 3474 | try { |
3475 3475 | _log << _ORIGIN; |
3476 - | if (detached()) { |
3476 + | if (_detached()) { |
3477 3477 | return "none"; |
3478 3478 | } |
3479 3479 | return _name(strippath); |
3480 3480 | } |
3481 3481 | catch (const AipsError& x) { |
3482 3482 | _log << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
3483 3483 | << LogIO::POST; |
3484 3484 | RETHROW(x); |
3485 3485 | } |
3486 3486 | return ""; |
3674 3674 | } |
3675 3675 | |
3676 3676 | image* image::pad( |
3677 3677 | const string& outfile, int npixels, double value, bool padmask, |
3678 3678 | bool overwrite, const variant& region, const string& box, |
3679 3679 | const string& chans, const string& stokes, const string& mask, |
3680 3680 | bool stretch, bool wantreturn |
3681 3681 | ) { |
3682 3682 | try { |
3683 3683 | _log << _ORIGIN; |
3684 - | if (detached()) { |
3684 + | if (_detached()) { |
3685 3685 | return nullptr; |
3686 3686 | } |
3687 3687 | ThrowIf( |
3688 3688 | ! _imageF, |
3689 3689 | "This method only supports Float valued images" |
3690 3690 | ); |
3691 3691 | if (npixels <= 0) { |
3692 3692 | _log << "Value of npixels must be greater than zero" << LogIO::EXCEPTION; |
3693 3693 | } |
3694 3694 | auto regionPtr = _getRegion(region, true); |
3727 3727 | } |
3728 3728 | |
3729 3729 | image* image::pbcor( |
3730 3730 | const variant& pbimage, const string& outfile, |
3731 3731 | bool overwrite, const string& box, |
3732 3732 | const variant& region, const string& chans, |
3733 3733 | const string& stokes, const string& mask, |
3734 3734 | const string& mode, float cutoff, |
3735 3735 | bool stretch |
3736 3736 | ) { |
3737 - | if (detached()) { |
3737 + | if (_detached()) { |
3738 3738 | throw AipsError("Unable to create image"); |
3739 3739 | } |
3740 3740 | try { |
3741 3741 | _log << _ORIGIN; |
3742 3742 | ThrowIf( |
3743 3743 | ! _imageF, |
3744 3744 | "This method only supports Float valued images" |
3745 3745 | ); |
3746 3746 | Array<Float> pbPixels; |
3747 3747 | SPCIIF pb_ptr; |
3813 3813 | _log << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
3814 3814 | << LogIO::POST; |
3815 3815 | RETHROW(x); |
3816 3816 | } |
3817 3817 | return nullptr; |
3818 3818 | } |
3819 3819 | |
3820 3820 | record* image::pixelvalue(const vector<int>& pixel) { |
3821 3821 | try { |
3822 3822 | _log << _ORIGIN; |
3823 - | if (detached()) { |
3823 + | if (_detached()) { |
3824 3824 | return nullptr; |
3825 3825 | } |
3826 3826 | if(_imageF) { |
3827 3827 | PixelValueManipulator<Float> pvm( |
3828 3828 | _imageF, nullptr, "", false |
3829 3829 | ); |
3830 3830 | return fromRecord(pvm.pixelValue(Vector<Int> (pixel))); |
3831 3831 | } |
3832 3832 | else { |
3833 3833 | PixelValueManipulator<Complex> pvm( |
3844 3844 | return nullptr; |
3845 3845 | } |
3846 3846 | |
3847 3847 | bool image::putchunk( |
3848 3848 | const variant& pixels, |
3849 3849 | const vector<int>& blc, const vector<int>& inc, |
3850 3850 | bool list, bool locking, bool replicate |
3851 3851 | ) { |
3852 3852 | try { |
3853 3853 | _log << _ORIGIN; |
3854 - | if (detached()) { |
3854 + | if (_detached()) { |
3855 3855 | return false; |
3856 3856 | } |
3857 3857 | if (_imageF) { |
3858 3858 | _putchunk( |
3859 3859 | _imageF, pixels, blc, inc, list, locking, replicate |
3860 3860 | ); |
3861 3861 | } |
3862 3862 | else { |
3863 3863 | if ( |
3864 3864 | pixels.type() == variant::COMPLEXVEC |
3935 3935 | ); |
3936 3936 | } |
3937 3937 | |
3938 3938 | bool image::putregion( |
3939 3939 | const variant& v_pixels, const variant& v_pixelmask, |
3940 3940 | const variant& region, bool list, bool usemask, |
3941 3941 | bool , bool replicateArray |
3942 3942 | ) { |
3943 3943 | try { |
3944 3944 | _log << _ORIGIN; |
3945 - | if (detached()) { |
3945 + | if (_detached()) { |
3946 3946 | return false; |
3947 3947 | } |
3948 3948 | // create Array<Float> pixels |
3949 3949 | Array<Float> pixels; |
3950 3950 | if (_isUnset(v_pixels)) { |
3951 3951 | // do nothing |
3952 3952 | } |
3953 3953 | else if (v_pixels.type() == ::casac::variant::DOUBLEVEC) { |
3954 3954 | std::vector<double> pixelVector = v_pixels.getDoubleVec(); |
3955 3955 | Vector<Int> shape = v_pixels.arrayshape(); |
4044 4044 | } |
4045 4045 | |
4046 4046 | image* image::pv( |
4047 4047 | const string& outfile, const variant& start, |
4048 4048 | const variant& end, const variant& center, const variant& length, |
4049 4049 | const variant& pa, const variant& width, const string& unit, |
4050 4050 | bool overwrite, const variant& region, const string& chans, |
4051 4051 | const string& stokes, const string& mask, bool stretch, |
4052 4052 | bool wantreturn |
4053 4053 | ) { |
4054 - | if (detached()) { |
4054 + | if (_detached()) { |
4055 4055 | return nullptr; |
4056 4056 | } |
4057 4057 | try { |
4058 4058 | _log << _ORIGIN; |
4059 4059 | ThrowIf( |
4060 4060 | ! _imageF, |
4061 4061 | "This method only supports Float valued images" |
4062 4062 | ); |
4063 4063 | SHARED_PTR<casacore::MDirection> startMD, endMD, centerMD; |
4064 4064 | Vector<Double> startPix, endPix, centerPix; |
4262 4262 | |
4263 4263 | image* image::rebin( |
4264 4264 | const string& outfile, const vector<int>& bin, |
4265 4265 | const variant& region, const variant& vmask, |
4266 4266 | bool dropdeg, bool overwrite, bool /* async */, |
4267 4267 | bool stretch, bool crop |
4268 4268 | ) { |
4269 4269 | LogOrigin lor(_class, __func__); |
4270 4270 | _log << lor; |
4271 4271 | ThrowIf( |
4272 - | detached(), "Unable to create image" |
4272 + | _detached(), "Unable to create image" |
4273 4273 | ); |
4274 4274 | Vector<Int> mybin(bin); |
4275 4275 | ThrowIf( |
4276 4276 | anyTrue(mybin <= 0), |
4277 4277 | "All binning factors must be positive." |
4278 4278 | ); |
4279 4279 | try { |
4280 4280 | vector<String> msgs; |
4281 4281 | if (_doHistory) { |
4282 4282 | vector<String> names { |
4335 4335 | const variant& region, const variant& vmask, |
4336 4336 | const string& method, int decimate, bool replicate, |
4337 4337 | bool doRefChange, bool dropDegenerateAxes, |
4338 4338 | bool overwrite, bool forceRegrid, |
4339 4339 | bool specAsVelocity, bool /* async */, |
4340 4340 | bool stretch |
4341 4341 | ) { |
4342 4342 | try { |
4343 4343 | LogOrigin lor(_class, __func__); |
4344 4344 | _log << lor; |
4345 - | if (detached()) { |
4345 + | if (_detached()) { |
4346 4346 | throw AipsError("Unable to create image"); |
4347 4347 | return 0; |
4348 4348 | } |
4349 4349 | unique_ptr<Record> csysRec(toRecord(csys)); |
4350 4350 | unique_ptr<CoordinateSystem> coordinates(CoordinateSystem::restore(*csysRec, "")); |
4351 4351 | ThrowIf ( |
4352 4352 | ! coordinates.get(), |
4353 4353 | "Invalid specified coordinate system record." |
4354 4354 | ); |
4355 4355 | auto regionPtr = _getRegion(region, true); |
4427 4427 | if (_doHistory) { |
4428 4428 | regridder.addHistory(lor, msgs); |
4429 4429 | } |
4430 4430 | return new image(regridder.regrid()); |
4431 4431 | } |
4432 4432 | |
4433 4433 | bool image::remove(const bool finished, const bool verbose) { |
4434 4434 | try { |
4435 4435 | _log << _ORIGIN; |
4436 4436 | |
4437 - | if (detached()) { |
4437 + | if (_detached()) { |
4438 4438 | return false; |
4439 4439 | } |
4440 4440 | _remove(verbose); |
4441 4441 | if (finished) { |
4442 4442 | done(); |
4443 4443 | } |
4444 4444 | return true; |
4445 4445 | } |
4446 4446 | catch (const AipsError &x) { |
4447 4447 | _log << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
4500 4500 | _log << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
4501 4501 | << LogIO::POST; |
4502 4502 | RETHROW(x); |
4503 4503 | } |
4504 4504 | return rstat; |
4505 4505 | } |
4506 4506 | |
4507 4507 | bool image::rename(const string& name, bool overwrite) { |
4508 4508 | try { |
4509 4509 | _log << _ORIGIN; |
4510 - | if (detached()) { |
4510 + | if (_detached()) { |
4511 4511 | return false; |
4512 4512 | } |
4513 4513 | _stats.reset(); |
4514 4514 | auto oldName = this->name(False); |
4515 4515 | if (_imageF) { |
4516 4516 | auto myimage = _imageF; |
4517 4517 | _imageF.reset(); |
4518 4518 | ImageFactory::rename(myimage, name, overwrite); |
4519 4519 | _imageF = myimage; |
4520 4520 | } |
4537 4537 | } |
4538 4538 | return false; |
4539 4539 | } |
4540 4540 | |
4541 4541 | bool image::replacemaskedpixels( |
4542 4542 | const variant& pixels, const variant& region, |
4543 4543 | const variant& vmask, bool updateMask, bool list, |
4544 4544 | bool stretch |
4545 4545 | ) { |
4546 4546 | _log << _ORIGIN; |
4547 - | if (detached()) { |
4547 + | if (_detached()) { |
4548 4548 | return false; |
4549 4549 | } |
4550 4550 | try { |
4551 4551 | auto regionPtr = _getRegion(region, true); |
4552 4552 | auto mask = _getMask(vmask); |
4553 4553 | if (_imageF) { |
4554 4554 | auto myfloat = _imageF; |
4555 4555 | ImageMaskedPixelReplacer<Float> impr( |
4556 4556 | myfloat, regionPtr.get(), mask |
4557 4557 | ); |
4584 4584 | _log << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
4585 4585 | << LogIO::POST; |
4586 4586 | RETHROW(x); |
4587 4587 | } |
4588 4588 | return false; |
4589 4589 | } |
4590 4590 | |
4591 4591 | record* image::restoringbeam(int channel, int polarization) { |
4592 4592 | try { |
4593 4593 | _log << _ORIGIN; |
4594 - | if (detached()) { |
4594 + | if (_detached()) { |
4595 4595 | return nullptr; |
4596 4596 | } |
4597 4597 | if (_imageF) { |
4598 4598 | return fromRecord( |
4599 4599 | _imageF->imageInfo().beamToRecord( |
4600 4600 | channel, polarization |
4601 4601 | ) |
4602 4602 | ); |
4603 4603 | } |
4604 4604 | else { |
4619 4619 | |
4620 4620 | image* image::rotate( |
4621 4621 | const string& outfile, const vector<int>& inshape, |
4622 4622 | const variant& inpa, const variant& region, |
4623 4623 | const variant& vmask, const string& method, |
4624 4624 | int decimate, bool replicate, bool dropdeg, |
4625 4625 | bool overwrite, bool stretch |
4626 4626 | ) { |
4627 4627 | try { |
4628 4628 | _log << _ORIGIN; |
4629 - | ThrowIf(detached(), "Unable to create image"); |
4629 + | ThrowIf(_detached(), "Unable to create image"); |
4630 4630 | Vector<Int> shape(inshape); |
4631 4631 | if (shape.size() == 1 && shape[0] == -1) { |
4632 4632 | shape.resize(0); |
4633 4633 | } |
4634 4634 | auto pa = _casaQuantityFromVar(inpa); |
4635 4635 | auto Region = _getRegion(region, false); |
4636 4636 | auto mask = _getMask(vmask); |
4637 4637 | ImageRotator rotator( |
4638 4638 | _imageF, Region.get(), mask, outfile, overwrite |
4639 4639 | ); |
4667 4667 | _log << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
4668 4668 | << LogIO::POST; |
4669 4669 | RETHROW(x); |
4670 4670 | } |
4671 4671 | return nullptr; |
4672 4672 | } |
4673 4673 | |
4674 4674 | bool image::rotatebeam(const variant& angle) { |
4675 4675 | try { |
4676 4676 | _log << _ORIGIN; |
4677 - | if(detached()) { |
4677 + | if(_detached()) { |
4678 4678 | return false; |
4679 4679 | } |
4680 4680 | Quantum<Double> pa(_casaQuantityFromVar(angle)); |
4681 4681 | vector<String> msgs; |
4682 4682 | if (_doHistory) { |
4683 4683 | vector<String> names { "angle" }; |
4684 4684 | vector<variant> values { angle }; |
4685 4685 | msgs = _newHistory(__func__, names, values); |
4686 4686 | } |
4687 4687 | if (_imageF) { |
4703 4703 | } |
4704 4704 | |
4705 4705 | image* image::sepconvolve( |
4706 4706 | const string& outfile, const vector<int>& axes, |
4707 4707 | const vector<std::string>& types, |
4708 4708 | const variant& widths, |
4709 4709 | double scale, const variant& region, |
4710 4710 | const variant& vmask, bool overwrite, bool stretch |
4711 4711 | ) { |
4712 4712 | _log << _ORIGIN; |
4713 - | if (detached()) { |
4713 + | if (_detached()) { |
4714 4714 | ThrowCc("Unable to create image"); |
4715 4715 | } |
4716 4716 | try { |
4717 4717 | UnitMap::putUser("pix", UnitVal(1.0), "pixel units"); |
4718 4718 | auto pRegion = _getRegion(region, false); |
4719 4719 | auto mask = _getMask(vmask); |
4720 4720 | Vector<Int> smoothaxes(axes); |
4721 4721 | auto kernels = toVectorString(types); |
4722 4722 | |
4723 4723 | Int num = 0; |
4801 4801 | } |
4802 4802 | return nullptr; |
4803 4803 | } |
4804 4804 | |
4805 4805 | bool image::set( |
4806 4806 | const variant& vpixels, int pixelmask, |
4807 4807 | const variant& region, bool list |
4808 4808 | ) { |
4809 4809 | try { |
4810 4810 | _log << _ORIGIN; |
4811 - | if (detached()) { |
4811 + | if (_detached()) { |
4812 4812 | return false; |
4813 4813 | } |
4814 4814 | auto pixels = vpixels.toString(); |
4815 4815 | if (pixels == "[]") { |
4816 4816 | pixels = ""; |
4817 4817 | } |
4818 4818 | auto pRegion = _getRegion(region, false); |
4819 4819 | if (pixels == "" && pixelmask == -1) { |
4820 4820 | _log << LogIO::WARN |
4821 4821 | << "You must specify at least either the pixels or the mask to set" |
4845 4845 | _log << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
4846 4846 | << LogIO::POST; |
4847 4847 | RETHROW(x); |
4848 4848 | } |
4849 4849 | return false; |
4850 4850 | } |
4851 4851 | |
4852 4852 | bool image::setbrightnessunit(const std::string& unit) { |
4853 4853 | try { |
4854 4854 | _log << _ORIGIN; |
4855 - | if (detached()) { |
4855 + | if (_detached()) { |
4856 4856 | return false; |
4857 4857 | } |
4858 4858 | Bool res = _imageF |
4859 4859 | ? _imageF->setUnits(Unit(unit)) |
4860 4860 | : _imageC->setUnits(Unit(unit)); |
4861 4861 | ThrowIf(! res, "Unable to set brightness unit"); |
4862 4862 | if (_doHistory) { |
4863 4863 | vector<String> names = {"unit"}; |
4864 4864 | vector<variant> values = {unit}; |
4865 4865 | _addHistory(__func__, names, values); |
4871 4871 | _log << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
4872 4872 | << LogIO::POST; |
4873 4873 | RETHROW(x); |
4874 4874 | } |
4875 4875 | return false; |
4876 4876 | } |
4877 4877 | |
4878 4878 | bool image::setcoordsys(const record& csys) { |
4879 4879 | try { |
4880 4880 | _log << _ORIGIN; |
4881 - | if (detached()) { |
4881 + | if (_detached()) { |
4882 4882 | return false; |
4883 4883 | } |
4884 4884 | |
4885 4885 | unique_ptr<Record> coordinates(toRecord(csys)); |
4886 4886 | unique_ptr<ImageMetaDataRW> md( |
4887 4887 | _imageF |
4888 4888 | ? new ImageMetaDataRW(_imageF) |
4889 4889 | : new ImageMetaDataRW(_imageC) |
4890 4890 | ); |
4891 4891 | md->setCsys(*coordinates); |
4900 4900 | << LogIO::POST; |
4901 4901 | RETHROW(x); |
4902 4902 | } |
4903 4903 | return true; |
4904 4904 | } |
4905 4905 | |
4906 4906 | bool image::sethistory( |
4907 4907 | const string& origin, const vector<string>& history |
4908 4908 | ) { |
4909 4909 | try { |
4910 - | if (detached()) { |
4910 + | if (_detached()) { |
4911 4911 | return false; |
4912 4912 | } |
4913 4913 | if ((history.size() == 1) && (history[0].size() == 0)) { |
4914 4914 | LogOrigin lor("image", "sethistory"); |
4915 4915 | _log << lor << "history string is empty" << LogIO::POST; |
4916 4916 | } |
4917 4917 | else { |
4918 4918 | if(_imageF) { |
4919 4919 | ImageHistory<Float> hist(_imageF); |
4920 4920 | hist.addHistory(origin, history); |
4930 4930 | _log << _ORIGIN << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
4931 4931 | << LogIO::POST; |
4932 4932 | RETHROW(x); |
4933 4933 | } |
4934 4934 | return false; |
4935 4935 | } |
4936 4936 | |
4937 4937 | bool image::setmiscinfo(const record& info) { |
4938 4938 | try { |
4939 4939 | _log << _ORIGIN; |
4940 - | if (detached()) { |
4940 + | if (_detached()) { |
4941 4941 | return false; |
4942 4942 | } |
4943 4943 | |
4944 4944 | std::unique_ptr<Record> tmp(toRecord(info)); |
4945 4945 | Bool res = _imageF |
4946 4946 | ? _imageF->setMiscInfo(*tmp) |
4947 4947 | : _imageC->setMiscInfo(*tmp); |
4948 4948 | if (res && _doHistory) { |
4949 4949 | vector<String> names {"info"}; |
4950 4950 | vector<variant> values {info}; |
4962 4962 | |
4963 4963 | bool image::setrestoringbeam( |
4964 4964 | const variant& major, const variant& minor, |
4965 4965 | const variant& pa, const record& beam, |
4966 4966 | bool remove, bool log, |
4967 4967 | int channel, int polarization, |
4968 4968 | const string& imagename |
4969 4969 | ) { |
4970 4970 | try { |
4971 4971 | _log << _ORIGIN; |
4972 - | if (detached()) { |
4972 + | if (_detached()) { |
4973 4973 | return false; |
4974 4974 | } |
4975 4975 | std::unique_ptr<Record> rec(toRecord(beam)); |
4976 4976 | ImageBeamSet bs; |
4977 4977 | if (! imagename.empty()) { |
4978 4978 | ThrowIf( |
4979 4979 | ! major.empty() || ! minor.empty() || ! pa.empty(), |
4980 4980 | "Cannot specify both imagename and major, minor, and/or pa" |
4981 4981 | ); |
4982 4982 | ThrowIf( |
5081 5081 | |
5082 5082 | String image::_quantityRecToString(const Record& q) { |
5083 5083 | ostringstream oss; |
5084 5084 | oss << "{'value': " << q.asDouble("value") |
5085 5085 | << ", 'unit': '" << q.asString("unit") << "'}"; |
5086 5086 | return oss.str(); |
5087 5087 | } |
5088 5088 | |
5089 5089 | vector<int> image::shape() { |
5090 5090 | _log << _ORIGIN; |
5091 - | if (detached()) { |
5091 + | if (_detached()) { |
5092 5092 | return vector<int>(); |
5093 5093 | } |
5094 5094 | try { |
5095 5095 | vector<int> rstat = _imageF |
5096 5096 | ? _imageF->shape().asVector().tovector() |
5097 5097 | : _imageC->shape().asVector().tovector(); |
5098 5098 | return rstat; |
5099 5099 | } |
5100 5100 | catch (const AipsError& x) { |
5101 5101 | _log << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
5110 5110 | const variant& mask, |
5111 5111 | const vector<double>& includepix, |
5112 5112 | const vector<double>& excludepix, bool list, bool force, |
5113 5113 | bool disk, bool robust, bool verbose, |
5114 5114 | bool stretch, const string& logfile, |
5115 5115 | bool append, const string& algorithm, double fence, |
5116 5116 | const string& center, bool lside, double zscore, |
5117 5117 | int maxiter, const string& clmethod, int niter |
5118 5118 | ) { |
5119 5119 | _log << _ORIGIN; |
5120 - | if (detached()) { |
5120 + | if (_detached()) { |
5121 5121 | _log << "Image not attached" << LogIO::POST; |
5122 5122 | return nullptr; |
5123 5123 | } |
5124 5124 | try { |
5125 5125 | ThrowIf( |
5126 5126 | ! _imageF, |
5127 5127 | "This method only supports Float valued images" |
5128 5128 | ); |
5129 5129 | SHARED_PTR<Record> regionRec(_getRegion(region, true)); |
5130 5130 | String mtmp = mask.toString(); |
5258 5258 | |
5259 5259 | image* image::subimage( |
5260 5260 | const string& outfile, const variant& region, |
5261 5261 | const variant& vmask, bool dropDegenerateAxes, |
5262 5262 | bool overwrite, bool list, bool stretch, |
5263 5263 | bool wantreturn, const vector<int>& keepaxes |
5264 5264 | ) { |
5265 5265 | try { |
5266 5266 | _log << _ORIGIN; |
5267 5267 | ThrowIf( |
5268 - | detached(), |
5268 + | _detached(), |
5269 5269 | "Unable to create image" |
5270 5270 | ); |
5271 5271 | SHARED_PTR<Record> regionRec = _getRegion(region, false); |
5272 5272 | String regionStr = region.type() == variant::STRING |
5273 5273 | ? region.toString() |
5274 5274 | : ""; |
5275 5275 | String mask = vmask.toString(); |
5276 5276 | if (mask == "[]") { |
5277 5277 | mask = ""; |
5278 5278 | } |
5352 5352 | ); |
5353 5353 | } |
5354 5354 | } |
5355 5355 | |
5356 5356 | record* image::summary( |
5357 5357 | const string& doppler, bool list, |
5358 5358 | bool pixelorder, bool verbose |
5359 5359 | ) { |
5360 5360 | try { |
5361 5361 | _log << _ORIGIN; |
5362 - | if (detached()) { |
5362 + | if (_detached()) { |
5363 5363 | return 0; |
5364 5364 | } |
5365 5365 | if (_imageF) { |
5366 5366 | ImageMetaData md(_imageF); |
5367 5367 | return fromRecord( |
5368 5368 | md.summary(doppler, list, pixelorder, verbose) |
5369 5369 | ); |
5370 5370 | } |
5371 5371 | else { |
5372 5372 | ImageMetaData md(_imageC); |
5384 5384 | } |
5385 5385 | |
5386 5386 | bool image::toASCII( |
5387 5387 | const string& outfile, const variant& region, |
5388 5388 | const variant& mask, const string& sep, |
5389 5389 | const string& format, double maskvalue, bool overwrite, |
5390 5390 | bool stretch |
5391 5391 | ) { |
5392 5392 | // sep is hard-wired as ' ' which is what imagefromascii expects |
5393 5393 | _log << _ORIGIN; |
5394 - | if (detached()) { |
5394 + | if (_detached()) { |
5395 5395 | return false; |
5396 5396 | } |
5397 5397 | try { |
5398 5398 | String Mask; |
5399 5399 | if (mask.type() == variant::BOOLVEC) { |
5400 5400 | Mask = ""; |
5401 5401 | } |
5402 5402 | else if ( |
5403 5403 | mask.type() == variant::STRING |
5404 5404 | || mask.type() == variant::STRINGVEC |
5423 5423 | bool image::tofits( |
5424 5424 | const string& fitsfile, bool velocity, |
5425 5425 | bool optical, int bitpix, double minpix, |
5426 5426 | double maxpix, const variant& region, |
5427 5427 | const variant& vmask, bool overwrite, |
5428 5428 | bool dropdeg, bool deglast, bool dropstokes, |
5429 5429 | bool stokeslast, bool wavelength, bool airwavelength, |
5430 5430 | bool /* async */, bool stretch, bool history |
5431 5431 | ) { |
5432 5432 | _log << _ORIGIN; |
5433 - | if (detached()) { |
5433 + | if (_detached()) { |
5434 5434 | return false; |
5435 5435 | } |
5436 5436 | try { |
5437 5437 | ThrowIf( |
5438 5438 | fitsfile.empty(), |
5439 5439 | "fitsfile must be specified" |
5440 5440 | ); |
5441 5441 | ThrowIf( |
5442 5442 | fitsfile == "." || fitsfile == "..", |
5443 5443 | "Invalid fitsfile name " + fitsfile |
5480 5480 | _log << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
5481 5481 | << LogIO::POST; |
5482 5482 | RETHROW(x); |
5483 5483 | } |
5484 5484 | return false; |
5485 5485 | } |
5486 5486 | |
5487 5487 | record* image::topixel(const variant& value) { |
5488 5488 | try { |
5489 5489 | _log << LogOrigin("image", __func__); |
5490 - | if (detached()) { |
5490 + | if (_detached()) { |
5491 5491 | return nullptr; |
5492 5492 | } |
5493 5493 | auto cSys = _imageF |
5494 5494 | ? _imageF->coordinates() |
5495 5495 | : _imageC->coordinates(); |
5496 5496 | casac::coordsys mycoords; |
5497 5497 | //NOT using _image->toworld as most of the math is in casac namespace |
5498 5498 | //in coordsys...should revisit this when casac::coordsys is cleaned |
5499 5499 | mycoords.setcoordsys(cSys); |
5500 5500 | return mycoords.topixel(value); |
5501 5501 | } |
5502 5502 | catch (const AipsError& x) { |
5503 5503 | _log << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
5504 5504 | << LogIO::POST; |
5505 5505 | RETHROW(x); |
5506 5506 | } |
5507 5507 | return nullptr; |
5508 5508 | } |
5509 5509 | |
5510 5510 | record* image::torecord() { |
5511 5511 | _log << LogOrigin("image", __func__); |
5512 - | if (detached()) { |
5512 + | if (_detached()) { |
5513 5513 | return new record(); |
5514 5514 | } |
5515 5515 | try { |
5516 5516 | Record rec; |
5517 5517 | String err; |
5518 5518 | Bool ret = _imageF ? _imageF->toRecord(err, rec) |
5519 5519 | : _imageC->toRecord(err, rec); |
5520 5520 | ThrowIf (! ret, "Could not convert to record: " + err); |
5521 5521 | return fromRecord(rec); |
5522 5522 | } |
5526 5526 | RETHROW(x); |
5527 5527 | } |
5528 5528 | return new record(); |
5529 5529 | } |
5530 5530 | |
5531 5531 | record* image::toworld( |
5532 5532 | const variant& value, const string& format, bool dovelocity |
5533 5533 | ) { |
5534 5534 | try { |
5535 5535 | _log << LogOrigin("image", __func__); |
5536 - | if (detached()) { |
5536 + | if (_detached()) { |
5537 5537 | return nullptr; |
5538 5538 | } |
5539 5539 | Vector<Double> pixel; |
5540 5540 | if (_isUnset(value)) { |
5541 5541 | pixel.resize(0); |
5542 5542 | } |
5543 5543 | else if (value.type() == variant::DOUBLEVEC) { |
5544 5544 | pixel = value.getDoubleVec(); |
5545 5545 | } |
5546 5546 | else if (value.type() == variant::INTVEC) { |
5579 5579 | RETHROW(x); |
5580 5580 | } |
5581 5581 | return nullptr; |
5582 5582 | } |
5583 5583 | |
5584 5584 | image* image::transpose( |
5585 5585 | const std::string& outfile, const variant& order |
5586 5586 | ) { |
5587 5587 | try { |
5588 5588 | _log << _ORIGIN; |
5589 - | if (detached()) { |
5589 + | if (_detached()) { |
5590 5590 | throw AipsError("No image specified to transpose"); |
5591 5591 | } |
5592 5592 | ThrowIf( |
5593 5593 | ! _imageF, |
5594 5594 | "This method only supports Float valued images" |
5595 5595 | ); |
5596 5596 | std::unique_ptr<ImageTransposer> transposer; |
5597 5597 | switch(order.type()) { |
5598 5598 | case variant::INT: |
5599 5599 | transposer.reset( |
5649 5649 | return nullptr; |
5650 5650 | } |
5651 5651 | |
5652 5652 | bool image::twopointcorrelation( |
5653 5653 | const string& outfile, |
5654 5654 | const variant& region, const variant& vmask, |
5655 5655 | const vector<int>& axes, const string& method, |
5656 5656 | bool overwrite, bool stretch |
5657 5657 | ) { |
5658 5658 | _log << _ORIGIN; |
5659 - | if (detached()) { |
5659 + | if (_detached()) { |
5660 5660 | return false; |
5661 5661 | } |
5662 5662 | try { |
5663 5663 | String outFile(outfile); |
5664 5664 | SHARED_PTR<Record> Region(_getRegion(region, false)); |
5665 5665 | String mask = vmask.toString(); |
5666 5666 | if (mask == "[]") { |
5667 5667 | mask = ""; |
5668 5668 | } |
5669 5669 | Vector<Int> iAxes; |
5725 5725 | return tpc.correlate(); |
5726 5726 | } |
5727 5727 | |
5728 5728 | string image::type() { |
5729 5729 | return "image"; |
5730 5730 | } |
5731 5731 | |
5732 5732 | bool image::unlock() { |
5733 5733 | try { |
5734 5734 | _log << LogOrigin("image", __func__); |
5735 - | if (detached()) { |
5735 + | if (_detached()) { |
5736 5736 | return false; |
5737 5737 | } |
5738 5738 | if (_imageF) { |
5739 5739 | _imageF->unlock(); |
5740 5740 | } |
5741 5741 | else { |
5742 5742 | _imageC->unlock(); |
5743 5743 | } |
5744 5744 | return true; |
5745 5745 | } catch (const AipsError& x) { |
6006 6006 | _log << LogOrigin("image", __func__); |
6007 6007 | _log << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
6008 6008 | << LogIO::POST; |
6009 6009 | RETHROW(x); |
6010 6010 | } |
6011 6011 | } |
6012 6012 | |
6013 6013 | bool image::isconform(const string& other) { |
6014 6014 | _log << _ORIGIN; |
6015 6015 | |
6016 - | if (detached()) { |
6016 + | if (_detached()) { |
6017 6017 | return false; |
6018 6018 | } |
6019 6019 | try { |
6020 6020 | ThrowIf( |
6021 6021 | ! _imageF, |
6022 6022 | "This method only supports Float valued images" |
6023 6023 | ); |
6024 6024 | auto mypair = ImageFactory::fromFile(other); |
6025 6025 | auto shape = mypair.first ? mypair.first->shape() |
6026 6026 | : mypair.second->shape(); |