Skip to content

Commit

Permalink
Merge pull request #1656 from dlakaplan/pintkargs
Browse files Browse the repository at this point in the history
`pintk` can swap inputs
  • Loading branch information
abhisrkckl authored Oct 23, 2023
2 parents c86140e + 88ceb69 commit 2977542
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ the released changes.
- Piecewise orbital model (`BinaryBTPiecewise`)
- `TimingModel.fittable_params` property
- Simulate correlated noise using `pint.simulation` (also available via the `zima` script)
- `pintk` will recognize when timfile and parfile inputs are switched and swap them
- `pintk` can plot against solar elongation
- Optionally return the the log normalization factor of the likelihood function from the `Residuals.calc_chi2()` method.
- `DownhilWLSFitter` can now estimate white noise parameters and their uncertainties.
Expand Down
20 changes: 20 additions & 0 deletions src/pint/scripts/pintk.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import argparse

import sys
import os

import tkinter as tk
import tkinter.filedialog as tkFileDialog
import tkinter.messagebox as tkMessageBox
import matplotlib as mpl
from loguru import logger as log

import pint.logging

Expand Down Expand Up @@ -260,6 +262,24 @@ def main(argv=None):
pint.logging.setup(
level=pint.logging.get_level(args.loglevel, args.verbosity, args.quiet)
)
# see if the arguments were flipped
if (
os.path.splitext(args.parfile)[1] == ".tim"
and os.path.splitext(args.timfile)[1] == ".par"
):
log.debug(
f"Swapping inputs: parfile='{args.timfile}' and timfile='{args.parfile}'"
)
args.parfile, args.timfile = args.timfile, args.parfile
else:
if os.path.splitext(args.timfile)[1] != ".tim":
log.info(
f"Input timfile '{args.timfile}' has unusual extension '{os.path.splitext(args.timfile)[1]}': is this intended?"
)
if os.path.splitext(args.parfile)[1] != ".par":
log.info(
f"Input parfile '{args.parfile}' has unusual extension '{os.path.splitext(args.parfile)[1]}': is this intended?"
)

root = tk.Tk()
root.minsize(1000, 800)
Expand Down

0 comments on commit 2977542

Please sign in to comment.