def write(self): self.write_landfrac() self.write_mask() shutil.copyfile(self.um_restart, self.um_restart_output) # Update the um restart with new mask and landfrac. with nc.Dataset(self.mask_filename_nc) as mask_f: mask = np.copy(mask_f.variables['lsm'][0, 0, :, :]) # Flip because we use True to mean masked, UM uses True to mean # land. mask = abs(1 - mask) with nc.Dataset(self.lfrac_filename_nc) as lfrac_f: lfrac = lfrac_f.variables['lsm'][:] remask(self.um_restart_output, mask, lfrac)
def do_remask(self, restart_dump, mask): # Make a copy of the restart dump. restart_dump_copy = restart_dump + '.copy' shutil.copyfile(restart_dump, restart_dump_copy) remasked_item_codes = remask(restart_dump_copy, mask) return restart_dump_copy, remasked_item_codes