Project

General

Profile

Revision 836:9e8a3379a845

ID9e8a3379a845
Parent 835:d623d705abd3
Child 837:bc739dd2cd7c

Added by Maarten Sneep almost 2 years ago

Add a swath-center selector

View differences:

src/pycama/transform/Filters.py
60 60
                 surface_classification):
61 61
        return primary
62 62

  
63

  
64
## Select only the central part of the swath in PyCAMA
65
#
66
# Cut off the edges of the swath.
67
class SwathPartSelection(AbstractTransformer):
68
    ## The actual callable interface
69
    #
70
    # This function simply returns the input array. The arguments are as defined in the superclass.
71
    def __init__(self, *kwargs):
72
        super().__init__()
73
        
74
        if 'count' in kwargs:
75
            self.count = kwargs['count']
76
        else:
77
            self.count = 200
78
        
79
    def __call__(self, primary,
80
                 secondary,
81
                 latitude,
82
                 longitude,
83
                 solar_zenith_angle,
84
                 viewing_zenith_angle,
85
                 solar_azimuth_angle,
86
                 viewing_azimuth_angle,
87
                 processing_quality_flags,
88
                 geolocation_flags,
89
                 surface_classification):
90
        
91
        n_pixels = primary.shape[0]
92
        offset = (n_pixels - self.count)//2
93
        try:
94
            mask = primary.mask
95
            dummy = mask[0]
96
        except (AttributeError, IndexError):
97
            primary = np.ma.asarray(primary)
98
            mask = np.zeros(primary.shape, dtype=np.bool)
99
        
100
        mask[0:offset, ...] = True
101
        mask[-offset:, ...] = True
102
        primary.mask = mask
103
        
104
        return primary
105

  
63 106
## %Unity transformation function for PyCAMA with extra debugging output.
64 107
#
65 108
# This no-op filter that prints out extra statistics on the data passing through it.

Also available in: Unified diff