pyredshift 1.10__tar.gz → 1.12__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyredshift
3
- Version: 1.10
3
+ Version: 1.12
4
4
  Summary: Interactive redshifting of 1D astronomical spectra (Python successor of pdlredshift / redshift.f)
5
5
  Home-page: https://github.com/karlglazebrook/pyredshift
6
6
  Author: Karl Glazebrook
@@ -264,9 +264,15 @@ def read_spectrum(fname, fmt=None):
264
264
  def main():
265
265
  ap = argparse.ArgumentParser(
266
266
  prog="pyredshift",
267
- description="Interactive redshifting of 1D spectra (port of pdlredshift).",
268
- epilog="Formats: ascii csv fits sdss table (=jwst,jwst2,gabe,dja) "
269
- "xs xs2 outthere. Default is auto-detection.")
267
+ usage="pyredshift [-help] [-f FORMAT] [-z REDSHIFT] [--retro] "
268
+ "[--microns] file",
269
+ description="Interactive redshifting of 1D spectra "
270
+ "(port of pdlredshift), v%s." % redshift_module.__version__,
271
+ formatter_class=argparse.RawDescriptionHelpFormatter,
272
+ # format documentation lives in the module (FORMAT_HELP) so the
273
+ # -h epilog and the '?' help page cannot drift apart
274
+ epilog=redshift_module.formats_text())
275
+ ap.add_argument("-help", action="help", help=argparse.SUPPRESS)
270
276
  ap.add_argument("file", help="spectrum file (FITS, CSV or 2-column ascii)")
271
277
  ap.add_argument("-f", "--format", default=None, metavar="FORMAT",
272
278
  help="force the input format instead of auto-detecting")
@@ -13,7 +13,7 @@ from setuptools import setup
13
13
 
14
14
  setup(
15
15
  name="pyredshift",
16
- version="1.10",
16
+ version="1.12",
17
17
  description="Interactive redshifting of 1D astronomical spectra "
18
18
  "(Python successor of pdlredshift / redshift.f)",
19
19
  long_description=open("README.md").read(),
@@ -1,4 +1,4 @@
1
- <h1>pyredshift help</h1>
1
+ <h1>pyredshift help <span class="ver">v{version}</span></h1>
2
2
 
3
3
  <input type="radio" name="tabs" id="tab-keys" checked>
4
4
  <input type="radio" name="tabs" id="tab-lines">
@@ -98,13 +98,16 @@ colours as plotted):</p>
98
98
  <h2>Guide</h2>
99
99
  <p>pyredshift is a tool for measuring the redshift of a galaxy or quasar
100
100
  from a 1D spectrum, by eye. Run it as <code>pyredshift file</code> &mdash;
101
- the format (FITS image or table, SDSS, JWST, XSHOOTER, OutThere, CSV,
102
- 2-column ascii) is auto-detected, with <code>-f</code> to force one,
103
- <code>-z</code> to start from a known redshift and <code>--retro</code>
104
- for a retro PGPLOT-style black background. It plots the spectrum histogram-style with a
101
+ the file format is auto-detected (see the table below), with
102
+ <code>-f</code> to force one, <code>-z</code> to start from a known
103
+ redshift and <code>--retro</code> for a retro PGPLOT-style black
104
+ background. It plots the spectrum histogram-style with a
105
105
  crosshair cursor, and overlays rest-frame line identifications that
106
106
  follow the trial redshift shown at top left.</p>
107
107
 
108
+ <h2>File formats</h2>
109
+ {formats}
110
+
108
111
  <p>The basic game: spot a feature you can identify, put the crosshair on
109
112
  it and press <code>ESC</code> then the line's shortcut key (or
110
113
  <code>g</code> to type any rest wavelength) &mdash; the line labels jump
@@ -49,6 +49,10 @@ V1.10 - The cursor works over the whole window, as PGPLOT's did: keys and
49
49
  'x'/'y'/'e' can be pressed just outside the axis, pdlredshift
50
50
  style), the crosshair and the readout follow into the margins,
51
51
  and rubber-band drags may extend past the plot edge.
