meteortools.utils.convertSolLon

 1# Copyright (C) 2018-2023 Mark McIntyre
 2#
 3import numpy as np
 4try:
 5    from ..utils import date2JD
 6except Exception:
 7    from meteortools.utils import date2JD
 8
 9
10def sollon2jd(Year, Month, Long):
11    """
12    Calculate the julian date corresponding to a solar longitude. 
13    Because Solar Longitude is relative to the Spring equinox, the exact date 
14    of a given LS varies from year to year.  
15
16    Parameters:  
17        Year: [int] year you wish to calculate in.  
18        Month: [int] month you wish to calculate in.  
19        Long:  [float] The solar longitude to convert.   
20
21    Returns:  
22        [float] julian date  
23
24    Notes:  
25        The function is only stable for date ranges from 1900-2100.  
26    """
27
28    Long = np.radians(Long)
29    N = Year - 2000
30    if abs(N) > 100:
31        print("Algorithm is not stable for years below 1900 or above 2100")
32
33    JDM0 = 2451182.24736 + 365.25963575 * N
34    ApproxJD = date2JD(Year, Month, 15, 12, 0, 0)
35    DiffJD = ApproxJD-2451545
36
37    Dt = 1.94330 * np.sin(Long - 1.798135) + 0.01305272 * np.sin(2*Long + 2.634232) + 78.195268 + 58.13165 * Long - 0.0000089408 * DiffJD
38
39    if abs(ApproxJD - (JDM0 + Dt))>50:
40        Dt = Dt + 365.2596
41
42    JD1 = JDM0 + Dt
43
44    return JD1
def sollon2jd(Year, Month, Long):
11def sollon2jd(Year, Month, Long):
12    """
13    Calculate the julian date corresponding to a solar longitude. 
14    Because Solar Longitude is relative to the Spring equinox, the exact date 
15    of a given LS varies from year to year.  
16
17    Parameters:  
18        Year: [int] year you wish to calculate in.  
19        Month: [int] month you wish to calculate in.  
20        Long:  [float] The solar longitude to convert.   
21
22    Returns:  
23        [float] julian date  
24
25    Notes:  
26        The function is only stable for date ranges from 1900-2100.  
27    """
28
29    Long = np.radians(Long)
30    N = Year - 2000
31    if abs(N) > 100:
32        print("Algorithm is not stable for years below 1900 or above 2100")
33
34    JDM0 = 2451182.24736 + 365.25963575 * N
35    ApproxJD = date2JD(Year, Month, 15, 12, 0, 0)
36    DiffJD = ApproxJD-2451545
37
38    Dt = 1.94330 * np.sin(Long - 1.798135) + 0.01305272 * np.sin(2*Long + 2.634232) + 78.195268 + 58.13165 * Long - 0.0000089408 * DiffJD
39
40    if abs(ApproxJD - (JDM0 + Dt))>50:
41        Dt = Dt + 365.2596
42
43    JD1 = JDM0 + Dt
44
45    return JD1

Calculate the julian date corresponding to a solar longitude. Because Solar Longitude is relative to the Spring equinox, the exact date of a given LS varies from year to year.

Parameters:
Year: [int] year you wish to calculate in.
Month: [int] month you wish to calculate in.
Long: [float] The solar longitude to convert.

Returns:
[float] julian date

Notes:
The function is only stable for date ranges from 1900-2100.