-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtukey_tapering.c
65 lines (58 loc) · 1.77 KB
/
tukey_tapering.c
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
59
60
61
62
63
64
65
/*
* Copyright (c) 2024 Marzia Rivi
*
* This file is part of RadioLensfit.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include "datatype.h"
#include "tukey_tapering.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Tukey tapering function
* It returns a value 0 <= w <= 1, in particular 0 when x = 0 and 1 when x=n)
* https://wsclean.readthedocs.io/en/latest/tapering.html#tukey-taper
*/
double tukey_weight(double x, double n)
{
return 0.5*(1.0+cos((PI/n)*(x-n)));
}
double tukey_tapering(double uvdist, double minuv_l, double maxuv_l, double inner_tukey, double outer_tukey)
{
double x,n;
double w = 0;
if (uvdist <= minuv_l) w = 0.;
else if (uvdist >= maxuv_l) w = 0.;
else if ((minuv_l + inner_tukey) < uvdist && uvdist < (maxuv_l - outer_tukey)) w= 1.;
else if (minuv_l < uvdist && uvdist <= (minuv_l + inner_tukey))
{
x = uvdist - minuv_l;
n = inner_tukey;
w = tukey_weight(x,n);
}
else if ((maxuv_l - outer_tukey) <= uvdist && uvdist < maxuv_l)
{
x = maxuv_l - uvdist;
n = outer_tukey;
w = tukey_weight(x,n);
}
return w;
}
#ifdef __cplusplus
}
#endif