Skip to content

Commit

Permalink
update age gridding workflow to spit out optimised netcdf grids
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Mather committed Sep 16, 2024
1 parent 78485e3 commit 91008d1
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions gplately/oceans.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,9 @@ def _create_continental_mask(self, time_array):

grids.write_netcdf_grid(
self.continent_mask_filepath.format(time),
final_grid,
final_grid.astype('i1'),
extent=[-180, 180, -90, 90],
fill_value=None,
)
logger.info(f"Finished building a continental mask at {time} Ma!")

Expand All @@ -809,8 +810,9 @@ def _build_continental_mask(self, time: float, overwrite=False):

grids.write_netcdf_grid(
self.continent_mask_filepath.format(time),
final_grid,
final_grid.astype('i1'),
extent=[-180, 180, -90, 90],
fill_value=None,
)
logger.info(f"Finished building a continental mask at {time} Ma!")

Expand Down Expand Up @@ -1490,7 +1492,11 @@ def _save_netcdf_file(
grid_output = os.path.join(output_dir, grid_basename)

if unmasked:
grids.write_netcdf_grid(grid_output_unmasked, Z, extent=extent)
grids.write_netcdf_grid(
grid_output_unmasked,
Z,
extent=extent,
significant_digits=2)

# Identify regions in the grid in the continental mask
cont_mask = grids.Raster(data=continent_mask_filename.format(time))
Expand All @@ -1512,6 +1518,7 @@ def _save_netcdf_file(
grid_output,
Z,
extent=extent,
significant_digits=2,
)
logger.info(f"Save {name} netCDF grid at {time:0.2f} Ma completed!")

Expand Down Expand Up @@ -1578,7 +1585,10 @@ def _lat_lon_z_to_netCDF_time(
grid_output = os.path.join(output_dir, grid_basename)

if unmasked:
grids.write_netcdf_grid(grid_output_unmasked, Z, extent=extent)
grids.write_netcdf_grid(grid_output_unmasked,
Z,
extent=extent,
significant_digits=2)

# Identify regions in the grid in the continental mask
cont_mask = grids.Raster(data=continent_mask_filename.format(time))
Expand All @@ -1603,6 +1613,7 @@ def _lat_lon_z_to_netCDF_time(
grid_output,
Z,
extent=extent,
significant_digits=2,
)
logger.info(f"{zval_name} netCDF grids for {time:0.2f} Ma complete!")

Expand Down Expand Up @@ -1717,8 +1728,9 @@ def continent_contouring_buffer_and_gap_distance_radians(time, contoured_contine
)
grids.write_netcdf_grid(
continent_mask_filepath.format(time),
continent_mask.astype("float"),
continent_mask.astype("i1"),
extent=[-180, 180, -90, 90],
fill_value=None,
)
logger.info(
f"Finished building a continental mask at {time} Ma! (continent_contouring)"
Expand Down

0 comments on commit 91008d1

Please sign in to comment.