Skip to content

(WIP) Save 3D marine analysis - #878

Draft
Dooruk wants to merge 85 commits into
developfrom
feature/save_tasks/save_analysis_fix_window
Draft

(WIP) Save 3D marine analysis#878
Dooruk wants to merge 85 commits into
developfrom
feature/save_tasks/save_analysis_fix_window

Conversation

@Dooruk

@Dooruk Dooruk commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

I have this version that works for the marine side as we won't have 4D analyses fields for a while.

For geos_cf and geos_atmos there is additional complexity in terms of:

  • use of model/r2d2.py by defining an dictionary for r2d2 to refer.
  • What type of grid will be stored? latlon or cubed?
  • (minor) is horizontal res part of r2d2 analysis item?
  • 4D analysis (not handled in this PR).

So I wanted to check with you @jeromebarre and @mer-a-o, whether you like this approach and would like to build on this, or would like to have a completely different geos_cf saveanalysis task? Sorry, I dragged this for a while, wanted SaveForecast to go in first.

For the last point (4D fields), I have

# --------------------------------------------------------------------------------------------------
def states_generator(
self,
background_frequency: str,
window_length: str,
window_begin_iso: str,
model: str = 'geos_marine',
marine_models: list = []
) -> list:
"""
Generates a list of states for JEDI configuration based on the model type.
Args:
background_frequency (str): ISO 8601 duration between background states.
window_length (str): ISO 8601 duration of the DA window.
window_begin_iso (str): ISO 8601 datetime string for the start of the window.
model (str): Model component name (e.g., 'geos_marine'). Defaults to 'geos_marine'.
marine_models (list): List of active marine model components (e.g., ['cice6']).
Returns:
list: A list of dictionaries, each representing a state with its date and filenames.
"""
states = []
self.logger.info('Generating states for model: '+model)
if model in ("geos_marine"):
states = self.marine_states(background_frequency, window_length, window_begin_iso,
marine_models)
return states
# --------------------------------------------------------------------------------------------------
def marine_states(self,
background_frequency: str,
window_length: str,
window_begin_iso: str,
marine_models: list
) -> list:
"""
Generates states specifically for the geos_marine model component.
Args:
background_frequency (str): ISO 8601 duration between background states.
window_length (str): ISO 8601 duration of the DA window.
window_begin_iso (str): ISO 8601 datetime string for the start of the window.
marine_models (list): List of active marine model components.
Returns:
list: List of dictionaries containing JEDI state information for marine models.
"""
static_part = {"basename": "./", "read_from_file": 1}
# Calculate the number of states using background frequency and window length
number_of_states = int(isodate.parse_duration(window_length)
/ isodate.parse_duration(background_frequency)) + 1
self.logger.info('Number of states: ' + str(number_of_states-1))
# Generate the list of states dictionary with date and marine filename entries.
# The date is calculated by adding the background frequency to the window begin date.
# The ocn_filename is calculated by adding the background frequency to the window begin date
states = []
# For FGAT and 4D-Var, the first state is the background state, hence we need to
# skip the first state in the loop by adding "-1" to the range function.
for i in range(1, number_of_states):
hours = int((isodate.parse_duration(background_frequency) * i).total_seconds() / 3600)
state_dto = isodate.parse_datetime(window_begin_iso) \
+ isodate.parse_duration(background_frequency) * i
state = {
"date": state_dto.strftime(datetime_formats['iso_format']),
"ocn_filename": "ocn.fc." + window_begin_iso + "." + f"PT{hours}H" + ".nc"
}
if 'cice6' in marine_models:
state.update({"ice_filename": "ice.fc." + window_begin_iso + "." + f"PT{hours}H" +
".nc"})
state.update(static_part)
states.append(state)
return states
# --------------------------------------------------------------------------------------------------
which may be useful to define analyses using background frequency but your call.

@Dooruk Dooruk self-assigned this Aug 19, 2026
@Dooruk Dooruk added enhancement New feature or request sea-ice da ocean da labels Aug 19, 2026
@Dooruk Dooruk linked an issue Aug 19, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

save analysis for geos_marine

1 participant