Skip to content

Commit

Permalink
lynt iterating
Browse files Browse the repository at this point in the history
  • Loading branch information
scfleming committed Jan 16, 2025
1 parent 87139b7 commit c008d9a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 37 deletions.
2 changes: 1 addition & 1 deletion astronify/simulator/add_transit_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

def add_transit_signal(
fluxes, transit_depth, transit_period, transit_start, transit_width
):
):
"""
:param fluxes: Array of fluxes to add the transit signal to.
:type fluxes: numpy.ndarray
Expand Down
43 changes: 19 additions & 24 deletions astronify/simulator/sim_lc.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@


def simulated_lc(
lc_type,
lc_ofile=SimLcConfig.sim_lc_ofile,
lc_length=SimLcConfig.sim_lc_length,
lc_noise=SimLcConfig.sim_lc_noise,
visualize=SimLcConfig.sim_lc_visualize,
lc_yoffset=SimLcConfig.sim_lc_yoffset,
transit_depth=SimLcConfig.sim_lc_transit_depth,
transit_period=SimLcConfig.sim_lc_transit_period,
transit_start=SimLcConfig.sim_lc_transit_start,
transit_width=SimLcConfig.sim_lc_transit_width,
sine_amp=SimLcConfig.sim_lc_sine_amp,
sine_period=SimLcConfig.sim_lc_sine_period,
flare_time=SimLcConfig.sim_lc_flare_time,
flare_amp=SimLcConfig.sim_lc_flare_amp,
flare_halfwidth=SimLcConfig.sim_lc_flare_halfwidth
):
lc_type,
lc_ofile=SimLcConfig.sim_lc_ofile,
lc_length=SimLcConfig.sim_lc_length,
lc_noise=SimLcConfig.sim_lc_noise,
visualize=SimLcConfig.sim_lc_visualize,
lc_yoffset=SimLcConfig.sim_lc_yoffset,
transit_depth=SimLcConfig.sim_lc_transit_depth,
transit_period=SimLcConfig.sim_lc_transit_period,
transit_start=SimLcConfig.sim_lc_transit_start,
transit_width=SimLcConfig.sim_lc_transit_width,
sine_amp=SimLcConfig.sim_lc_sine_amp,
sine_period=SimLcConfig.sim_lc_sine_period,
flare_time=SimLcConfig.sim_lc_flare_time,
flare_amp=SimLcConfig.sim_lc_flare_amp,
flare_halfwidth=SimLcConfig.sim_lc_flare_halfwidth
):
"""
Create light curve with specified parameters as a `~astropy.table.Table`,
and optionally writes a FITS file with the same information.
Expand Down Expand Up @@ -143,21 +143,16 @@ def simulated_lc(
hdr.append(("LCLENGTH", lc_length, "Number of fluxes."))
hdr.append(("LCYOFF", lc_yoffset, "Baseline flux value (unitless)."))
hdr.append(
("LCNOISE", lc_noise, "Std. dev. of normal dist. used to"
" apply noise.")
"LCNOISE", lc_noise, "Std. dev. of normal dist. used to apply noise.",
)
# Record the flare parameters used if adding a flare.
if lc_type == "flare":
hdr.append(
("FLARETIM",
flare_time,
"Index corresponding to the peak of the flare.")
"FLARETIM", flare_time, "Index corresponding to the peak of the flare.",
)
hdr.append(("FLAREAMP", flare_amp, "Amplitude of the flare."))
hdr.append(
("FLAREWID",
flare_halfwidth,
"Flare half-width (number of indices).")
"FLAREWID", flare_halfwidth, "Flare half-width (number of indices).",
)
# Record the sinusoidal parameters if adding a sinusoid.
if lc_type == "sine":
Expand Down
2 changes: 1 addition & 1 deletion astronify/simulator/sim_lc_setup_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def sim_lc_setup_args():
type=float,
default=sim_lc_config.sim_lc_sine_amp,
dest="sine_amp",
help="Amplitude of the sinusoidal signal to add. Default = %(default)s."
help="Amplitude of the sinusoidal signal to add. Default = %(default)s.",
)

sine_group.add_argument(
Expand Down
22 changes: 11 additions & 11 deletions astronify/utils/pitch_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@


def data_to_pitch(
data_array,
pitch_range=[100, 10000],
center_pitch=440,
zero_point="median",
stretch='linear',
minmax_percent=None,
minmax_value=None,
invert=False,
):
data_array,
pitch_range=[100, 10000],
center_pitch=440,
zero_point="median",
stretch='linear',
minmax_percent=None,
minmax_value=None,
invert=False,
):
"""
Map data array to audible pitches in the given range, and apply stretch and scaling
as required.
Expand Down Expand Up @@ -145,13 +145,13 @@ def data_to_pitch(

if (
(1 / zero_point) * (center_pitch - pitch_range[0]) + pitch_range[0]
) <= pitch_range[1]:
) <= pitch_range[1]:
pitch_array = (pitch_array / zero_point) * (
center_pitch - pitch_range[0]
) + pitch_range[0]
else:
pitch_array = ((pitch_array - zero_point) / (1 - zero_point)) * (
pitch_range[1] - center_pitch
) + center_pitch
) + center_pitch

return pitch_array

0 comments on commit c008d9a

Please sign in to comment.