Skip to content

Convert marine LETKF task to use JCB#3381

Closed
AndrewEichmann-NOAA wants to merge 16 commits into
NOAA-EMC:developfrom
AndrewEichmann-NOAA:feature/letkf-jcb
Closed

Convert marine LETKF task to use JCB#3381
AndrewEichmann-NOAA wants to merge 16 commits into
NOAA-EMC:developfrom
AndrewEichmann-NOAA:feature/letkf-jcb

Conversation

@AndrewEichmann-NOAA
Copy link
Copy Markdown
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
Copy Markdown
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.

#3250

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

AndrewEichmann-NOAA added a commit to NOAA-EMC/GDASApp that referenced this pull request Mar 11, 2025
# Description

This converts the prepoceanobs task to using an obs list that ingests
the jinja yaml observation configs in jcb-gdas. Also attempts to align
script-internal variable names with existing JEDI yaml nomenclature.
Similar changes will also be incorporated into
NOAA-EMC/global-workflow#3381

# Companion PRs

None

# Issues

Resolves #1285

# Automated CI tests to run in Global Workflow

- [x] C48mx500_3DVarAOWCDA <!-- JEDI low-res marine 3DVar cycled DA !-->
- [x] C48mx500_hybAOWCDA <!-- JEDI marine hybrid envar cycled DA !-->
jspsl pushed a commit to NOAA-EMC/GDASApp that referenced this pull request Mar 26, 2025
# Description

This converts the prepoceanobs task to using an obs list that ingests
the jinja yaml observation configs in jcb-gdas. Also attempts to align
script-internal variable names with existing JEDI yaml nomenclature.
Similar changes will also be incorporated into
NOAA-EMC/global-workflow#3381

# Companion PRs

None

# Issues

Resolves #1285

# Automated CI tests to run in Global Workflow

- [x] C48mx500_3DVarAOWCDA <!-- JEDI low-res marine 3DVar cycled DA !-->
- [x] C48mx500_hybAOWCDA <!-- JEDI marine hybrid envar cycled DA !-->
@DavidNew-NOAA DavidNew-NOAA added the JEDI Feature development to support JEDI-based DA label Apr 15, 2025
@AndrewEichmann-NOAA
Copy link
Copy Markdown
Contributor Author

Closing to set aside for GFSv18

DavidNew-NOAA pushed a commit to NOAA-EMC/GDASApp that referenced this pull request Jan 16, 2026
# Description

This converts the prepoceanobs task to using an obs list that ingests
the jinja yaml observation configs in jcb-gdas. Also attempts to align
script-internal variable names with existing JEDI yaml nomenclature.
Similar changes will also be incorporated into
NOAA-EMC/global-workflow#3381

# Companion PRs

None

# Issues

Resolves #1285

# Automated CI tests to run in Global Workflow

- [x] C48mx500_3DVarAOWCDA <!-- JEDI low-res marine 3DVar cycled DA !-->
- [x] C48mx500_hybAOWCDA <!-- JEDI marine hybrid envar cycled DA !-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

JEDI Feature development to support JEDI-based DA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Have marine letkf task use jcb infrastructure

2 participants