def output_interpolated_model_climatologies(self, test, test_data): ''' Save the netCDF file. ''' region_name = self.get_region_name_from_region(test.region) pth = os.path.join(self.parameter.test_clims_interpolated_output, region_name) clim_file = Base(pth, self.parameter.filename_output_template) logging.info('Saving interpolated climatologies to: %s' % clim_file()) clim_file.level = self.out_file.level clim_file.model_version = test.obs_or_model clim_file.table = self.table_realm clim_file.period = self.parameter.period clim_file.case_id = self.parameter.case_id clim_file.set_target_grid(self.parameter.target_grid, self.regrid_tool, self.regrid_method) clim_file.variable = self.var clim_file.region = region_name clim_file.realization = self.parameter.realization DataSet.apply_custom_keys(clim_file, self.parameter.custom_keys, self.var) clim_file.write(test_data, type="nc", id=self.var)
def output_interpolated_model_climatologies(self, test, test_data): ''' Save the netCDF file. ''' region_name = self.get_region_name_from_region(test.region) pth = os.path.join(self.parameter.test_clims_interpolated_output, region_name) clim_file = Base(pth, self.parameter.filename_output_template) logging.getLogger("pcmdi_metrics").info('Saving interpolated climatologies to: %s' % clim_file()) clim_file.level = self.out_file.level clim_file.model_version = test.obs_or_model clim_file.table = self.table_realm clim_file.period = self.parameter.period clim_file.case_id = self.parameter.case_id clim_file.set_target_grid( self.parameter.target_grid, self.regrid_tool, self.regrid_method) clim_file.variable = self.var clim_file.region = region_name clim_file.realization = self.parameter.realization DataSet.apply_custom_keys(clim_file, self.parameter.custom_keys, self.var) clim_file.write(test_data, type="nc", id=self.var)
def create_sftlf(parameter): """Create the sftlf file from the parameter.""" sftlf = {} for test in parameter.test_data_set: tmp_name = getattr(parameter, "sftlf_filename_template") if tmp_name is None: # Not defined from commandline or param file tmp_name = parameter.filename_template sft = Base(parameter.test_data_path, tmp_name) sft.model_version = test sft.table = "fx" sft.realm = "atmos" sft.period = getattr(parameter, "period", "") sft.ext = "nc" sft.case_id = getattr(parameter, "case_id", "") sft.target_grid = None sft.realization = "r0i0p0" DataSet.apply_custom_keys(sft, parameter.custom_keys, "sftlf") try: sftlf[test] = {"raw": sft.get("sftlf")} sftlf[test]["filename"] = os.path.basename(sft()) sftlf[test]["md5"] = sft.hash() except Exception: sftlf[test] = {"raw": None} sftlf[test]["filename"] = None sftlf[test]["md5"] = None if parameter.target_grid == "2.5x2.5": t_grid = cdms2.createUniformGrid(-88.875, 72, 2.5, 0, 144, 2.5) else: t_grid = parameter.target_grid sft = cdutil.generateLandSeaMask(t_grid) sft[:] = sft.filled(1.0) * 100.0 sftlf["target_grid"] = sft return sftlf
def create_sftlf(parameter): ''' Create the sftlf file from the parameter. ''' sftlf = {} for test in parameter.test_data_set: tmp_name = getattr(parameter, "sftlf_filename_template") if tmp_name is None: # Not defined from commandline or param file tmp_name = parameter.filename_template sft = Base(parameter.test_data_path, tmp_name) sft.model_version = test sft.table = "fx" sft.realm = "atmos" sft.period = getattr(parameter, 'period', '') sft.ext = "nc" sft.case_id = getattr(parameter, 'case_id', '') sft.target_grid = None sft.realization = "r0i0p0" DataSet.apply_custom_keys(sft, parameter.custom_keys, "sftlf") try: sftlf[test] = {"raw": sft.get("sftlf")} sftlf[test]["filename"] = os.path.basename(sft()) sftlf[test]["md5"] = sft.hash() except Exception: sftlf[test] = {"raw": None} sftlf[test]["filename"] = None sftlf[test]["md5"] = None if parameter.target_grid == "2.5x2.5": t_grid = cdms2.createUniformGrid(-88.875, 72, 2.5, 0, 144, 2.5) else: t_grid = parameter.target_grid sft = cdutil.generateLandSeaMask(t_grid) sft[:] = sft.filled(1.0) * 100.0 sftlf["target_grid"] = sft return sftlf