# Path: PyFVCOM/utilities/general.py
# def fix_range(a, nmin, nmax):
#     """
#     Given an array of values `a', scale the values within in to the range
#     specified by `nmin' and `nmax'.
# 
#     In the case where all the values are identical, the values are returned unchanged.
# 
#     Parameters
#     ----------
#     a : ndarray
#         Array of values to scale.
#     nmin, nmax : float
#         New minimum and maximum values for the new range.
# 
#     Returns
#     -------
#     b : ndarray
#         Scaled array.
# 
#     """
# 
#     A = a.min()
#     B = a.max()
#     C = nmin
#     D = nmax
# 
#     # In the case where all the values are the same, just return the original values.
#     if A != B:
#         b = (((D - C) * (a - A)) / (B - A)) + C
#     else:
#         b = a
# 
#     return b


from collections import namedtuple
from datetime import datetime
from datetime import timedelta
from PyFVCOM.utilities.general import fix_range
import jdcal
import numpy as np
import pytz
    # Add the end of the requested period to the list and convert to array.
    t.append(end_datetime)
    t = np.asarray(t)

    signal = np.repeat(min_rate, len(t)).astype(float)

    if ramp_duration[0] is None:
        signal_start_index_offset = 0
    else:
        signal_start_index_offset = np.ceil(ramp_duration[0] / time_interval).astype(int)

    if ramp_duration[-1] is None:
        signal_end_index_offset = len(t) - 1
    elif ramp_duration[-1] < 0:
        signal_end_index_offset = signal_start_index_offset
    else:
        signal_end_index_offset = np.ceil(ramp_duration[-1] / time_interval).astype(int)

    start_index = np.argmin([np.abs((tt - start_signal_datetime).total_seconds()) for tt in t])
    start_max_index = start_index + signal_start_index_offset
    end_index = np.argmin([np.abs((tt - end_signal_datetime).total_seconds()) for tt in t])
    end_max_index = np.min((end_index + signal_end_index_offset, len(signal) - 1))

    hyperbolic_start = np.arange(-signal_start_index_offset / 2, signal_start_index_offset / 2)
    hyperbolic_end = np.arange(-signal_start_index_offset / 2, signal_end_index_offset / 2)
    ramp_start = np.tanh((hyperbolic_start / signal_start_index_offset) * np.pi * 2)
    ramp_end = np.tanh((hyperbolic_end / signal_end_index_offset) * np.pi * 2)
    if np.any(ramp_start):
        ramp_start = fix_range(ramp_start, min_rate, max_rate)
    if np.any(ramp_end):

# Path: PyFVCOM/utilities/general.py
# def fix_range(a, nmin, nmax):
#     """
#     Given an array of values `a', scale the values within in to the range
#     specified by `nmin' and `nmax'.
# 
#     In the case where all the values are identical, the values are returned unchanged.
# 
#     Parameters
#     ----------
#     a : ndarray
#         Array of values to scale.
#     nmin, nmax : float
#         New minimum and maximum values for the new range.
# 
#     Returns
#     -------
#     b : ndarray
#         Scaled array.
# 
#     """
# 
#     A = a.min()
#     B = a.max()
#     C = nmin
#     D = nmax
# 
#     # In the case where all the values are the same, just return the original values.
#     if A != B:
#         b = (((D - C) * (a - A)) / (B - A)) + C
#     else:
#         b = a
# 
#     return b


# Path: PyFVCOM/utilities/time.py
from collections import namedtuple
from datetime import datetime
from datetime import timedelta
from PyFVCOM.utilities.general import fix_range
import jdcal
import numpy as np
import pytz

    # Add the end of the requested period to the list and convert to array.
    t.append(end_datetime)
    t = np.asarray(t)

    signal = np.repeat(min_rate, len(t)).astype(float)

    if ramp_duration[0] is None:
        signal_start_index_offset = 0
    else:
        signal_start_index_offset = np.ceil(ramp_duration[0] / time_interval).astype(int)

    if ramp_duration[-1] is None:
        signal_end_index_offset = len(t) - 1
    elif ramp_duration[-1] < 0:
        signal_end_index_offset = signal_start_index_offset
    else:
        signal_end_index_offset = np.ceil(ramp_duration[-1] / time_interval).astype(int)

    start_index = np.argmin([np.abs((tt - start_signal_datetime).total_seconds()) for tt in t])
    start_max_index = start_index + signal_start_index_offset
    end_index = np.argmin([np.abs((tt - end_signal_datetime).total_seconds()) for tt in t])
    end_max_index = np.min((end_index + signal_end_index_offset, len(signal) - 1))

    hyperbolic_start = np.arange(-signal_start_index_offset / 2, signal_start_index_offset / 2)
    hyperbolic_end = np.arange(-signal_start_index_offset / 2, signal_end_index_offset / 2)
    ramp_start = np.tanh((hyperbolic_start / signal_start_index_offset) * np.pi * 2)
    ramp_end = np.tanh((hyperbolic_end / signal_end_index_offset) * np.pi * 2)
    if np.any(ramp_start):
        ramp_start = fix_range(ramp_start, min_rate, max_rate)
    if np.any(ramp_end):

        ramp_end = fix_range(ramp_end, min_rate, max_rate)