-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a39d418
commit d685301
Showing
2 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import math | ||
import numpy as np | ||
|
||
def calc_max_nsub( | ||
sn, | ||
nchan, | ||
duration, | ||
input_nsub, | ||
sn_desired=12., | ||
minimum_duration=480., | ||
): | ||
""" | ||
Calculate the maximum number of time subintegrations of sensitive ToAs for an archive. | ||
Parameters | ||
---------- | ||
sn : float | ||
The signal-to-noise ratio of the archive. | ||
nchan : int | ||
The number of frequency channels in the decimated archive. | ||
duration : float | ||
The duration of the archive in seconds. | ||
input_nsub : int | ||
The number of subintegrations of the input archive. | ||
sn_desired : float | ||
The desired signal-to-noise ratio (default: 12.). | ||
minimum_duration : float | ||
The minimum duration of the archive in seconds (default: 480.). | ||
Returns | ||
------- | ||
nsub : int | ||
The estimated number of subintegrations that will create the maximum number of sensitive ToAs. | ||
""" | ||
# Calc estimated sn when channelised | ||
sn_chan = sn / np.sqrt(nchan) | ||
|
||
# Calc duration estimate to get desired sn | ||
estimated_duration = duration * ( sn_desired / sn_chan ) **2 | ||
|
||
if estimated_duration < minimum_duration: | ||
# estimated duration is less than minimum so us minimum | ||
estimated_duration = minimum_duration | ||
|
||
# Work out nsub using math.floor to round down | ||
nsub = math.floor( duration / estimated_duration ) | ||
|
||
if nsub > input_nsub: | ||
# nsub is greater than input so use input | ||
nsub = input_nsub | ||
|
||
return nsub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import argparse | ||
|
||
from meerpipe.calc_max_nsub import calc_max_nsub | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description="Calculate maximum number of time subintegratons of sensitive ToAs for an archive") | ||
parser.add_argument( | ||
"--sn", | ||
type=float, | ||
required=True | ||
help="The signal-to-noise ratio of the archive", | ||
) | ||
parser.add_argument( | ||
"--nchan", | ||
type=int, | ||
required=True | ||
help="The number of frequency channels in the decimated archive", | ||
) | ||
parser.add_argument( | ||
"--duration", | ||
type=float, | ||
required=True | ||
help="The duration of the archive in seconds", | ||
) | ||
parser.add_argument( | ||
"--input_nsub", | ||
type=float, | ||
required=True | ||
help="The number of subintegrations of the input archive", | ||
) | ||
parser.add_argument( | ||
"--sn_desired", | ||
type=float, | ||
default=12., | ||
help="The desired signal-to-noise ratio (default: 12.)", | ||
) | ||
parser.add_argument( | ||
"--minimum_duration", | ||
type=float, | ||
default=480., | ||
help="The minimum duration of the archive in seconds (default: 480.)", | ||
) | ||
args = parser.parse_args() | ||
|
||
nsub = calc_max_nsub( | ||
sn, | ||
nchan, | ||
duration, | ||
input_nsub, | ||
sn_desired=12., | ||
minimum_duration=480, | ||
) | ||
if nsub = 1: | ||
print("1") | ||
else: | ||
print(f"1 {nsub}") | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |