Skip to content

Commit

Permalink
Merge branch 'master' into quat_pointing
Browse files Browse the repository at this point in the history
  • Loading branch information
arahlin committed Oct 25, 2023
2 parents ffc614f + 0a56335 commit 0136569
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 83 deletions.
27 changes: 16 additions & 11 deletions calibration/python/bolopropertiesutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SplitByProperty(object):
G3TimestreamMap, G3MapInt, etc.
'''
def __init__(self, input='CalTimestreams', property=None, property_list=None,
output_root=None, bpm='BolometerProperties'):
output_root=None, bpm='BolometerProperties', drop_empty=False):
'''
Split the input map given by input into several output
maps named output_root + key (e.g. CalTimestreams + str(property)) with
Expand All @@ -40,6 +40,8 @@ def __init__(self, input='CalTimestreams', property=None, property_list=None,
bpm : str
The key name of the BolometerPropertiesMap from which to extract
the requested `property` for splitting the input map.
drop_empty : bool
If True, drop output maps that don't contain any bolometers.
'''
if property is None:
core.log_fatal("Property is a required argument")
Expand All @@ -54,6 +56,7 @@ def __init__(self, input='CalTimestreams', property=None, property_list=None,
self.props = None
self.bpmkey = bpm
self.bpm = None
self.drop_empty = drop_empty

@staticmethod
def converter(prop):
Expand Down Expand Up @@ -94,8 +97,10 @@ def __call__(self, frame):
continue
out[prop][b] = inmap[b]

for prop in out.keys():
frame['%s%s' % (self.output_root, prop)] = out[prop]
for prop, outmap in out.items():
if not len(outmap.keys()) and self.drop_empty:
continue
frame['%s%s' % (self.output_root, prop)] = outmap


@core.indexmod
Expand All @@ -108,7 +113,7 @@ class SplitByBand(SplitByProperty):
G3TimestreamMap, G3MapInt, etc.
'''
def __init__(self, input='CalTimestreams', output_root=None,
bands=None, bpm='BolometerProperties'):
bands=None, bpm='BolometerProperties', drop_empty=False):
'''
Split the input map given by input into several output
maps named output_root + band + GHz (e.g. CalTimestreams150GHz with
Expand All @@ -120,7 +125,7 @@ def __init__(self, input='CalTimestreams', output_root=None,
'''
super(SplitByBand, self).__init__(
input=input, output_root=output_root, property_list=bands,
bpm=bpm, property='band')
bpm=bpm, property='band', drop_empty=drop_empty)

@staticmethod
def converter(band):
Expand All @@ -137,10 +142,10 @@ def converter(band):
class SplitTimestreamsByBand(SplitByBand):

def __init__(self, input='CalTimestreams', output_root=None,
bands=None, bpm='BolometerProperties'):
bands=None, bpm='BolometerProperties', drop_empty=False):
core.log_warn("SplitTimestreamsByBand is deprecated, use SplitByBand instead")
super(SplitTimestreamsByBand, self).__init__(
input=input, output_root=output_root, bands=bands, bpm=bpm)
input=input, output_root=output_root, bands=bands, bpm=bpm, drop_empty=drop_empty)


