Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project(casarest)
enable_language(CXX Fortran)
cmake_minimum_required(VERSION 2.6)
cmake_minimum_required(VERSION 3.3.0)
include(CheckCXXCompilerFlag)
#list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake)
set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
Expand All @@ -21,25 +21,9 @@ if(HDF5_ROOT_DIR)
set(ENV{HDF5_ROOT} ${HDF5_ROOT_DIR})
endif(HDF5_ROOT_DIR)

# Detect if the compiler supports C++11 if we want to use it.
check_cxx_compiler_flag(-std=c++11 HAS_CXX11)
if (HAS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else()
message(FATAL_ERROR "Casacore build requires a c++11 compatible compiler")
endif (HAS_CXX11)

# libsynthesis has a mix of C++ and Fortran which is not handled well by
# versions before 2.8.
if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.8)
if(NOT LIB_EXTRA_SYNTHESIS)
set(LIB_EXTRA_SYNTHESIS gfortran)
endif(NOT LIB_EXTRA_SYNTHESIS)
endif(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.8)

# project version
set( ${PROJECT_NAME}_MAJOR_VERSION 1 )
set( ${PROJECT_NAME}_MINOR_VERSION 8 )
set( ${PROJECT_NAME}_MINOR_VERSION 9 )
set( ${PROJECT_NAME}_PATCH_LEVEL 0 )

if (UseCasaNamespace)
Expand Down
4 changes: 2 additions & 2 deletions calibration/CalTables/CalTable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ CalTable CalTable::select (const String& calSelect)
return *this;
} else {
String parseString = "select from $1 where " + calSelect;
Table result = tableCommand (parseString, *itsMainTable);
Table result = tableCommand (parseString, *itsMainTable).table();
return CalTable (result);
};
};
Expand All @@ -255,7 +255,7 @@ void CalTable::select2 (const String& calSelect)
Int nspace = calSelect.freq (' ');
if (!calSelect.empty() && nspace!=len) {
String parseString = "select from $1 where " + calSelect;
Table *selected = new Table(tableCommand (parseString, *itsMainTable));
Table *selected = new Table(tableCommand (parseString, *itsMainTable).table());
delete itsMainTable;
itsMainTable=selected;
};
Expand Down
4 changes: 2 additions & 2 deletions calibration/CalTables/CalTable2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ CalTable2 CalTable2::select (const String& calSelect)
return *this;
} else {
String parseString = "select from $1 where " + calSelect;
Table result = tableCommand (parseString, *itsMainTable);
Table result = tableCommand (parseString, *itsMainTable).table();
return CalTable2 (result);
};
};
Expand All @@ -262,7 +262,7 @@ void CalTable2::select2 (const String& calSelect)
Int nspace = calSelect.freq (' ');
if (!calSelect.empty() && nspace!=len) {
String parseString = "select from $1 where " + calSelect;
Table *selected = new Table(tableCommand (parseString, *itsMainTable));
Table *selected = new Table(tableCommand (parseString, *itsMainTable).table());
delete itsMainTable;
itsMainTable=selected;
};
Expand Down
4 changes: 2 additions & 2 deletions cmake/FindCasaCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ else(NOT CASACORE_INCLUDE_DIR)
casacore_find_library(m)
list(APPEND CASACORE_LIBRARIES ${CMAKE_DL_LIBS})
elseif(${_comp} STREQUAL coordinates)
casacore_find_package(WcsLib REQUIRED)
casacore_find_package(WCSLIB REQUIRED)
elseif(${_comp} STREQUAL fits)
casacore_find_package(CfitsIO REQUIRED)
casacore_find_package(CFITSIO REQUIRED)
elseif(${_comp} STREQUAL scimath_f)
casacore_find_package(LAPACK REQUIRED)
endif(${_comp} STREQUAL casa)
Expand Down
2 changes: 1 addition & 1 deletion components/ComponentModels/FluxStdSrcs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ FluxStdSrcs::Source FluxStdSrcs::srcNameToEnum(const String& srcName, const MDir
os << LogIO::NORMAL
<< "Trying to determine source match by position..."
<< LogIO::POST;
Table tmpsubtab = tableCommand(taql);
Table tmpsubtab = tableCommand(taql).table();
if(tmpsubtab.nrow()) {
ScalarColumn<String> srcNameCol(tmpsubtab,"Name");
String srcNameInTable = srcNameCol.getColumnCells(RefRows(0,0))[0];
Expand Down
11 changes: 6 additions & 5 deletions components/ComponentModels/test/tFluxStandard2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <casacore/casa/OS/Path.h> // Needed by ComponentList
#include <casacore/casa/iostream.h>
#include <casacore/tables/Tables/Table.h>
#include <casacore/tables/Tables/TableUtil.h>

#include <casacore/casa/namespace.h>
int main(int argc, char* argv[])
Expand Down Expand Up @@ -245,10 +246,10 @@ int main(int argc, char* argv[])
AipsError);
cout << "\tPassed flux density test." << endl;
if(tempCLs[spwInd] != ""){
if(Table::canDeleteTable(tempCLs[spwInd]))
Table::deleteTable(tempCLs[spwInd]);
if(TableUtil::canDeleteTable(tempCLs[spwInd]))
TableUtil::deleteTable(tempCLs[spwInd]);
else
cout << "Table::canDeleteTable(" << tempCLs[spwInd]
cout << "TableUtil::canDeleteTable(" << tempCLs[spwInd]
<< ") returned False" << endl;
}
}
Expand Down Expand Up @@ -298,8 +299,8 @@ int main(int argc, char* argv[])
}
}
if(tempCLs[0] != ""){
if(Table::canDeleteTable(tempCLs[0]))
Table::deleteTable(tempCLs[0]);
if(TableUtil::canDeleteTable(tempCLs[0]))
TableUtil::deleteTable(tempCLs[0]);
else
cout << "Table::canDeleteTable(" << tempCLs[0]
<< ") returned False" << endl;
Expand Down
3 changes: 1 addition & 2 deletions components/SpectralComponents/ProfileFit1D.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,7 @@ void ProfileFit1D<T>::copy(const ProfileFit1D& other)
template <class T>
void ProfileFit1D<T>::checkType() const
{
T* p=0;
AlwaysAssert(whatType(p)==TpDouble,AipsError);
AlwaysAssert(whatType<T>()==TpDouble,AipsError);
}

} //#End casa namespace
35 changes: 18 additions & 17 deletions components/SpectralComponents/SpectralElementFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
//# Includes

