Skip to content
Snippets Groups Projects
Commit 833e197e authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Add recurring start date setting

parent af09ffd2
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,7 @@ config = configparser.ConfigParser()
config.read("PSILARTEMP.cfg")
year = os.getenv("YEAR")
recurring_start_date = os.getenv("RECURRING_START_DATE")
weatherdata_path = os.getenv("WEATHER_DATA_DIR")
tmp_path = "tmp/"
out_path = os.getenv("DATA_DIR")
......@@ -39,11 +40,17 @@ out_path = os.getenv("DATA_DIR")
# TODO: Put timezone out in .env
local_timezone = pytz.timezone("Europe/Oslo")
# If we are before the recurring start date, exit nicely
start_time = datetime.strptime(f"{year}-{recurring_start_date}","%Y-%m-%d")
if datetime.now() <= start_time:
print(f"Today is before the configured start time of {start_time}. Exiting.")
exit(0)
# """
# Calculate cumulated degree days above 5 degrees after 1st of April
# Remove all values before April 1st
subprocess.run(
f"cdo -selname,TM -seldate,{year}-04-01T00:00:00,{year}-12-31T00:00:00 {weatherdata_path}met_1_0km_nordic-{year}.nc {tmp_path}TM_from_april.nc",
f"cdo -selname,TM -seldate,{year}-{recurring_start_date}T00:00:00,{year}-12-31T00:00:00 {weatherdata_path}met_1_0km_nordic-{year}.nc {tmp_path}TM_from_april.nc",
shell=True,
)
# Subtracting 5 deg C from all cells
......
......@@ -2,6 +2,8 @@
# Year to run for
YEAR=2024
# Recurring start date (MM-DD)
RECURRING_START_DATE=04-01
# Where your application resides
HOME_DIR=/home/foo/
# Path to the weather data
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment