Skip to content

Commit

Permalink
Merge pull request #588 from astrorama/develop
Browse files Browse the repository at this point in the history
Release 0.22
  • Loading branch information
marcschefer authored Jul 4, 2024
2 parents af90cdd + 5499068 commit 8bcd56a
Show file tree
Hide file tree
Showing 37 changed files with 1,185 additions and 95 deletions.
1 change: 1 addition & 0 deletions .github/workflows/dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ $PYTHON-devel
$PYTHON-numpy
$PYTHON-pytest
$PYTHON-sphinx
$PYTHON-setuptools
CCfits-devel
blas-devel
$BOOST-$PYTHON-devel
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/run-litmus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ TARGET_BRANCH=${GITHUB_BASE_REF:-$GITHUB_REF}
# In the case of pull requests, this is the origin branch
ORIGIN_BRANCH=${GITHUB_HEAD_REF:-$GITHUB_REF}

export GIT_CLONE_PROTECTION_ACTIVE=false

# Platform-specific configuration
source /etc/os-release

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ find_package(ElementsProject)
#---------------------------------------------------------------

# Declare project name and version
elements_project(SourceXtractorPlusPlus 0.21 USE Alexandria 2.31.0 DESCRIPTION "SourceXtractor++, the next generation SExtractor")
elements_project(SourceXtractorPlusPlus 0.22 USE Alexandria 2.31.0 DESCRIPTION "SourceXtractor++, the next generation SExtractor")
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Documentation: https://astrorama.github.io/SourceXtractorPlusPlus/
SourceXtractor++ is available on [Anaconda Cloud for Linux and MacOSX](https://anaconda.org/astrorama/sourcextractor)

```bash
conda install -c conda-forge -c astrorama sourcextractor==0.19.2
conda install -c conda-forge -c astrorama sourcextractor==0.21
```

We would recommend, however, to install it into its own environment.

```bash
conda create -n sourcex -c astrorama -c conda-forge sourcextractor==0.19.2
conda create -n sourcex -c astrorama -c conda-forge sourcextractor==0.21
conda activate sourcex
```

Expand Down
11 changes: 9 additions & 2 deletions SEFramework/SEFramework/Pipeline/SourceGrouping.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <memory>
#include <set>

#include "SEFramework/Property/PropertyId.h"
#include "SEFramework/Pipeline/PipelineStage.h"
#include "SEFramework/Source/SourceGroupFactory.h"
#include "SEFramework/Source/SourceGroupInterface.h"
Expand Down Expand Up @@ -81,14 +82,20 @@ class GroupingCriteria {
virtual std::set<PropertyId> requiredProperties() const { return {}; }
};

class SourceGroupingInterface : public PipelineEmitter<SourceGroupInterface>, public PipelineReceiver<SourceInterface> {
public:
/// Returns the set of required properties to compute the grouping
virtual std::set<PropertyId> requiredProperties() const = 0;
};

/**
* @class SourceGrouping
* @brief SourceGrouping takes Source, groups them together according to its GroupingCriteria and stores them.
* When a ProcessSourcesEvent is received the sources that need to be processed are output together with the
* sources they are grouped with as a SourceGroup.
*
*/
class SourceGrouping : public PipelineEmitter<SourceGroupInterface>, public PipelineReceiver<SourceInterface> {
class SourceGrouping : public SourceGroupingInterface {
public:

/**
Expand All @@ -101,7 +108,7 @@ class SourceGrouping : public PipelineEmitter<SourceGroupInterface>, public Pipe
unsigned int hard_limit);

/// Returns the set of required properties to compute the grouping
std::set<PropertyId> requiredProperties() const;
std::set<PropertyId> requiredProperties() const override;

/// Handles a new Source
void receiveSource(std::unique_ptr<SourceInterface> source) override;
Expand Down
38 changes: 38 additions & 0 deletions SEImplementation/SEImplementation/Configuration/RngConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* RngConfig.h
*
* Created on: Mar 21, 2024
* Author: mschefer
*/

#ifndef _SEIMPLEMENTATION_CONFIGURATION_RNGCONFIG_H_
#define _SEIMPLEMENTATION_CONFIGURATION_RNGCONFIG_H_

#include "Configuration/Configuration.h"
#include "AlexandriaKernel/ThreadPool.h"

namespace SourceXtractor {

class RngConfig : public Euclid::Configuration::Configuration {
public:
explicit RngConfig(long manager_id);

virtual ~RngConfig() = default;

std::map<std::string, OptionDescriptionList> getProgramOptions() override;

void initialize(const UserValues& args) override;

unsigned int getSeed() const {
return m_seed;
}

private:
unsigned int m_seed;
};


}


#endif /* _SEIMPLEMENTATION_CONFIGURATION_RNGCONFIG_H_ */
50 changes: 50 additions & 0 deletions SEImplementation/SEImplementation/Grouping/AssocGrouping.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/** Copyright © 2019 - 2023 Université de Genève, LMU Munich - Faculty of Physics, IAP-CNRS/Sorbonne Université
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3.0 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef _SEIMPLEMENTATION_GROUPING_ASSOCGROUPING_H_
#define _SEIMPLEMENTATION_GROUPING_ASSOCGROUPING_H_

#include <map>

#include "SEFramework/Pipeline/SourceGrouping.h"

namespace SourceXtractor {

class AssocGrouping : public SourceGroupingInterface {
public:

AssocGrouping(std::shared_ptr<SourceGroupFactory> group_factory, unsigned int hard_limit);
virtual ~AssocGrouping() = default;

std::set<PropertyId> requiredProperties() const override;

/// Handles a new Source
void receiveSource(std::unique_ptr<SourceInterface> source) override;

/// Handles a ProcessSourcesEvent to trigger the processing of some of the Sources stored in SourceGrouping
void receiveProcessSignal(const ProcessSourcesEvent& event) override;

private:
std::shared_ptr<SourceGroupFactory> m_group_factory;
std::map<unsigned int, std::unique_ptr<SourceGroupInterface>> m_source_groups;
unsigned int m_hard_limit;

};

}

#endif /* _SEIMPLEMENTATION_GROUPING_ASSOCGROUPING_H_ */
44 changes: 10 additions & 34 deletions SEImplementation/SEImplementation/Grouping/GroupingFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,48 +42,24 @@ class GroupingFactory : public Configurable {

public:

explicit GroupingFactory(std::shared_ptr<SourceGroupFactory> source_group_factory)
: m_source_group_factory(source_group_factory), m_hard_limit(0) {}
explicit GroupingFactory(std::shared_ptr<SourceGroupFactory> source_group_factory);

virtual ~GroupingFactory() = default;

void reportConfigDependencies(Euclid::Configuration::ConfigManager& manager) const override {
manager.registerConfiguration<GroupingConfig>();
}

void configure(Euclid::Configuration::ConfigManager& manager) override {
auto grouping_config = manager.getConfiguration<GroupingConfig>();
switch (grouping_config.getAlgorithmOption()) {
case GroupingConfig::Algorithm::NO_GROUPING:
m_grouping_criteria = std::make_shared<NoGroupingCriteria>();
break;
case GroupingConfig::Algorithm::OVERLAPPING:
m_grouping_criteria = std::make_shared<OverlappingBoundariesCriteria>();
break;
case GroupingConfig::Algorithm::SPLIT_SOURCES:
m_grouping_criteria = std::make_shared<SplitSourcesCriteria>();
break;
case GroupingConfig::Algorithm::MOFFAT:
m_grouping_criteria = std::make_shared<MoffatCriteria>(grouping_config.getMoffatThreshold(), grouping_config.getMoffatMaxDistance());
break;
case GroupingConfig::Algorithm::ASSOC:
m_grouping_criteria = std::make_shared<AssocCriteria>();
break;
}
m_hard_limit = grouping_config.getHardLimit();
}

std::shared_ptr<SourceGrouping> createGrouping() const {
assert(m_grouping_criteria != nullptr);
assert(m_source_group_factory != nullptr);

return std::make_shared<SourceGrouping>(m_grouping_criteria, m_source_group_factory, m_hard_limit);
}
void reportConfigDependencies(Euclid::Configuration::ConfigManager& manager) const override;

void configure(Euclid::Configuration::ConfigManager& manager) override;

std::shared_ptr<SourceGroupingInterface> createGrouping() const;

private:
std::shared_ptr<GroupingCriteria> getCriteria() const;

GroupingConfig::Algorithm m_algorithm;
std::shared_ptr<GroupingCriteria> m_grouping_criteria;
std::shared_ptr<SourceGroupFactory> m_source_group_factory;
unsigned int m_hard_limit;
double m_moffat_max_distance;
};

} /* namespace SourceXtractor */
Expand Down
67 changes: 67 additions & 0 deletions SEImplementation/SEImplementation/Grouping/MoffatGrouping.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/** Copyright © 2019-2024 Université de Genève, LMU Munich - Faculty of Physics, IAP-CNRS/Sorbonne Université
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3.0 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef _SEIMPLEMENTATION_GROUPING_MOFFATGROUPING_H_
#define _SEIMPLEMENTATION_GROUPING_MOFFATGROUPING_H_

#include "SEFramework/Pipeline/SourceGrouping.h"
#include "SEUtils/QuadTree.h"

#include <map>
#include <vector>
#include <functional>

namespace SourceXtractor {

class MoffatGrouping : public SourceGroupingInterface {
public:
struct SourceInfo {
std::unique_ptr<SourceInterface> m_source;
double m_x, m_y;
size_t m_group_id;
};

using Group = std::vector<std::shared_ptr<SourceInfo>>;

MoffatGrouping(std::shared_ptr<GroupingCriteria> grouping_criteria,
std::shared_ptr<SourceGroupFactory> group_factory, unsigned int hard_limit, float max_range);
virtual ~MoffatGrouping() = default;

std::set<PropertyId> requiredProperties() const override;

/// Handles a new Source
void receiveSource(std::unique_ptr<SourceInterface> source) override;

/// Handles a ProcessSourcesEvent to trigger the processing of some of the Sources stored in SourceGrouping
void receiveProcessSignal(const ProcessSourcesEvent& event) override;

private:
void processGroup(unsigned int group_id);

std::shared_ptr<GroupingCriteria> m_grouping_criteria;
std::shared_ptr<SourceGroupFactory> m_group_factory;
unsigned int m_hard_limit;
float m_max_range;

size_t m_group_counter;
std::map<unsigned int, std::shared_ptr<Group>> m_groups;
QuadTree<std::shared_ptr<SourceInfo>> m_tree;
};

}

#endif /* _SEIMPLEMENTATION_GROUPING_MOFFATGROUPING_H_ */
50 changes: 50 additions & 0 deletions SEImplementation/SEImplementation/Grouping/SplitSourcesGrouping.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/** Copyright © 2019 - 2023 Université de Genève, LMU Munich - Faculty of Physics, IAP-CNRS/Sorbonne Université
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3.0 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef _SEIMPLEMENTATION_GROUPING_SPLITSOURCESGROUPING_H_
#define _SEIMPLEMENTATION_GROUPING_SPLITSOURCESGROUPING_H_

#include "SEFramework/Pipeline/SourceGrouping.h"

#include <map>

namespace SourceXtractor {

class SplitSourcesGrouping : public SourceGroupingInterface {
public:

SplitSourcesGrouping(std::shared_ptr<SourceGroupFactory> group_factory, unsigned int hard_limit);
virtual ~SplitSourcesGrouping() = default;

std::set<PropertyId> requiredProperties() const override;

/// Handles a new Source
void receiveSource(std::unique_ptr<SourceInterface> source) override;

/// Handles a ProcessSourcesEvent to trigger the processing of some of the Sources stored in SourceGrouping
void receiveProcessSignal(const ProcessSourcesEvent& event) override;

private:
std::shared_ptr<SourceGroupFactory> m_group_factory;
std::map<unsigned int, std::unique_ptr<SourceGroupInterface>> m_source_groups;
unsigned int m_hard_limit;

};

}

#endif /* _SEIMPLEMENTATION_GROUPING_SPLITSOURCESGROUPING_H_ */
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#ifndef _SEIMPLEMENTATION_PARTITION_MULTITHRESHOLDPARTITIONSTEP_H_
#define _SEIMPLEMENTATION_PARTITION_MULTITHRESHOLDPARTITIONSTEP_H_

#include <boost/random.hpp>

#include "SEUtils/Types.h"

#include "SEImplementation/Property/PixelCoordinateList.h"
Expand All @@ -48,7 +50,7 @@ class MultiThresholdPartitionStep : public PartitionStep {
public:

MultiThresholdPartitionStep(std::shared_ptr<SourceFactory> source_factory, SeFloat contrast,
unsigned int thresholds_nb, unsigned int min_deblend_area);
unsigned int thresholds_nb, unsigned int min_deblend_area, unsigned int seed);

virtual ~MultiThresholdPartitionStep() = default;

Expand All @@ -67,6 +69,8 @@ class MultiThresholdPartitionStep : public PartitionStep {
SeFloat m_contrast;
unsigned int m_thresholds_nb;
unsigned int m_min_deblend_area;
unsigned int m_seed;
boost::random::mt19937 m_rng;
};


Expand Down
Loading

0 comments on commit 8bcd56a

Please sign in to comment.