Skip to content
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

Convert marine LETKF task to use JCB #3381

Draft
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

AndrewEichmann-NOAA
Copy link
Contributor

@AndrewEichmann-NOAA AndrewEichmann-NOAA commented Feb 24, 2025

Description

Converts marine LETKF to use JCB instead of GDASApp yamls for configuration, to bring in line with other tasks.

Resolves NOAA-EMC/GDASApp#1485

Needs NOAA-EMC/jcb-algorithms#11 merged

Type of change

  • Maintenance (code refactor, clean-up, new CI test, etc.)

Change characteristics

  • Is this a breaking change (a change in existing functionality)? NO
  • Does this change require a documentation update? NO
  • Does this change require an update to any of the following submodules? YES (If YES, please add a link to any PRs that are pending.)
    • GDAS

How has this been tested?

Clone, build, and run C48mx500_hybAOWCDA GDASApp ctests on Hera

Checklist

  • Any dependent changes have been merged and published
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have documented my code, including function, input, and output descriptions
  • My changes generate no new warnings
  • New and existing tests pass with my changes
  • This change is covered by an existing CI test or a new one has been added
  • Any new scripts have been added to the .github/CODEOWNERS file with owners
  • I have made corresponding changes to the system documentation if necessary

@AndrewEichmann-NOAA
Copy link
Contributor Author

AndrewEichmann-NOAA commented Feb 25, 2025

@DavidNew-NOAA this should be on the list for this month's sprint, but I can seem to find where that would be indicated.

https://github.com/orgs/NOAA-EMC/projects/41?pane=issue&itemId=94955508&issue=NOAA-EMC%7Cglobal-workflow%7C3250

Copy link
Contributor

@DavidNew-NOAA DavidNew-NOAA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly comments on how the JCB template is rendered.

These changes are going to be required for when we get around to refactoring marine_analysis.py and marine_letkf.py to use the Jedi class. When using the Jedi class, the JCB template is rendered by a single line. That means that j2-yamls need to do most of the work and not python.

See for example:

self.jedi_dict['atmensanlobs'].initialize(self.task_config)

See also:

self.jedi_config.input_config = self.render_jcb(task_config)

and:

def render_jcb(self, task_config: AttrDict, algorithm: Optional[str] = None) -> AttrDict:

letkf_yaml.save(self.task_config.letkf_yaml_file)
####################################################################################################

envconfig_jcb = copy.deepcopy(self.task_config)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the reason to make a copy of task_config. I know this is what marine_analysis.py does too, but with the atmosphere, aerosols, and snow, the JCB base and algo yamls are all parsed using task_config. I think at least for consistency we should do it this way for the marine jobs too.

####################################################################################################

envconfig_jcb = copy.deepcopy(self.task_config)
envconfig_jcb['cyc'] = int(os.getenv('cyc'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cyc and PDY should already be in task_config

envconfig_jcb = copy.deepcopy(self.task_config)
envconfig_jcb['cyc'] = int(os.getenv('cyc'))
envconfig_jcb['PDY'] = self.task_config.current_cycle.strftime('%Y%m%d')
envconfig_jcb['window_length'] = f"PT{self.task_config['assim_freq']}H"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, if you use task_config to render the JCB template, environment variables required for the rendering should be added to task_config in the constructor for the MarineLETKF class, like MARINE_WINDOW_BEGIN etc are, for example.

jcb_config = {**jcb_base_config, **jcb_algo_config}

# convert datetime to string
jcb_config['window_begin'] = self.task_config.MARINE_WINDOW_BEGIN.strftime('%Y-%m-%dT%H:%M:%SZ')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any JCB variables like this should be set in the JCB base yaml. In fact, window_begin and window_length are are already set in https://github.com/NOAA-EMC/GDASApp/blob/583e630a14d799495ea41147004916a9b6b81379/parm/soca/marine-jcb-base.yaml#L20

jcb_base_config = Template.substitute_structure(jcb_base_config, TemplateConstants.DOUBLE_CURLY_BRACES, envconfig_jcb.get)
jcb_base_config = Template.substitute_structure(jcb_base_config, TemplateConstants.DOLLAR_PARENTHESES, envconfig_jcb.get)
jcb_algo_config = parse_j2yaml(path=jcb_algo_yaml, data=envconfig_jcb)
jcb_algo_config = Template.substitute_structure(jcb_algo_config, TemplateConstants.DOUBLE_CURLY_BRACES, envconfig_jcb.get)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand this correctly, the need for the Template class is to render this line https://github.com/NOAA-EMC/GDASApp/blob/583e630a14d799495ea41147004916a9b6b81379/parm/soca/marine-jcb-3dfgat.yaml.j2#L5 ? If so, why can't obs be set directly in the algo yaml (marine-jcb-3dfgat.yaml)? In the atmosphere, aero, and snow, we set them directly, such as here: https://github.com/NOAA-EMC/GDASApp/blob/583e630a14d799495ea41147004916a9b6b81379/parm/atm/jcb-prototype_3dvar.yaml.j2#L7


# Render the full JEDI configuration file using JCB
jedi_config = render(jcb_config)
jedi_config['observations'] = observers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think by the time the JCB render method is called, this jedi_config dict should be complete and ready to render into a yaml. You should find some way to set the observations key using JCB templating directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Have marine letkf task use jcb infrastructure
2 participants