@core.indexmod
Expand All @@ -153,7 +158,7 @@ class SplitByWafer(SplitByProperty):
G3TimestreamMap, G3MapInt, etc.
'''
def __init__(self, input='CalTimestreams', output_root=None,
wafers=None, bpm='BolometerProperties'):
wafers=None, bpm='BolometerProperties', drop_empty=False):
'''
Split the input map given by input into several output
maps named output_root + wafer (e.g. CalTimestreamsW172 with
Expand All @@ -165,7 +170,7 @@ def __init__(self, input='CalTimestreams', output_root=None,
'''
super(SplitByWafer, self).__init__(
input=input, output_root=output_root, property_list=wafers,
bpm=bpm, property='wafer_id')
bpm=bpm, property='wafer_id', drop_empty=drop_empty)

@staticmethod
def converter(wafer):
Expand All @@ -184,7 +189,7 @@ class SplitByPixelType(SplitByProperty):
G3TimestreamMap, G3MapInt, etc.
'''
def __init__(self, input='CalTimestreams', output_root=None,
types=None, bpm='BolometerProperties'):
types=None, bpm='BolometerProperties', drop_empty=False):
'''
Split the input map given by input into several output
maps named output_root + wafer (e.g. CalTimestreamsW172 with
Expand All @@ -196,7 +201,7 @@ def __init__(self, input='CalTimestreams', output_root=None,
'''
super(SplitByPixelType, self).__init__(
input=input, output_root=output_root, property_list=types,
bpm=bpm, property='pixel_type')
bpm=bpm, property='pixel_type', drop_empty=drop_empty)

@staticmethod
def converter(pixel_type):
Expand Down
60 changes: 0 additions & 60 deletions maps/include/maps/maputils.h

This file was deleted.

22 changes: 12 additions & 10 deletions maps/src/maputils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
#include <G3Logging.h>
#include <G3Units.h>

#include <maps/maputils.h>
#include <maps/G3SkyMap.h>
#include <maps/FlatSkyMap.h>
#include <maps/pointing.h>

#include <iostream>
Expand All @@ -19,11 +20,6 @@

using namespace G3Units;

void RemoveWeightsT(G3SkyMapPtr T, G3SkyMapWeightsConstPtr W, bool zero_nans)
{
RemoveWeights(T, NULL, NULL, W, zero_nans);
}

void RemoveWeights(G3SkyMapPtr T, G3SkyMapPtr Q, G3SkyMapPtr U, G3SkyMapWeightsConstPtr W,
bool zero_nans)
{
Expand Down Expand Up @@ -100,9 +96,9 @@ void RemoveWeights(G3SkyMapPtr T, G3SkyMapPtr Q, G3SkyMapPtr U, G3SkyMapWeightsC
}
}

void ApplyWeightsT(G3SkyMapPtr T, G3SkyMapWeightsConstPtr W)
void RemoveWeightsT(G3SkyMapPtr T, G3SkyMapWeightsConstPtr W, bool zero_nans)
{
ApplyWeights(T, NULL, NULL, W);
RemoveWeights(T, NULL, NULL, W, zero_nans);
}

void ApplyWeights(G3SkyMapPtr T, G3SkyMapPtr Q, G3SkyMapPtr U, G3SkyMapWeightsConstPtr W)
Expand Down Expand Up @@ -139,6 +135,11 @@ void ApplyWeights(G3SkyMapPtr T, G3SkyMapPtr Q, G3SkyMapPtr U, G3SkyMapWeightsCo
}
}

void ApplyWeightsT(G3SkyMapPtr T, G3SkyMapWeightsConstPtr W)
{
ApplyWeights(T, NULL, NULL, W);
}

boost::python::tuple GetRaDecMap(G3SkyMapConstPtr m)
{

Expand Down Expand Up @@ -525,8 +526,9 @@ MakePointSourceMask(G3SkyMapConstPtr map, const std::vector<double> & ra,
}


namespace bp = boost::python;
void maputils_pybindings(void){
PYBINDINGS("maps")
{
namespace bp = boost::python;
bp::def("remove_weights_t", RemoveWeightsT,
(bp::arg("T"), bp::arg("W"), bp::arg("zero_nans")=false),
"Remove weights from unpolarized maps. If zero_nans is true, empty pixels "
Expand Down
2 changes: 0 additions & 2 deletions maps/src/python.cxx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#include <pybindings.h>
#include <maps/maputils.h>

namespace bp = boost::python;

BOOST_PYTHON_MODULE(maps)
{
bp::import("spt3g.core");
bp::docstring_options docopts(true, true, false);
maputils_pybindings();
G3ModuleRegistrator::CallRegistrarsFor("maps");
}

0 comments on commit 0136569

Please sign in to comment.