-
Notifications
You must be signed in to change notification settings - Fork 50
Add sea ice recentering #1479
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
Merged
Merged
Add sea ice recentering #1479
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -65,6 +65,7 @@ def __init__(self, config: Dict) -> None: | |
|
|
||
| _window_begin = add_to_datetime(self.task_config.current_cycle, -to_timedelta(f"{self.task_config.assim_freq}H") / 2) | ||
| _window_end = add_to_datetime(self.task_config.current_cycle, to_timedelta(f"{self.task_config.assim_freq}H") / 2) | ||
| _enspert_relpath = os.path.relpath(self.task_config.DATAens, self.task_config.DATA) | ||
|
|
||
| local_dict = AttrDict({'window_begin': f"{window_begin.strftime('%Y-%m-%dT%H:%M:%SZ')}", | ||
| 'PARMsoca': os.path.join(self.task_config.PARMgfs, 'gdas', 'soca'), | ||
|
|
@@ -80,6 +81,8 @@ def __init__(self, config: Dict) -> None: | |
| 'stage_dir': DATA, | ||
| 'soca_input_fix_dir': self.task_config.SOCA_INPUT_FIX_DIR, | ||
| 'NMEM_ENS': self.task_config.NMEM_ENS, | ||
| 'GDUMP_ENS': self.task_config.GDUMP_ENS, | ||
| 'ENSPERT_RELPATH': _enspert_relpath, | ||
| 'MARINE_WINDOW_LENGTH': f"PT{config['assim_freq']}H", | ||
| 'recen_yaml_template': os.path.join(berror_yaml_dir, 'soca_ensrecenter.yaml'), | ||
| 'recen_yaml_file': os.path.join(DATA, 'soca_ensrecenter.yaml'), | ||
|
|
@@ -124,6 +127,9 @@ def initialize(self): | |
| # stage backgrounds | ||
| bkg_list = parse_j2yaml(self.task_config.MARINE_DET_STAGE_BKG_YAML_TMPL, self.task_config) | ||
| FileHandler(bkg_list).sync() | ||
| # stage ensemble backgrounds for soca2cice | ||
| ens_bkg_list = parse_j2yaml(self.task_config.MARINE_ENSDA_STAGE_BKG_YAML_TMPL, self.task_config) | ||
| FileHandler(ens_bkg_list).sync() | ||
|
|
||
| # ################################################################################ | ||
| # # Copy initial condition | ||
|
|
@@ -155,6 +161,37 @@ def initialize(self): | |
| ens_member_list.append([fname_in, fname_out]) | ||
|
|
||
| FileHandler({'copy': ens_member_list}).sync() | ||
| # stage ensemble ice restarts | ||
| # make a copy of the CICE6 restart | ||
| logger.info("---------------- Stage ensemble CICE restarts") | ||
| # set the restart date, dependent on the cycling type | ||
| if self.task_config.DOIAU: | ||
| # forecast initialized at the begining of the DA window | ||
| fcst_begin = self.task_config.MARINE_WINDOW_BEGIN_ISO | ||
| rst_date = self.task_config.MARINE_WINDOW_BEGIN.strftime('%Y%m%d.%H%M%S') | ||
| else: | ||
| # forecast initialized at the middle of the DA window | ||
| fcst_begin = self.task_config.MARINE_WINDOW_MIDDLE_ISO | ||
| rst_date = self.task_config.MARINE_WINDOW_MIDDLE.strftime('%Y%m%d.%H%M%S') | ||
| ens_cice_list = [] | ||
| for mem in range(1, nmem_ens+1): | ||
| mem_dir = os.path.join(self.task_config.ROTDIR, | ||
| f'enkf{RUN}.{gPDYstr}', | ||
| f'{gcyc}', | ||
| f'mem{str(mem).zfill(3)}', | ||
| 'model', | ||
| 'ice', | ||
| 'restart') | ||
| mem_dir_real = os.path.realpath(mem_dir) | ||
| f00 = f'{rst_date}.cice_model.res.nc' | ||
| fname_in = os.path.abspath(os.path.join(mem_dir_real, f00)) | ||
| fname_out = os.path.realpath(os.path.join(self.task_config.ens_dir, | ||
| "cice_model.res."+str(mem)+".nc")) | ||
| ens_cice_list.append([fname_in, fname_out]) | ||
| fname_out = os.path.realpath(os.path.join(self.task_config.ens_dir, | ||
| "cice_model.res.output."+str(mem)+".nc")) | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: this currently copies restarts twice (to keep input and output separate), we can change this before the merge to only copy the file once, and change it in place. (I coded input and output separately so I can easily see what the recentering does). |
||
| ens_cice_list.append([fname_in, fname_out]) | ||
| FileHandler({'copy': ens_cice_list}).sync() | ||
|
|
||
| ################################################################################ | ||
| # generate the YAML file for recenterer | ||
|
|
@@ -228,10 +265,6 @@ def finalize(self): | |
| mem_dir_list = [] | ||
| copy_list = [] | ||
|
|
||
| # Skip the analysis insertion into the CICE restart for now | ||
| # TODO (G): Add this back in when we have hardened the soca to cice | ||
| # change of variable | ||
|
|
||
| # Copy the recentering increment files to the member COMROOT directories | ||
| for mem in range(1, nmem_ens+1): | ||
| mem_dir = os.path.join(self.task_config.ROTDIR, | ||
|
|
@@ -242,9 +275,29 @@ def finalize(self): | |
| 'ocean') | ||
| mem_dir_real = os.path.realpath(mem_dir) | ||
| mem_dir_list.append(mem_dir_real) | ||
|
|
||
| copy_list.append([f'ocn.recenter.incr.{str(mem)}.nc', | ||
| os.path.join(mem_dir_real, incr_file)]) | ||
|
|
||
| FileHandler({'mkdir': mem_dir_list}).sync() | ||
| FileHandler({'copy': copy_list}).sync() | ||
|
|
||
| # Copy the CICE restart files to the member COMROOT directories | ||
| if os.getenv('DOIAU') == "YES": | ||
| cice_rst_date = self.task_config.MARINE_WINDOW_BEGIN.strftime('%Y%m%d.%H%M%S') | ||
| else: | ||
| cice_rst_date = cdate.strftime('%Y%m%d.%H%M%S') | ||
| mem_dir_list = [] | ||
| copy_list = [] | ||
| for mem in range(1, nmem_ens+1): | ||
| mem_dir = os.path.join(self.task_config.ROTDIR, | ||
| f'enkf{RUN}.{PDYstr}', | ||
| f'{cyc}', | ||
| f'mem{str(mem).zfill(3)}', | ||
| 'analysis', | ||
| 'ice') | ||
| mem_dir_real = os.path.realpath(mem_dir) | ||
| mem_dir_list.append(mem_dir_real) | ||
| copy_list.append([f'ens/cice_model.res.output.{str(mem)}.nc', | ||
| os.path.join(mem_dir_real, f'{cice_rst_date}.cice_model_anl.res.nc')]) | ||
| FileHandler({'mkdir': mem_dir_list}).sync() | ||
| FileHandler({'copy': copy_list}).sync() | ||
This file contains hidden or 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
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.
note: these parameters should be the same as in soca2cice used in the marineanlckpt; ideally we would reference the same yaml section in both places.