Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision d745e74710ab581d489e815095d0dd4ee91e9c35 authored by Bryna Hazelton on 15 September 2025, 18:00:43 UTC, committed by Jonathan Pober on 15 September 2025, 18:31:58 UTC
remove macos-13 from our CI matrix because it is deprecated
1 parent ea19da5
  • Files
  • Changes
  • 0617af3
  • /
  • scripts
  • /
  • convert_to_uvfits.py
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
revision badge
swh:1:rev:d745e74710ab581d489e815095d0dd4ee91e9c35
directory badge
swh:1:dir:5cb9d966777e4709e445efe230c8d8cbeee7aa7c
content badge
swh:1:cnt:45f02ab5cebb230508cfa51632772b8cb70f10f4

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
convert_to_uvfits.py
#!/usr/bin/env python
# Copyright (c) 2018 Radio Astronomy Software Group
# Licensed under the 2-clause BSD License

"""Convert any pyuvdata compatible file to UVFITS format."""

import argparse
import os
import sys

from astropy.time import Time

import pyuvdata

# setup argparse
a = argparse.ArgumentParser(
    description="A command-line script for converting file(s) to UVFITS format."
)
a.add_argument(
    "files",
    type=str,
    nargs="*",
    help="pyuvdata-compatible file(s) to convert to uvfits.",
)
a.add_argument(
    "--output_filename",
    type=str,
    default=None,
    help="Filepath of output file. Default is input with suffix replaced by .uvfits",
)
a.add_argument(
    "--phase_time",
    type=float,
    default=None,
    help="Julian Date to phase data to. Default is the first integration of the file.",
)
a.add_argument(
    "--overwrite",
    default=False,
    action="store_true",
    help="overwrite output file if it already exists.",
)
a.add_argument(
    "--verbose", default=False, action="store_true", help="report feedback to stdout."
)


# get args
args = a.parse_args()
history = " ".join(sys.argv)

# iterate over files
for filename in args.files:
    # check output
    if args.output_filename is None:
        splitext = os.path.splitext(filename)[1]
        if (
            splitext[1] == ".uvh5"
            or splitext[1] in [".ms", ".MS"]
            or splitext[1] == ".sav"
        ):
            outfilename = splitext[0] + ".uvfits"
        else:
            outfilename = filename + ".uvfits"
    else:
        outfilename = args.output_filename
    if os.path.exists(outfilename) and args.overwrite is False:
        print(f"{outfilename} exists, not overwriting...")
        continue

    # read in file
    UV = pyuvdata.UVData()
    UV.read(filename)

    if any(UV._check_for_cat_type("unprojected")):
        # phase data
        if args.phase_time is not None:
            UV.phase_to_time(Time(args.phase_time, format="jd", scale="utc"))
            if args.verbose:
                print(f"phasing {filename} to time {args.phase_time}")

        else:
            UV.phase_to_time(Time(UV.time_array[0], format="jd", scale="utc"))
            if args.verbose:
                print(f"phasing {filename} to time {UV.time_array[0]}")

    # write data
    UV.history += history
    if args.verbose:
        print(f"saving {outfilename}")
    UV.write_uvfits(outfilename, spoof_nonessential=True)
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API