1010)
1111
1212
13- class NormalizeIcebergIceShelfMelt (FilesForE3SMStep ):
13+ class AddTotalIcebergIceShelfMelt (FilesForE3SMStep ):
1414 """
15- A step for for normalizing data iceberg and ice-shelf melt rates on the
16- MPAS grid to a total flux of 1.0 and staging them in ``assembled_files``
15+ A step for for adding the total data iceberg and ice-shelf melt rates to
16+ to the data iceberg and ice-shelf melt files and staging them in
17+ ``assembled_files``
1718 """
1819 def __init__ (self , test_case ):
1920 """
@@ -24,7 +25,7 @@ def __init__(self, test_case):
2425 test_case : compass.TestCase
2526 The test case this step belongs to
2627 """
27- super ().__init__ (test_case , name = 'normalize_iceberg_ice_shelf_melt ' ,
28+ super ().__init__ (test_case , name = 'add_total_iceberg_ice_shelf_melt ' ,
2829 ntasks = 1 , min_tasks = 1 )
2930
3031 filename = 'Iceberg_Climatology_Merino_MPAS.nc'
@@ -41,12 +42,14 @@ def __init__(self, test_case):
4142
4243 def setup (self ):
4344 """
44- setup input files based on config options
45+ setup output files based on config options
4546 """
4647 super ().setup ()
4748 if self .with_ice_shelf_cavities :
48- self .add_output_file (filename = 'dib_merino_2020_normalized.nc' )
49- self .add_output_file (filename = 'dismf_paolo2023_normalized.nc' )
49+ self .add_output_file (
50+ filename = 'Iceberg_Climatology_Merino_MPAS_with_totals.nc' )
51+ self .add_output_file (
52+ filename = 'prescribed_ismf_paolo2023_with_totals.nc' )
5053
5154 def run (self ):
5255 """
@@ -59,11 +62,8 @@ def run(self):
5962
6063 logger = self .logger
6164
62- suffix = f'{ self .mesh_short_name } .{ self .creation_date } '
63-
6465 ds_dib = xr .open_dataset ('Iceberg_Climatology_Merino_MPAS.nc' )
6566 ds_dismf = xr .open_dataset ('prescribed_ismf_paolo2023.nc' )
66-
6767 ds_mesh = xr .open_dataset ('restart.nc' )
6868
6969 area_cell = ds_mesh .areaCell
@@ -87,39 +87,48 @@ def run(self):
8787 logger .info (f'total_flux: { total_flux :.1f} ' )
8888 logger .info ('' )
8989
90- for var in ['bergFreshwaterFluxData' ]:
91- ds_dib [var ] = ds_dib [var ] / total_flux
90+ for ds in [ds_dib , ds_dismf ]:
91+ ntime = ds .sizes ['Time' ]
92+ field = 'areaIntegAnnMeanDataIcebergFreshwaterFlux'
93+ ds [field ] = (('Time' ,), np .ones (ntime ) * total_dib_flux .values )
94+ ds [field ].attrs ['units' ] = 'kg s-1'
95+ field = 'areaIntegAnnMeanDataIceShelfFreshwaterFlux'
96+ ds [field ] = (('Time' ,), np .ones (ntime ) * total_dismf_flux .values )
97+ ds [field ].attrs ['units' ] = 'kg s-1'
98+ field = 'areaIntegAnnMeanDataIcebergIceShelfFreshwaterFlux'
99+ ds [field ] = (('Time' ,), np .ones (ntime ) * total_flux .values )
100+ ds [field ].attrs ['units' ] = 'kg s-1'
92101
93- write_netcdf (ds_dib , 'dib_merino_2020_normalized.nc' )
102+ dib_filename = 'Iceberg_Climatology_Merino_MPAS_with_totals.nc'
103+ write_netcdf (ds_dib , dib_filename )
94104
95- for var in ['dataLandIceFreshwaterFlux' , 'dataLandIceHeatFlux' ]:
96- ds_dismf [var ] = ds_dismf [var ] / total_flux
97-
98- write_netcdf (ds_dismf , 'dismf_paolo2023_normalized.nc' )
105+ dismf_filename = 'prescribed_ismf_paolo2023_with_totals.nc'
106+ write_netcdf (ds_dismf , dismf_filename )
99107
100108 norm_total_dib_flux = (ds_dib .bergFreshwaterFluxData * weights *
101- area_cell ).sum ()
109+ area_cell / total_flux ).sum ()
102110
103111 norm_total_dismf_flux = (ds_dismf .dataLandIceFreshwaterFlux *
104- area_cell ).sum ()
112+ area_cell / total_flux ).sum ()
105113
106114 norm_total_flux = norm_total_dib_flux + norm_total_dismf_flux
107115
108- logger .info (f'norm_total_dib_flux: { norm_total_dib_flux :.3f} ' )
109- logger .info (f'norm_total_dismf_flux: { norm_total_dismf_flux :.3f} ' )
110- logger .info (f'norm_total_flux: { norm_total_flux :.3f} ' )
116+ logger .info (f'norm_total_dib_flux: { norm_total_dib_flux :.16f} ' )
117+ logger .info (f'norm_total_dismf_flux: { norm_total_dismf_flux :.16f} ' )
118+ logger .info (f'norm_total_flux: { norm_total_flux :.16f} ' )
119+ logger .info (f'1 - norm_total_flux: { 1 - norm_total_flux :.16g} ' )
111120 logger .info ('' )
112121
113- prefix = 'Iceberg_Climatology_Merino_normalized'
122+ prefix = 'Iceberg_Climatology_Merino'
123+ suffix = f'{ self .mesh_short_name } .{ self .creation_date } '
114124 dest_filename = f'{ prefix } .{ suffix } .nc'
115-
116125 symlink (
117- os .path .abspath ('dib_merino_2020_normalized.nc' ),
118- f'{ self .ocean_inputdata_dir } /{ dest_filename } ' )
126+ os .path .abspath (dib_filename ),
127+ f'{ self .seaice_inputdata_dir } /{ dest_filename } ' )
119128
120- prefix = 'prescribed_ismf_paolo2023_normalized'
129+ prefix = 'prescribed_ismf_paolo2023'
130+ suffix = f'{ self .mesh_short_name } .{ self .creation_date } '
121131 dest_filename = f'{ prefix } .{ suffix } .nc'
122-
123132 symlink (
124- os .path .abspath ('dismf_paolo2023_normalized.nc' ),
133+ os .path .abspath (dismf_filename ),
125134 f'{ self .ocean_inputdata_dir } /{ dest_filename } ' )
0 commit comments