#include <casacore/casa/Containers/Record.h>
#include <casacore/casa/Utilities/PtrHolder.h>
#include <components/SpectralComponents/CompiledSpectralElement.h>
#include <components/SpectralComponents/GaussianSpectralElement.h>
#include <components/SpectralComponents/GaussianMultipletSpectralElement.h>
Expand All @@ -38,12 +37,14 @@
#include <components/SpectralComponents/PowerLogPolynomialSpectralElement.h>
#include <components/SpectralComponents/SpectralElementFactory.h>

#include <memory>

namespace casacore { //# NAMESPACE CASACORE - BEGIN

SpectralElement* SpectralElementFactory::fromRecord(
const RecordInterface &in
) {
PtrHolder<SpectralElement> specEl;
std::unique_ptr<SpectralElement> specEl;
String origin = "SpectralElementFactory::fromRecord: ";
if (
! in.isDefined("type")
Expand Down Expand Up @@ -141,7 +142,7 @@ SpectralElement* SpectralElementFactory::fromRecord(
}
param(2) = GaussianSpectralElement::sigmaFromFWHM (param(2));
errs(2) = GaussianSpectralElement::sigmaFromFWHM (errs(2));
specEl.set(new GaussianSpectralElement(param(0), param(1), param(2)));
specEl.reset(new GaussianSpectralElement(param(0), param(1), param(2)));
specEl->setError(errs);
break;
case SpectralElement::LORENTZIAN:
Expand All @@ -155,17 +156,17 @@ SpectralElement* SpectralElementFactory::fromRecord(
"The width of a Lorentzian element must be positive"
);
}
specEl.set(new LorentzianSpectralElement(param(0), param(1), param(2)));
specEl->setError(errs);
break;
specEl.reset(new LorentzianSpectralElement(param(0), param(1), param(2)));
specEl->setError(errs);
break;
case SpectralElement::POLYNOMIAL:
if (param.nelements() == 0) {
throw AipsError(
"Polynomial spectral element must have order "
"of at least zero"
);
}
specEl.set(new PolynomialSpectralElement(param.nelements() - 1));
specEl.reset(new PolynomialSpectralElement(param.nelements() - 1));
specEl->set(param);
specEl->setError(errs);
break;
Expand All @@ -176,7 +177,7 @@ SpectralElement* SpectralElementFactory::fromRecord(
) {
String function;
in.get(RecordFieldId("compiled"), function);
specEl.set(new CompiledSpectralElement(function, param));
specEl.reset(new CompiledSpectralElement(function, param));
specEl->setError(errs);
}
else {
Expand All @@ -200,10 +201,11 @@ SpectralElement* SpectralElementFactory::fromRecord(
while(True) {
String id = "*" + String::toString(i);
if (gaussians.isDefined(id)) {
PtrHolder<SpectralElement> gauss(fromRecord(gaussians.asRecord(id)));
// MV: I found this code rather untidy w.r.t. pointer management, but leave it as is for now
std::unique_ptr<SpectralElement> gauss(fromRecord(gaussians.asRecord(id)));
comps.push_back(
*dynamic_cast<GaussianSpectralElement*>(
gauss.ptr()
gauss.get()
)
);
i++;
Expand All @@ -214,20 +216,20 @@ SpectralElement* SpectralElementFactory::fromRecord(
}
Matrix<Double> fixedMatrix = in.asArrayDouble("fixedMatrix");
fixedMatrix.reform(IPosition(2, comps.size()-1, 3));
specEl.set(new GaussianMultipletSpectralElement(comps, fixedMatrix));
specEl.reset(new GaussianMultipletSpectralElement(comps, fixedMatrix));
}
break;

case SpectralElement::POWERLOGPOLY: {
specEl.set(new PowerLogPolynomialSpectralElement(param));
specEl.reset(new PowerLogPolynomialSpectralElement(param));
specEl->set(param);
specEl->setError(errs);
}
break;

case SpectralElement::LOGTRANSPOLY: {
specEl.set(new LogTransformedPolynomialSpectralElement(param));
specEl->set(param);
specEl.reset(new LogTransformedPolynomialSpectralElement(param));
specEl->set(param);
specEl->setError(errs);
}
break;
Expand All @@ -243,9 +245,8 @@ SpectralElement* SpectralElementFactory::fromRecord(
specEl->fix(in.asArrayBool("fixed"));
}
// ready to return, fish out the pointer and return it without deleting it
SpectralElement *sp = specEl.ptr();
specEl.clear(False);
return sp;
SpectralElement *sp = specEl.release();
return sp;
}


Expand Down
17 changes: 8 additions & 9 deletions components/SpectralComponents/SpectralFit2.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
//# Includes
#include <components/SpectralComponents/SpectralFit.h>

#include <casacore/casa/Utilities/PtrHolder.h>
#include <components/SpectralComponents/CompiledSpectralElement.h>
#include <components/SpectralComponents/GaussianSpectralElement.h>
#include <components/SpectralComponents/LogTransformedPolynomialSpectralElement.h>
Expand Down Expand Up @@ -67,38 +66,38 @@ Bool SpectralFit::fit(
// The functions to fit
CompoundFunction<AutoDiff<MT> > func;
uInt ncomps = slist_p.nelements();
PtrHolder<Function<AutoDiff<MT> > > autodiff;
std::unique_ptr<Function<AutoDiff<MT> > > autodiff;
for (uInt i=0; i<ncomps; i++) {
SpectralElement *elem = slist_p[i];
uInt nparms = elem->getOrder();
SpectralElement::Types type = slist_p[i]->getType();
switch(type) {
case SpectralElement::GAUSSIAN: {
autodiff.set(new Gaussian1D<AutoDiff<MT> >());
autodiff.reset(new Gaussian1D<AutoDiff<MT> >());
}
break;
case SpectralElement::POLYNOMIAL: {
PolynomialSpectralElement *x = dynamic_cast<PolynomialSpectralElement *>(elem);
autodiff.set(new Polynomial<AutoDiff<MT> >(x->getDegree()));
autodiff.reset(new Polynomial<AutoDiff<MT> >(x->getDegree()));
}
break;
case SpectralElement::COMPILED:
// Allow fall through; these use the same code
case SpectralElement::GMULTIPLET: {
CompiledSpectralElement *x = dynamic_cast<CompiledSpectralElement *>(elem);
autodiff.set(new CompiledFunction<AutoDiff<MT> >());
autodiff.reset(new CompiledFunction<AutoDiff<MT> >());
dynamic_cast<CompiledFunction<AutoDiff<MT> > *>(
autodiff.ptr()
autodiff.get()
)->setFunction(x->getFunction());
}
break;
case SpectralElement::LORENTZIAN: {
autodiff.set(new Lorentzian1D<AutoDiff<MT> >());
autodiff.reset(new Lorentzian1D<AutoDiff<MT> >());
}
break;
case SpectralElement::POWERLOGPOLY: {
Vector<Double> parms = elem->get();
autodiff.set(new PowerLogarithmicPolynomial<AutoDiff<MT> > (nparms));
autodiff.reset(new PowerLogarithmicPolynomial<AutoDiff<MT> > (nparms));
}
break;
case SpectralElement::LOGTRANSPOLY: {
Expand All @@ -107,7 +106,7 @@ Bool SpectralFit::fit(
>(elem);
// treated as a polynomial for fitting purposes. The caller is responsible for passing the ln's of
// the ordinate and obscissa values to the fitter.
autodiff.set(new Polynomial<AutoDiff<MT> > (x->getDegree()));
autodiff.reset(new Polynomial<AutoDiff<MT> > (x->getDegree()));
}
break;
default:
Expand Down
5 changes: 3 additions & 2 deletions components/SpectralComponents/SpectralList.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@
#include <casacore/casa/Containers/RecordInterface.h>
#include <casacore/casa/Containers/Record.h>
#include <components/SpectralComponents/GaussianSpectralElement.h>
#include <casacore/casa/Utilities/PtrHolder.h>
#include <components/SpectralComponents/SpectralElementFactory.h>

#include <casacore/casa/iostream.h>

#include <memory>

namespace casacore { //# NAMESPACE CASACORE - BEGIN

//# Constructors
Expand Down Expand Up @@ -179,7 +180,7 @@ Bool SpectralList::fromRecord (String& errMsg, const RecordInterface& container)
for (uInt i=0; i<container.nfields(); i++) {
if (container.dataType(i)==TpRecord) {
const RecordInterface& rec = container.asRecord(i);
PtrHolder<SpectralElement> specEl(SpectralElementFactory::fromRecord(rec));
std::unique_ptr<SpectralElement> specEl(SpectralElementFactory::fromRecord(rec));
add(*specEl);
} else {
errMsg = String("Illegal record structure");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <casacore/casa/aips.h>
#include <casacore/casa/Arrays/ArrayMath.h>
#include <casacore/casa/Containers/Record.h>
#include <casacore/casa/Utilities/PtrHolder.h>
#include <components/SpectralComponents/PolynomialSpectralElement.h>

#include <components/SpectralComponents/GaussianSpectralElement.h>
Expand All @@ -44,6 +43,7 @@
#include <casacore/casa/namespace.h>

#include <vector>
#include <memory>

int main() {

Expand Down Expand Up @@ -213,10 +213,11 @@ int main() {
doublet.toRecord(myRec);
cout << "myrec " << myRec << endl;
cout << __FILE__ << " " << __LINE__ << endl;
PtrHolder<SpectralElement> ptr(SpectralElementFactory::fromRecord(myRec));
std::unique_ptr<SpectralElement> ptr(SpectralElementFactory::fromRecord(myRec));
AlwaysAssert(static_cast<bool>(ptr), AipsError);
cout << __FILE__ << " " << __LINE__ << endl;
GaussianMultipletSpectralElement out = *dynamic_cast<GaussianMultipletSpectralElement*>(
ptr.ptr()
GaussianMultipletSpectralElement& out = dynamic_cast<GaussianMultipletSpectralElement&>(
*ptr
);
cout << __FILE__ << " " << __LINE__ << endl;
cout << "out " << out << endl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <casacore/casa/aips.h>
#include <casacore/casa/Arrays/ArrayMath.h>
#include <casacore/casa/Containers/Record.h>
#include <casacore/casa/Utilities/PtrHolder.h>
#include <components/SpectralComponents/LogTransformedPolynomialSpectralElement.h>
#include <components/SpectralComponents/SpectralElementFactory.h>

Expand All @@ -41,6 +40,8 @@

#include <casacore/casa/namespace.h>

#include <memory>

int main() {
{
try {
Expand All @@ -58,8 +59,8 @@ int main() {
cout << "Test to/from record" << endl;
Record rec;
ltp.toRecord(rec);
PtrHolder<SpectralElement> el(SpectralElementFactory::fromRecord(rec));
LogTransformedPolynomialSpectralElement ltp2 = *dynamic_cast<LogTransformedPolynomialSpectralElement *>(el.ptr());
std::unique_ptr<SpectralElement> el(SpectralElementFactory::fromRecord(rec));
LogTransformedPolynomialSpectralElement ltp2 = *dynamic_cast<LogTransformedPolynomialSpectralElement *>(el.get());
AlwaysAssert(ltp == ltp2, AipsError);
}
catch (const AipsError& x) {
Expand Down
Loading
Loading