1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#include "imageweightinitializer.h"
#include <aocommon/logger.h>
#include "../io/imagefilename.h"
#include "../io/imageweightcache.h"
#include "../msproviders/msprovider.h"
#include "../structures/imageweights.h"
#include "../structures/imagingtable.h"
#include "../structures/mslistitem.h"
#include "mshelper.h"
#include "settings.h"
using aocommon::Logger;
using schaapcommon::reordering::MSSelection;
namespace wsclean {
std::shared_ptr<ImageWeights> InitializeWeights(
const Settings& settings, const ImagingTableEntry& entry,
const std::vector<MsListItem>& ms_list, ImageWeightCache& cache) {
if (settings.mfWeighting) {
return cache.GetMFWeights();
} else {
std::shared_ptr<ImageWeights> weights =
cache.Get(ms_list, entry.outputChannelIndex, entry.outputIntervalIndex);
if (settings.isWeightImageSaved) {
const std::string prefix = ImageFilename::GetPSFPrefix(
settings, entry.outputChannelIndex, entry.outputIntervalIndex);
weights->Save(prefix + "-weights.fits");
}
return weights;
}
}
void InitializeMfWeights(const Settings& settings,
const ImagingTable& imaging_table,
ImageWeightCache& cache, MsHelper& ms_helper) {
Logger::Info << "Precalculating MF weights for "
<< settings.weightMode.ToString() << " weighting...\n";
std::unique_ptr<ImageWeights> weights = cache.MakeEmptyWeights();
for (const ImagingTable::Group& group : imaging_table.SquaredGroups()) {
const ImagingTableEntry& entry = *group.front();
std::vector<MsListItem> ms_list = ms_helper.InitializeMsList(entry);
for (MsListItem& item : ms_list) {
weights->Grid(*item.ms_description->GetProvider());
}
}
weights->FinishGridding();
cache.SetMFWeights(std::move(weights));
if (settings.isWeightImageSaved)
cache.GetMFWeights()->Save(settings.prefixName + "-weights.fits");
}
} // namespace wsclean
|