52
+ V1.11 - Proper file-format documentation: a per-format table in the
53
+ script's -h and a File formats section in the help page, both
54
+ generated from FORMAT_HELP here so they cannot drift apart.
55
+ V1.12 - The version number is shown by -h/-help and on the help page.
52
56
  """
53
57
 
54
58
  import ctypes
@@ -88,12 +92,33 @@ try:
88
92
  except AttributeError:
89
93
  pass
90
94
 
91
- __version__ = "1.10"
95
+ __version__ = "1.12"
92
96
 
93
97
  C_LIGHT = 2.99792458e8 # m/s
94
98
 
95
99
  TEMPLATE_NAME = "GNIRS_N4608" # template for the 't' key
96
100
 
101
+ # One description per reader in the pyredshift script - the single source
102
+ # for both the script's -h epilog and the Formats section of the help page.
103
+ # Keep in sync when adding a reader to the script.
104
+ FORMAT_HELP = [
105
+ ("fits", "1D (or 2D - row 1 used) FITS image with WCS; CD1_1 "
106
+ "overrides CDELT1, IRAF/SDSS log-lambda flags handled"),
107
+ ("sdss", "SDSS/BOSS binary table (LOGLAM/FLUX, either case)"),
108
+ ("table", "generic binary table with wave+flux columns; TUNIT "
109
+ "(um, nm, A) converted automatically "
110
+ "(aliases: jwst, jwst2, gabe, dja)"),
111
+ ("xs", "XSHOOTER 1D table spectrum (nm)"),
112
+ ("xs2", "XSHOOTER as a FITS image in extension 1"),
113
+ ("outthere", "OutThere multi-extension grism spectra, stitched "
114
+ "and flat-calibrated"),
115
+ ("csv", "comma-separated, header rows skipped"),
116
+ ("ascii", "2-column text"),
117
+ ]
118
+ FORMAT_NOTES = ("Default is auto-detection. Wavelengths that look like "
119
+ "microns are converted to Angstroms (--microns keeps them); "
120
+ "NaNs are treated as bad pixels and plot as gaps.")
121
+
97
122
  CONFIG_FILE = os.path.expanduser("~/.pyredshift.json") # remembers window size
98
123
  DEFAULT_FIGSIZE = (13.0, 5.5) # inches
99
124
 
@@ -215,11 +240,35 @@ def linelist_html():
215
240
  return "<table class='linelist'>\n%s\n</table>" % "\n".join(rows)
216
241
 
217
242
 
243
+ def formats_html():
244
+ """FORMAT_HELP as table rows + notes for the help page."""
245
+ rows = ["<tr><th>Format</th><th>Description</th></tr>"]
246
+ for name, desc in FORMAT_HELP:
247
+ rows.append("<tr><td><code>%s</code></td><td>%s</td></tr>"
248
+ % (name, desc))
249
+ return ("<table>\n%s\n</table>\n<p>%s</p>"
250
+ % ("\n".join(rows), FORMAT_NOTES))
251
+
252
+
253
+ def formats_text():
254
+ """FORMAT_HELP as aligned plain text for the script's -h epilog."""
255
+ import textwrap
256
+ width = max(len(name) for name, _ in FORMAT_HELP)
257
+ lines = ["Formats (-f):"]
258
+ for name, desc in FORMAT_HELP:
259
+ lines.append(textwrap.fill(
260
+ desc, width=79, initial_indent=" %-*s " % (width, name),
261
+ subsequent_indent=" " * (width + 4)))
262
+ lines.append(textwrap.fill(FORMAT_NOTES, width=79))
263
+ return "\n".join(lines)
264
+
265
+
218
266
  def help_html():
219
267
  """The help HTML body with the placeholders filled in."""
220
268
  if HELP_RAW is None:
221
269
  return None
222
- return HELP_RAW.format(template=TEMPLATE_NAME, linelist=linelist_html())
270
+ return HELP_RAW.format(template=TEMPLATE_NAME, linelist=linelist_html(),
271
+ formats=formats_html(), version=__version__)
223
272
 
224
273
 
225
274
  # ---------------------------------------------------------------------------
@@ -926,6 +975,7 @@ body { font-family: -apple-system, "Helvetica Neue", sans-serif;
926
975
  max-width: 46em; margin: 2em auto; padding: 0 1em;
927
976
  color: %(fg)s; background: %(bg)s; line-height: 1.45; }
928
977
  h1 { font-size: 1.5em; border-bottom: 2px solid %(rule)s; padding-bottom: 0.2em; }
978
+ h1 .ver { font-size: 0.6em; font-weight: normal; color: %(accent)s; }
929
979
  h2 { font-size: 1.15em; color: %(accent)s; margin-top: 1.4em; }
930
980
  table { border-collapse: collapse; margin: 0.5em 0; }
931
981
  th, td { border: 1px solid %(rule)s; padding: 0.25em 0.7em; text-align: left; }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyredshift
3
- Version: 1.10
3
+ Version: 1.12
4
4
  Summary: Interactive redshifting of 1D astronomical spectra (Python successor of pdlredshift / redshift.f)
5
5
  Home-page: https://github.com/karlglazebrook/pyredshift
6
6
  Author: Karl Glazebrook
File without changes
File without changes
File without changes
File without changes