-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split get_background into 3d and 4d tasks #268
Draft
tariqhamzeyssai
wants to merge
6
commits into
develop
Choose a base branch
from
feature/split_get_background
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c8d9c31
first commit, prep_background.py
aa3ebde
Back to basics, make window_type a suite question, get rid of prep_ba…
93efcb5
task lists for templated task names
f2d5399
remove GetBackground3d from background_frequency task list
de540a7
remove comments
9f4fcc5
Merge branch 'develop' into feature/split_get_background
danholdaway File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
src/swell/configuration/jedi/interfaces/geos_atmosphere/suite_questions.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
cycle_times: | ||
default_value: ['T00', 'T06', 'T12', 'T18'] | ||
options: ['T00', 'T06', 'T12', 'T18'] | ||
|
||
window_type: | ||
default_value: '4d' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -242,6 +242,3 @@ window_length: | |
window_offset: | ||
default_value: PT3H | ||
|
||
window_type: | ||
default_value: 4D | ||
|
3 changes: 3 additions & 0 deletions
3
src/swell/configuration/jedi/interfaces/geos_ocean/suite_questions.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
cycle_times: | ||
default_value: ['T00', 'T12'] | ||
options: ['T00', 'T12'] | ||
|
||
window_type: | ||
default_value: '3d' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,6 +88,3 @@ window_length: | |
window_offset: | ||
default_value: PT6H | ||
|
||
window_type: | ||
default_value: 3D | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# (C) Copyright 2021- United States Government as represented by the Administrator of the | ||
# National Aeronautics and Space Administration. All Rights Reserved. | ||
# | ||
# This software is licensed under the terms of the Apache Licence Version 2.0 | ||
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. | ||
|
||
|
||
# -------------------------------------------------------------------------------------------------- | ||
|
||
|
||
from swell.tasks.base.task_base import taskBase | ||
|
||
import isodate | ||
import os | ||
from r2d2 import fetch | ||
|
||
|
||
# -------------------------------------------------------------------------------------------------- | ||
|
||
r2d2_model_dict = { | ||
'geos_atmosphere': 'geos', | ||
'geos_ocean': 'mom6_cice6_UFS', | ||
} | ||
|
||
|
||
# -------------------------------------------------------------------------------------------------- | ||
|
||
class GetBackground3d(taskBase): | ||
|
||
def execute(self): | ||
|
||
"""Acquires 3D background files for a given experiment and cycle | ||
|
||
Parameters | ||
---------- | ||
All inputs are extracted from the JEDI experiment file configuration. | ||
See the taskBase constructor for more information. | ||
""" | ||
|
||
bkg_step = None | ||
|
||
# Parse config | ||
background_experiment = self.config.background_experiment() | ||
forecast_offset = self.config.analysis_forecast_window_offset() | ||
horizontal_resolution = self.config.horizontal_resolution() | ||
window_length = self.config.window_length() | ||
window_offset = self.config.window_offset() | ||
|
||
# Get window parameters | ||
local_background_time = self.da_window_params.local_background_time(window_offset, '3D') | ||
|
||
# Add to jedi config rendering dictionary | ||
self.jedi_rendering.add_key('local_background_time', local_background_time) | ||
|
||
# Convert to datetime durations | ||
# ----------------------------- | ||
window_length_dur = isodate.parse_duration(window_length) | ||
forecast_offset_dur = isodate.parse_duration(forecast_offset) | ||
|
||
# Duration between the start of the forecast that generated the background | ||
# and the middle of the current window | ||
# ------------------------------------------------------------------------------- | ||
forecast_duration_for_background = window_length_dur - forecast_offset_dur | ||
|
||
# Append the list of backgrounds to get with the first background | ||
# ----------------------------------------------------------------- | ||
bkg_step = isodate.duration_isoformat(forecast_duration_for_background) | ||
|
||
# Get the forecast start time | ||
# --------------------------- | ||
forecast_start_time = self.cycle_time_dto() - window_length_dur + forecast_offset_dur | ||
|
||
# Get name of this model component | ||
# -------------------------------- | ||
model_component = self.get_model() | ||
|
||
# Loop over background files in the R2D2 config and fetch | ||
# ------------------------------------------------------- | ||
self.logger.info(f"Background step being fetched: {bkg_step}") | ||
|
||
# Get r2d2 dictionary | ||
r2d2_dict = self.jedi_rendering.render_interface_model('r2d2') | ||
|
||
# Loop over fc | ||
# ------------ | ||
for fc in r2d2_dict['fetch']['fc']: | ||
|
||
# Reset target file | ||
# -------------------- | ||
file_type = fc['file_type'] | ||
target_file_template = fc['filename'] | ||
|
||
# Set the datetime format for the output files | ||
# -------------------------------------------- | ||
background_time = forecast_start_time + isodate.parse_duration(bkg_step) | ||
|
||
# Set the datetime templating in the target file name | ||
# --------------------------------------------------- | ||
target_file = background_time.strftime(target_file_template) | ||
|
||
fetch( | ||
date=forecast_start_time, | ||
target_file=target_file, | ||
model=r2d2_model_dict[model_component], | ||
file_type=file_type, | ||
fc_date_rendering='analysis', | ||
step=bkg_step, | ||
resolution=horizontal_resolution, | ||
type='fc', | ||
experiment=background_experiment) | ||
|
||
# Change permission | ||
os.chmod(target_file, 0o644) | ||
|
||
# -------------------------------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to have a
defer_to_model
here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think not, but I'm trying to remember why.