Skip to content

Commit

Permalink
Update plotspectra.py
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeshingles committed Mar 7, 2025
1 parent ed45526 commit 80da12d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions artistools/spectra/plotspectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,9 @@ def plot_artis_spectrum(
if plotpacketcount:
dfspectrum = dfspectrum.with_columns(y=pl.col("packetcount"))

dfspectrum = dfspectrum.filter(pl.col("x").is_between(supxmin * 0.9, supxmax * 1.1))
dfspectrum = dfspectrum.filter(pl.col("x").is_between(supxmin * 0.9, supxmax * 1.1)).sort(
"x", maintain_order=True
)

atspectra.print_integrated_flux(dfspectrum["y"], dfspectrum["x"])

Expand Down Expand Up @@ -454,8 +456,6 @@ def plot_artis_spectrum(

dfspectrum = pl.DataFrame({"x": new_lambda_angstroms, "y": binned_flux})

dfspectrum = dfspectrum.sort("x", maintain_order=True)

axis.plot(
dfspectrum["x"], dfspectrum["y"], label=linelabel_withdirbin if axindex == 0 else None, **plotkwargs
)
Expand Down
4 changes: 2 additions & 2 deletions artistools/spectra/spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ def get_exspec_bins(


def convert_angstroms_to_units(value_angstroms: float, new_units: str) -> float:
h = 4.1356677e-15 # Planck's constant [eV s]
c = 2.99792458e18 # speed of light [angstroms/s]
hc_ev_angstroms = h * c # [eV angstroms]
if new_units.lower() == "kev":
h = 4.1356677e-15 # Planck's constant [eV s]
hc_ev_angstroms = h * c # [eV angstroms]
return hc_ev_angstroms / value_angstroms / 1e3 # [keV]
if new_units.lower() == "hz":
return c / value_angstroms
Expand Down

0 comments on commit 80da12d

Please sign in to comment.