Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grab sample_rate and center_freq from filename if missing #200

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions apps/iridium-extractor
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import time
import getopt
import sys
import re
import threading
import os.path
import argparse
Expand Down Expand Up @@ -285,6 +286,21 @@ if __name__ == "__main__":
if fmt in sample_formats:
fmt = sample_formats[fmt]

# grab things from filename as fallback
if sample_rate is None and (g := re.search(r"-s(\d+(\.\d+)?(e[+-]\d+)?)-", filename)):
sample_rate = int(float(g.group(1)))

if args.file_info is None and (g := re.search(r"-t(\d{14}(\+\d{4})?)\.", filename)):
try:
import datetime
dt = datetime.datetime.strptime(g.group(1), "%Y%m%d%H%M%S" + "%z" * bool(g.group(2)))
args.file_info = f'i-{dt.timestamp():.20g}-t1'
except ValueError:
print("Couldn't parse timestamp in filename.", file=sys.stderr)

if center is None and (g := re.search(r"-f(\d+(\.\d+)?(e[+-]\d+)?)-", filename)):
center = int(float(g.group(1)))

if args.file_info is None:
if offline:
args.file_info = os.path.splitext(os.path.basename(filename))[0]
Expand Down
Loading