Skip to content

Commit

Permalink
debug: update yearlyname
Browse files Browse the repository at this point in the history
Previous code miss the first file
  • Loading branch information
Beforerr authored Oct 18, 2023
1 parent 5284f7d commit f7036a2
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions pyspedas/utilities/dailynames.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ def yearlynames(
directory: str
String containing the directory for the generated file names.
prefix: str
file name prefix.
Expand Down Expand Up @@ -138,23 +136,21 @@ def yearlynames(
dates = []

if resolution == "half-year":
# Generate all the January 1st and July 1st dates within the range
potential_dates = [
datetime(year, month, 1)
for year in range(start_date.year, end_date.year + 1)
for month in [1, 7]
]
# Adjust the start date to be 6 months prior to the specified start date
if start_date.month <= 6:
adjusted_start_date = datetime(start_date.year - 1, start_date.month + 6, 1)
else:
adjusted_start_date = datetime(start_date.year, start_date.month - 6, 1)

print(adjusted_start_date)

# Generate all the January 1st and July 1st dates within the range
potential_dates = [datetime(year, month, 1) for year in range(start_date.year, end_date.year + 1) for month in [1, 7]]

# Filter out dates outside the range
dates = [date for date in potential_dates if start_date <= date <= end_date]
dates = [date for date in potential_dates if adjusted_start_date < date <= end_date]
elif resolution == "year":
# Generate all the January 1st dates within the range
potential_dates = [
datetime(year, 1, 1) for year in range(start_date.year, end_date.year + 1)
]

# Filter out dates outside the range
dates = [date for date in potential_dates if start_date <= date <= end_date]
dates = [datetime(year, 1, 1) for year in range(start_date.year, end_date.year + 1)]
else:
raise ValueError("Invalid resolution specified. Choose 'year' or 'half-year'.")

Expand Down

0 comments on commit f7036a2

Please sign in to comment.