Skip to content

Commit d33df1c

Browse files
author
Chris Blanton
committed
possible wip
1 parent 4097401 commit d33df1c

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

Jinja2Filters/get_analysis_info.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def graph(self, chunk, analysis_only):
184184

185185
if self.script_frequency == chunk and self.date_range == self.experiment_date_range \
186186
and not self.cumulative:
187-
graph += f"+{chunk - one_year}/{self.script_frequency} = \"\"\"\n"
187+
graph += f"{self.script_frequency} = \"\"\"\n"
188188
if analysis_only:
189189
graph += f"data-catalog => ANALYSIS-{chunk}?\n"
190190
else:
@@ -232,7 +232,7 @@ def graph(self, chunk, analysis_only):
232232
graph += f"=> ANALYSIS-CUMULATIVE-{time_dumper.strftime(date, '%Y')}\n"
233233

234234
if not self.is_legacy:
235-
graph += f"install-analysis-{self.name}[^] => analysis-{self.name}-{time_dumper.strftime(date, '%Y')}\n"
235+
graph += f"install-analysis-{self.name}[^] => analysis-{self.name}-{time_dumper.strftime(self.experiment_date_range[0], '%Y')}_{time_dumper.strftime(date, '%Y')}\n"
236236
graph += f" \"\"\"\n"
237237
date += chunk
238238
if not self.is_legacy:
@@ -241,25 +241,24 @@ def graph(self, chunk, analysis_only):
241241

242242
if self.script_frequency == "R1":
243243
# Run the analysis once over a custom date range (can match experiment).
244-
date = self.date_range[1]
245-
graph += f"R1/{time_dumper.strftime(date, '%Y-%m-%dT00:00:00Z')} = \"\"\"\n"
244+
graph += f"R1/{time_dumper.strftime(self.date_range[0], '%Y-%m-%dT00:00:00Z')} = \"\"\"\n"
246245
if not analysis_only:
247246
if self.product == "av":
248247
graph += f"COMBINE-TIMEAVGS-{chunk}:succeed-all\n"
249248
else:
250249
graph += f"REMAP-PP-COMPONENTS-TS-{chunk}:succeed-all\n"
251250

252-
# Looping backwards through all previous chunks.
253-
d = date - chunk
254-
i = -1
255-
while d >= self.date_range[0]:
251+
# Looping forwards
252+
d = self.date_range[0]
253+
i = 0
254+
while d <= self.date_range[1]:
256255
if not analysis_only:
257256
if self.product == "av":
258257
graph += f"& COMBINE-TIMEAVGS-{chunk}[{i*chunk}]:succeed-all\n"
259258
else:
260259
graph += f"& REMAP-PP-COMPONENTS-TS-{chunk}[{i*chunk}]:succeed-all\n"
261-
i -= 1
262-
d -= chunk
260+
i += 1
261+
d += chunk
263262
if not analysis_only:
264263
graph += "=>\n"
265264
if self.product == "ts":
@@ -396,7 +395,8 @@ def definition(self, chunk, pp_dir):
396395
[[ANALYSIS-{chunk}]]
397396
inherit = ANALYSIS
398397
[[[environment]]]
399-
yr1 = $(cylc cycle-point --template=CCYY --offset=-{chunk - one_year})
398+
yr1 = $(cylc cycle-point --template=CCYY)
399+
yr2 = $(cylc cycle-point --template=CCYY --offset=+{chunk - one_year})
400400
databegyr = $yr1
401401
dataendyr = $yr2
402402
datachunk = {chunk.years}
@@ -438,14 +438,15 @@ def definition(self, chunk, pp_dir):
438438
# each chunk/interval, starting from the beginning of pp data
439439
# then we create an analysis script task for each of these task families.
440440
logger.info(f"{self.name}: Will run each chunk {chunk} from beginning {self.experiment_date_range[0]}")
441-
date = self.experiment_date_range[0] + chunk - one_year
441+
date = self.experiment_date_range[0]
442442
while date <= self.experiment_date_range[1]:
443-
date_str = time_dumper.strftime(date, '%Y')
443+
date_str1 = time_dumper.strftime(date, '%Y')
444+
date_str2 = time_dumper.strftime(date + chunk - one_year, '%Y')
444445

445446
# Add the task definition for each ending time.
446447
definitions += f"""
447-
[[analysis-{self.name}-{date_str}]]
448-
inherit = ANALYSIS-CUMULATIVE-{date_str}, analysis-{self.name}
448+
[[analysis-{self.name}-{time_dumper.strftime(self.experiment_date_range[0], "%Y")}_{date_str2}]]
449+
inherit = ANALYSIS-CUMULATIVE-{date_str2}, analysis-{self.name}
449450
"""
450451

451452
if self.is_legacy:
@@ -455,9 +456,9 @@ def definition(self, chunk, pp_dir):
455456

456457
# Add the task definition family for each ending time.
457458
year1 = time_dumper.strftime(self.experiment_date_range[0], "%Y")
458-
year2 = time_dumper.strftime(date, "%Y")
459+
year2 = time_dumper.strftime(date + chunk - one_year, "%Y")
459460
definitions += f"""
460-
[[ANALYSIS-CUMULATIVE-{date_str}]]
461+
[[ANALYSIS-CUMULATIVE-{date_str2}]]
461462
inherit = ANALYSIS
462463
[[[environment]]]
463464
yr1 = {year1}
@@ -490,7 +491,7 @@ def definition(self, chunk, pp_dir):
490491
dd += chunk
491492
years = "{" + str(years) + "}"
492493
definitions += f"""
493-
[[analysis-{self.name}-{date_str}]]
494+
[[analysis-{self.name}-{self.experiment_date_range[0]}_{date_str2}]]
494495
[[[environment]]]
495496
in_data_file = {self.components[0]}.{years}.{times}.nc
496497
"""
@@ -562,7 +563,7 @@ def definition(self, chunk, pp_dir):
562563
dd += chunk
563564
years = "{" + str(years) + "}"
564565
definitions += f"""
565-
[[analysis-{self.name}]]
566+
[[analysis-{self.name}-{date1_str}_{date2_str}]]
566567
[[[environment]]]
567568
in_data_file = {self.components[0]}.{years}.{times}.nc
568569
"""

flow.cylc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,6 @@ rename-split-to-pp-regrid<regrid_static> => remap-pp-components-static => combin
976976
FRE_ANALYSIS_GIT_URL = file:///home/fms/local/opt/fre-analysis/git
977977
FRE_ANALYSIS_ARCHIVE = /archive/fms/fre-analysis/test
978978
# fre-analysis template vars
979-
yr2 = $(cylc cycle-point --template=CCYY)
980979
out_dir = {{ ANALYSIS_DIR }}
981980
descriptor = {{ EXPERIMENT }}
982981
fremodule = fre/{{ FRE_VERSION }}

0 commit comments

Comments
 (0)